Skip to content

Revert .oindex and .vindex additions in _ElementwiseFunctionArray, NativeEndiannessArray, and BoolTypeArray classes - #8921

Closed
andersy005 wants to merge 13 commits into
pydata:mainfrom
andersy005:revert-indexing-changes-to-coding
Closed

Revert .oindex and .vindex additions in _ElementwiseFunctionArray, NativeEndiannessArray, and BoolTypeArray classes#8921
andersy005 wants to merge 13 commits into
pydata:mainfrom
andersy005:revert-indexing-changes-to-coding

Conversation

@andersy005

Copy link
Copy Markdown
Member

As noted in #8909, the use of .oindex and .vindex properties in coding/* appears to have broken some backends (e.g. scipy). This PR reverts those changes. We plan to bundle these changes into a separate backends feature branch (see this comment, which will be merged once we are confident about its impact on downstream dependencies.

…`, `NativeEndiannessArray`, and `BoolTypeArray` classes
@andersy005
andersy005 requested a review from dcherianApril 8, 2024 17:11
@andersy005

Copy link
Copy Markdown
MemberAuthor

@ocraft, when you get a chance do you mind try this branch and confirming whether this fixes your issue in #8909? as @dcherian noted, the minimal verifiable example you provided in #8909 (comment) wasn't reproducible on his end.

@andersy005
andersy005force-pushed the revert-indexing-changes-to-coding branch from aacbe04 to 721aaf1CompareApril 8, 2024 18:15
@ocraft

ocraft commented Apr 9, 2024

Copy link
Copy Markdown

Ok, I started from scratch and created venv with this set of packages (newest version of xarray and scipy with deps):

Package Version
--------------- -----------
numpy 1.26.4
packaging 24.0
pandas 2.2.1
pip 22.0.4
python-dateutil 2.9.0.post0
pytz 2024.1
scipy 1.13.0
setuptools 58.1.0
six 1.16.0
tzdata 2024.1
xarray 2024.3.0

and my example results in error as in #8909 (comment)
After uninstalling xarray and installing it from this pull request with

pip install https://github.com/pydata/xarray/pull/8921/commits/721aaf1f4dc88d8801717246941d9e63379c9aef

I got:

NotImplementedError: _ElementwiseFunctionArray._oindex_get method should be overridden

@andersy005

Copy link
Copy Markdown
MemberAuthor

@dcherian /@ocraft, i believe i've managed to revert the breaking changes. however, the temporary fixes turned out to be messier than i expected :(

@dcheriandcherian left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yuck but ok :)

@andersy005

Copy link
Copy Markdown
MemberAuthor

@ocraft, when you get a chance can you confirm this fully addresses the issue on your end?

@ocraft

Copy link
Copy Markdown

@ocraft, when you get a chance can you confirm this fully addresses the issue on your end?

I have this error: NotImplementedError: StackedBytesArray._oindex_get method should be overridde

@dcherian

Copy link
Copy Markdown
Contributor

Can we add the reproducer as a test case please

@dcherian

Copy link
Copy Markdown
Contributor

Can we add the reproducer as a test case please

@andersy005 can we add a test here please?

@andersy005

Copy link
Copy Markdown
MemberAuthor

Can we add the reproducer as a test case please

@andersy005 can we add a test here please?

i wanted to mention that, as i revisit this issue to add a test, i'm learning the temporary fix may become more complex than initially thought. should we attempt to fix this going forward (as part of the adding support for oindex/vindex to BackendArray) rather than reverting to the previous behavior?

@andersy005

Copy link
Copy Markdown
MemberAuthor

i can confirm that this issue is fully resolved on backend-indexing branch

In [1]: importxarrayasxr
...: ...: ds=xr.Dataset()
...: ds['A'] =xr.DataArray([[1, 'a'], [2,'b']],dims=['x','y'])
...: ds.to_netcdf('/tmp/test.nc')
...: ds2=xr.open_dataset('/tmp/test.nc')
...: ds2.sel(y=[1]).to_netcdf('/tmp/test.nc')
In [2]: In [2]: xr.show_versions()
INSTALLEDVERSIONS------------------commit: e96e70e04dc21607173d7cdcd9dba2c121d6aab6python: 3.12.3|packagedbyconda-forge| (main, Apr152024, 18:35:20) [Clang16.0.6 ]
python-bits: 64OS: DarwinOS-release: 23.4.0machine: arm64processor: armbyteorder: littleLC_ALL: NoneLANG: en_US.UTF-8LOCALE: ('en_US', 'UTF-8')
libhdf5: Nonelibnetcdf: Nonexarray: 2024.3.1.dev39+g04cca97a0pandas: 2.2.2numpy: 1.26.4scipy: 1.13.0netCDF4: Nonepydap: Noneh5netcdf: Noneh5py: Nonezarr: Nonecftime: Nonenc_time_axis: Noneiris: Nonebottleneck: Nonedask: Nonedistributed: Nonematplotlib: Nonecartopy: Noneseaborn: Nonenumbagg: Nonefsspec: Nonecupy: Nonepint: Nonesparse: Noneflox: Nonenumpy_groupies: Nonesetuptools: 69.5.1pip: 24.0conda: Nonepytest: Nonemypy: NoneIPython: 8.22.2sphinx: None

dcherian added a commit to dcherian/xarray that referenced this pull request Jun 18, 2025
dcherian added a commit to dcherian/xarray that referenced this pull request Jun 18, 2025
dcherian added a commit to dcherian/xarray that referenced this pull request Jun 18, 2025
kmuehlbauer pushed a commit that referenced this pull request Jun 20, 2025
* Making decoding arrays lazy too
* Add IndexingAdapter mixin class
* Cleanup backends some more
* Revert "Add IndexingAdapter mixin class"
This reverts commit 930f24d.
* Fix scipy backend
* Add scipy-only CI job
xref #8909
* Pin array-api-strict
* Fix doctest
* Add test for #8909Closes#8909, #8921
* Remove user warning
* fix types
* Add whats-new
* fix types
* Fix docs build
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScipyArrayWrapper' object has no attribute 'oindex'

3 participants

@andersy005@ocraft@dcherian