Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support complex arrays in xr.corr #7392

Merged
merged 11 commits into from
Feb 14, 2023
Merged

Support complex arrays in xr.corr #7392

merged 11 commits into from
Feb 14, 2023

Conversation

headtr1ck
Copy link
Collaborator

@headtr1ck headtr1ck commented Dec 19, 2022

@dcherian dcherian changed the title Corr Support complex arrays in xr.corr Jan 15, 2023
@headtr1ck
Copy link
Collaborator Author

Unfortunately dask does not support conjugate yet and raises an error.

Not sure how to proceed...

@dcherian
Copy link
Contributor

IT supports .conj so we now have a different error:

/home/runner/work/xarray/xarray/xarray/tests/test_computation.py:1597: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/runner/work/xarray/xarray/xarray/core/computation.py:1300: in cov
    return _cov_corr(da_a, da_b, dim=dim, ddof=ddof, method="cov")
/home/runner/work/xarray/xarray/xarray/core/computation.py:1402: in _cov_corr
    valid_count = valid_values.sum(dim) - ddof
/home/runner/work/xarray/xarray/xarray/core/_aggregations.py:1855: in sum
    return self.reduce(
/home/runner/work/xarray/xarray/xarray/core/dataarray.py:3667: in reduce
    var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
/home/runner/work/xarray/xarray/xarray/core/variable.py:1944: in reduce
    axis = self.get_axis_num(dim)
/home/runner/work/xarray/xarray/xarray/core/common.py:215: in get_axis_num
    return tuple(self._get_axis_num(d) for d in dim)
/home/runner/work/xarray/xarray/xarray/core/common.py:215: in <genexpr>
    return tuple(self._get_axis_num(d) for d in dim)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <xarray.Variable (x: 2, time: 2)>
array([[ True,  True],
       [ True,  True]])
dim = ['time', 'x']

    def _get_axis_num(self: Any, dim: Hashable) -> int:
        try:
            return self.dims.index(dim)
        except ValueError:
>           raise ValueError(f"{dim!r} not found in array dimensions {self.dims!r}")
E           ValueError: ['time', 'x'] not found in array dimensions ('x', 'time')

@headtr1ck headtr1ck requested a review from dcherian February 10, 2023 21:39
@github-actions github-actions bot added io topic-backends topic-zarr Related to zarr storage library labels Feb 12, 2023
@dcherian dcherian removed io topic-backends topic-zarr Related to zarr storage library labels Feb 13, 2023
Copy link
Contributor

@dcherian dcherian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@headtr1ck headtr1ck added the plan to merge Final call for comments label Feb 13, 2023
@dcherian dcherian merged commit 21d8645 into pydata:main Feb 14, 2023
dcherian added a commit to bzah/xarray that referenced this pull request Feb 28, 2023
* upstream/main: (291 commits)
  Update error message when saving multiindex (pydata#7475)
  DOC: cross ref the groupby tutorial (pydata#7555)
  [pre-commit.ci] pre-commit autoupdate (pydata#7543)
  supress namespace_package deprecation warning (doctests) (pydata#7548)
  [skip-ci] Add PDF of Xarray logo (pydata#7530)
  Support complex arrays in xr.corr (pydata#7392)
  clarification for thresh arg of dataset.dropna() (pydata#7481)
  [pre-commit.ci] pre-commit autoupdate (pydata#7524)
  Require to explicitly defining optional dimensions such as hue and markersize (pydata#7277)
  Use plt.rc_context for default styles (pydata#7318)
  Update HOW_TO_RELEASE.md (pydata#7512)
  Update whats-new for dev (pydata#7511)
  Fix whats-new for 2023.02.0 (pydata#7506)
  Update apply_ufunc output_sizes error message (pydata#7509)
  Zarr: drop "source" and  "original_shape" from encoding (pydata#7500)
  [pre-commit.ci] pre-commit autoupdate (pydata#7507)
  Whats-new for 2023.03.0
  Add `inclusive` argument to `cftime_range` and `date_range` and deprecate `closed` argument (pydata#7373)
  Make text match code example (pydata#7499)
  Remove Dask single-threaded setting in tests (pydata#7489)
  ...
@headtr1ck headtr1ck deleted the corr branch March 2, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plan to merge Final call for comments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xr.corr produces incorrect output for complex arrays
2 participants