Skip to content

Commit

Permalink
Make 0.10.x branch test with numpy v2 and scipy v 1.14
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Oct 29, 2024
1 parent d07e897 commit 510b668
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Stoner/Image/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def _proxy(self, *args, **kargs):
if len(coords) == 2 and isinstance(coords[0], np.ndarray) and coords[0].ndim == 3:
im = type(self._img)(np.zeros(self._img.shape, dtype="uint32"))
im += coords[0][:, :, 0]
im += coords[0][:, :, 1] * 256
im += coords[0][:, :, 2] * 256**2
im += coords[0][:, :, 1].astype("uint32") * 256
im += coords[0][:, :, 2].astype("uint32") * 256**2
im[im == 16777215] = 0
im.convert(self._img.dtype)
self._img[im != 0] = im[im != 0]
Expand Down
2 changes: 1 addition & 1 deletion Stoner/Image/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
np.float64: (-1.0, 1.0),
}

if np_version.major==1 and np_version.minon<24:
if np_version.major == 1 and np_version.minor < 24:
dtype_range[np.bool8] = (False, True)

integer_types = (np.uint8, np.uint16, np.int8, np.int16)
Expand Down
2 changes: 1 addition & 1 deletion Stoner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Options = _Options()


__version_info__ = ("0", "10", "10")
__version_info__ = ("0", "10", "11")
__version__ = ".".join(__version_info__)

__homepath__ = pathlib.Path(__file__).parent.resolve()
Expand Down
1 change: 1 addition & 0 deletions Stoner/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def get_filedialog(what="file", **opts):
raise RuntimeError(f"Unable to recognise required file dialog type:{what}")
return fileDialog.openDialog(mode=funcs[what], **opts)


if np_version.major >= 2:
int_types += (int, np.int8, np.int16, np.int32, np.int64)
elif np_version.minor >= 20:
Expand Down
2 changes: 2 additions & 0 deletions Stoner/core/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ def __getitem__(self, ix):
return ret.dtype.type(ret)
if not isinstance(ret, np.ndarray): # bugout for scalar returns
return ret
if isinstance(ix, tuple) and len(ix) == 0:
return ret
if ret.ndim >= 2: # Potentially 2D array here
if ix[-1] is None: # Special case for increasing an array dimension
if self.ndim == 1: # Going from 1 D to 2D
Expand Down
2 changes: 1 addition & 1 deletion Stoner/core/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DataFileSearchMixin:
def _search_index(self, xcol=None, value=None, accuracy=0.0, invert=False):
"""Return an array of booleans for indexing matching rows for use with search method."""
_ = self._col_args(scalar=False, xcol=xcol)
x = self.find_col(_.xcol)
x = self.find_col(_.xcol, force_list=True)[0] # Workaround in newer numpy
if isinstance(value, (int_types, float)): # Search for a value in x-column
ix = np.isclose(self.data[:, x], value, atol=accuracy)
elif isinstance(value, tuple) and len(value) == 2: # within a range of values
Expand Down
2 changes: 1 addition & 1 deletion Stoner/formats/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _load(self, filename=None, *args, **kargs):
tmp = DataFile(grp.as_dataframe())
self.data = tmp.data
self.column_headers = tmp.column_headers
except (IOError, ValueError, TypeError, StonerLoadError) as err:
except (IOError, ValueError, TypeError, StonerLoadError, RuntimeError) as err:
from traceback import format_exc

raise StonerLoadError(f"Not a TDMS File \n{format_exc()}") from err
Expand Down
19 changes: 10 additions & 9 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,32 @@ build:

requirements:
build:
- python >=3.9
- python >=3.11
- pytest
- pytest-runner

run:
- python >=3.9
- scipy >1.7
- numpy >=1.18
- matplotlib >=3.0
- scikit-image >=0.17
- python >=3.11
- scipy >=1.14
- numpy >=2.0
- matplotlib >=3.8
- scikit-image >=0.24
- h5py
- cycler >=0.10.0
- filemagic >=1.6
- image-registration >=0.2.1
- lmfit >=0.9.7
- lmfit >=1.3
- memoization >=0.1.4
- npTDMS >=1.9.0
- python-dateutil >=2.7.0
- statsmodels
- tabulate >=0.8
- tabulate >=0.9
- imreg_dft >=2.0
- multiprocess >=0.70
- dill >=0.2.8
- urllib3 >=1.26
- python-dateutil >=2.8
- dateutil >=2.8


about:
home: https://github.com/gb119/Stoner-PythonCode/
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
scipy>1.4
numpy>=1.18
matplotlib>=3.0
scikit-image>=0.17
scipy>=1.14
numpy>=2.0
matplotlib>=3.8
scikit-image>=0.24
h5py
cycler>=0.10.0
filemagic>=1.6
image-registration>=0.2.1
lmfit>=0.9.7
lmfit>=1.3
memoization>=0.1.4
npTDMS>=1.9.0
python-dateutil>=2.7.0
statsmodels
tabulate>=0.8
tabulate>=0.9
imreg_dft>=2.0
multiprocess>=0.70
dill>=0.2.8
Expand Down
2 changes: 1 addition & 1 deletion tests/Stoner/folders/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_metadata_slice():
pass
for k, typ in zip(
["Info.Sample_Holder", ("Info.Sample_Holder", "Datatype,Comment")],
[(np.ndarray, np.str), (np.ndarray, np.ndarray)],
[(np.ndarray, str), (np.ndarray, np.ndarray)],
):
ret = fldr6.metadata[k]
for ix, t in enumerate(typ):
Expand Down

0 comments on commit 510b668

Please sign in to comment.