You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
___________________________ TestLocStream.test_slice ___________________________
self = <esmpy.test.test_api.test_locstream.TestLocStream testMethod=test_slice>
@pytest.mark.skipif(pet_count()!=1, reason="test must be run in serial")
def test_slice(self):
locstream = LocStream(5, name="Test LocStream")
> locstream2 = locstream[0:2]
src/esmpy/test/test_api/test_locstream.py:95:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = LocStream:
name = 'Test LocStream'
lower_bounds = array([0], dtype=int32)
upper_bounds = array([5], dtype=int32)
keys = dict_items([])
slc = slice(0, 2, None)
def __getitem__(self, slc):
# initialize slc_ls
slc_ls = slc
# check that this is actually a slicing operation and not just regular item retrieval
if not isinstance(slc, str):
# parallel slicing is not yet enabled (collective operation)
if pet_count() > 1:
raise SerialMethod
# re-initialize slc_ls
slc_ls = get_formatted_slice(slc, self.rank)
# slice at will
try:
> ret = super(LocStream, self).__getitem__(slc_ls)
E KeyError: slice(0, 2, None)
src/esmpy/api/locstream.py:130: KeyError
The cause of this is that slice() objects are hashable in Python >=3.12, whereas they were not in Python <3.12, and raised a TypeError. I believe the fix would be to change the try/catch to:
# slice at willifnotisinstance(slc_ls, slice):
ret=super(LocStream, self).__getitem__(slc_ls)
else:
# as of Python 3.12, slice objects are hashable so don't# raise a TypeErrorret=self.copy()
...
This at least seems to have allowed all tests to pass.
Discussed in https://github.com/orgs/esmf-org/discussions/313
Originally posted by xylar October 27, 2024
Requirements
Affiliation(s)
LANL
ESMF Version
v8.7.0 (and earlier)
Issue
I'm trying to build ESMPy 8.7.0 on conda-forge:
conda-forge/esmpy-feedstock#85
In the tests, I am seeing a KeyError:
The cause of this is that
slice()
objects are hashable in Python >=3.12, whereas they were not in Python <3.12, and raised aTypeError
. I believe the fix would be to change thetry
/catch
to:This at least seems to have allowed all tests to pass.
Autotag
@billsacks
The text was updated successfully, but these errors were encountered: