home / github

Menu
  • GraphQL API
  • Search all tables

issues

Table actions
  • GraphQL API for issues

3 rows where state = "closed" and user = 11289391 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date), closed_at (date)

type 2

  • pull 2
  • issue 1

state 1

  • closed · 3 ✖

repo 1

  • xarray 3
id node_id number title user state locked assignee milestone comments created_at updated_at ▲ closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
1215946244 PR_kwDOAMm_X842zRtP 6515 Add allow_failures flag to Dataset.curve_fit StanczakDominik 11289391 closed 0     4 2022-04-26T13:17:18Z 2023-06-16T03:15:09Z 2023-06-16T03:15:09Z CONTRIBUTOR   0 pydata/xarray/pulls/6515
  • [x] Closes #6317
  • [ ] Tests added
  • [x] User visible changes (including notable bug fixes) are documented in whats-new.rst

For some reason, my grepping doesn't seem to show any existing tests for curve_fit...?

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6515/reactions",
    "total_count": 1,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 1
}
    xarray 13221727 pull
1157140667 I_kwDOAMm_X85E-JC7 6317 Handle scipy fitting errors in `xarray.curve_fit` StanczakDominik 11289391 closed 0     2 2022-03-02T12:38:04Z 2023-06-16T03:15:08Z 2023-06-16T03:15:08Z CONTRIBUTOR      

Is your feature request related to a problem?

I'm trying to fit a bunch of exponential decays to a dataset of dimensions (Time, experimental_index), along the Time dimension. This works nicely... except in some cases, scipy.optimize raises an error such as RuntimeError: Optimal parameters not found: The maximum number of function evaluations is exceeded.. That's, of course, reasonable, except in my use case I'm fine with a bunch of experimental_index failing to fit, and I'd still like to access the fits that made it through.

Describe the solution you'd like

I'm proposing adding a flag for xarray.curvefit, for example allow_failures: bool = False, that would take this part:

https://github.com/pydata/xarray/blob/f9037c41e36254bfe7efa9feaedd3eae5512bd11/xarray/core/dataset.py#L7738-L7752

and, if active, wrap popt, pcov = curve_fit(func, x, y, **kwargs) in a try/except block that would output nan just as the not len(y) conditional clause does if scipy.optimize.curve_fit fails with a RuntimeError.

Describe alternatives you've considered

At the moment, I sidestep the issue like this:

```python fits = [] for experimental_index in timetraces.experimental_index: trace = traces.sel(experimental_index=experimental_index)

try:
    fit = trace.curvefit(
        "Time",
        fitfunc,
        p0=(...),
        bounds={...},
    )
except (RuntimeError, TypeError) as e:
    logger.debug(...)
    continue

fits.append(fit)

fits = xarray.concat(fits, dim="experimental_index", coords="all") ``` but that seems like a pretty ugly hack...

Additional context

I would of course be happy to implement this!

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6317/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed xarray 13221727 issue
1092546388 PR_kwDOAMm_X84weBgE 6132 Check for just `...`, rather than `[...]` in `da.stack` StanczakDominik 11289391 closed 0     3 2022-01-03T14:13:28Z 2022-01-04T04:57:12Z 2022-01-03T23:05:23Z CONTRIBUTOR   0 pydata/xarray/pulls/6132
  • [x] Closes #6051
  • [x] Tests added
  • [ ] User visible changes (including notable bug fixes) are documented in whats-new.rst - not quite just yet, as I'm not 100% sure in what category you'd put it!

_stack_once seemed like a reasonable place to put this check, just going from the trace of where the test failed.

I also saw mypy failures during the local pre-commit step, but chose to ignore them for now given #6024. They seemed to pop up in unrelated areas, anyway.

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/6132/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
    xarray 13221727 pull

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issues] (
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [number] INTEGER,
   [title] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [state] TEXT,
   [locked] INTEGER,
   [assignee] INTEGER REFERENCES [users]([id]),
   [milestone] INTEGER REFERENCES [milestones]([id]),
   [comments] INTEGER,
   [created_at] TEXT,
   [updated_at] TEXT,
   [closed_at] TEXT,
   [author_association] TEXT,
   [active_lock_reason] TEXT,
   [draft] INTEGER,
   [pull_request] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [performed_via_github_app] TEXT,
   [state_reason] TEXT,
   [repo] INTEGER REFERENCES [repos]([id]),
   [type] TEXT
);
CREATE INDEX [idx_issues_repo]
    ON [issues] ([repo]);
CREATE INDEX [idx_issues_milestone]
    ON [issues] ([milestone]);
CREATE INDEX [idx_issues_assignee]
    ON [issues] ([assignee]);
CREATE INDEX [idx_issues_user]
    ON [issues] ([user]);
Powered by Datasette · Queries took 24.205ms · About: xarray-datasette