From 1d8916f5f60b7fdeff2f5755e77ed6a062e41e15 Mon Sep 17 00:00:00 2001 From: Erik Everson Date: Mon, 20 Feb 2023 19:51:58 -0800 Subject: [PATCH] Upate for numpy deprications (#101) --- .github/workflows/linters.yml | 9 +++++---- .github/workflows/tests.yml | 4 ++-- bapsflib/_hdf/maps/controls/tests/fauxsixk.py | 4 ++-- bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py | 2 +- bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py | 8 ++++---- bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py | 2 +- bapsflib/_hdf/utils/hdfreaddata.py | 4 ++-- bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py | 4 ++-- changelog/101.pkg_management.1.rst | 1 + changelog/101.pkg_management.2.rst | 1 + changelog/101.trivial.1.rst | 2 ++ docs/using_lapd/read_from_digi.inc.rst | 2 +- requirements/docs.txt | 2 +- requirements/install.txt | 2 +- setup.cfg | 5 +++-- 15 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 changelog/101.pkg_management.1.rst create mode 100644 changelog/101.pkg_management.2.rst create mode 100644 changelog/101.trivial.1.rst diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 0ab3b7a4..4c7ea957 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -19,19 +19,20 @@ jobs: - name: Install isort run: | python -m pip install -r requirements/extras.txt + python -m pip install colorama - name: Retrieve isort version run: | ISORTVERSION=$(python -c "import isort; print(isort.__version__)") echo "ISORT_VERSION=${ISORTVERSION}" >> $GITHUB_ENV - name: Which isort version - uses: isort/isort-action@master + uses: isort/isort-action@v1.1.0 with: - isortVersion: "${{ env.ISORT_VERSION }}" + isort-version: "${{ env.ISORT_VERSION }}" configuration: "--version" - name: Run isort checks - uses: isort/isort-action@master + uses: isort/isort-action@v1.1.0 with: - isortVersion: "${{ env.ISORT_VERSION }}" + isort-version: "${{ env.ISORT_VERSION }}" configuration: "--check-only --diff --color" black: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 78da0aa3..b1b72d5f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -107,8 +107,8 @@ jobs: min-install: h5py==3.0 python: '3.7' - - spec-name: h5py v3.0 numpy v1.17 - min-install: h5py==3.0 numpy==1.17 + - spec-name: h5py v3.0 numpy v1.20 + min-install: h5py==3.0 numpy==1.20 python: '3.7' steps: diff --git a/bapsflib/_hdf/maps/controls/tests/fauxsixk.py b/bapsflib/_hdf/maps/controls/tests/fauxsixk.py index 9977ed76..f234fe53 100644 --- a/bapsflib/_hdf/maps/controls/tests/fauxsixk.py +++ b/bapsflib/_hdf/maps/controls/tests/fauxsixk.py @@ -341,8 +341,8 @@ def _add_datasets(self): ("z", np.float64), ("theta", np.float64), ("phi", np.float64), - ("Motion list", np.bytes0, 120), - ("Probe name", np.bytes0, 120), + ("Motion list", np.bytes_, 120), + ("Probe name", np.bytes_, 120), ] ) diff --git a/bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py b/bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py index ca5af43a..9acbe9fd 100644 --- a/bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py +++ b/bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py @@ -47,7 +47,7 @@ def active_brdch(self, val): if isinstance(val, np.ndarray): if ( val.shape == (13, 8) - and np.issubdtype(val.dtype, np.bool) + and np.issubdtype(val.dtype, bool) and np.any(val) ): self._faux._active_brdch = val diff --git a/bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py b/bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py index e02106cc..b7826511 100644 --- a/bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py +++ b/bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py @@ -67,11 +67,11 @@ def active_brdch(self, val): # - prevent enabling channels that can't be enabled for # the SIS 3305 mode if self.sis3305_mode == 2: - mask = np.array(2 * [True, False, False, False], dtype=np.bool) + mask = np.array(2 * [True, False, False, False], dtype=bool) elif self.sis3305_mode == 1: - mask = np.array(2 * [True, False, True, False], dtype=np.bool) + mask = np.array(2 * [True, False, True, False], dtype=bool) else: - mask = np.ones(8, dtype=np.bool) + mask = np.ones(8, dtype=bool) mask = np.logical_not(mask) mask = mask.reshape(1, 8) mask = np.append(mask, mask, axis=0) @@ -495,7 +495,7 @@ def _default_setup(self): self._sn_size = 100 self._nt = 10000 self._active_brdch = np.zeros( - (), dtype=[("SIS 3302", np.bool, (4, 8)), ("SIS 3305", np.bool, (2, 8))] + (), dtype=[("SIS 3302", bool, (4, 8)), ("SIS 3305", bool, (2, 8))] ) self._active_brdch["SIS 3302"][0][0] = True self._active_brdch["SIS 3305"][0][0] = True diff --git a/bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py b/bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py index bd9d1315..10ea8829 100644 --- a/bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py +++ b/bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py @@ -46,7 +46,7 @@ def tearDownClass(cls): @property def group(self) -> h5py.Group: - """Data group holding digitizer gorups.""" + """Data group holding digitizer groups.""" return self.f[self.DIGI_ROOT] @property diff --git a/bapsflib/_hdf/utils/hdfreaddata.py b/bapsflib/_hdf/utils/hdfreaddata.py index 887757ad..02f524e4 100644 --- a/bapsflib/_hdf/utils/hdfreaddata.py +++ b/bapsflib/_hdf/utils/hdfreaddata.py @@ -57,7 +57,7 @@ class HDFReadData(np.ndarray): .. note:: - * Evey returned numpy array will have the :code:`'xyz'` field, + * Every returned numpy array will have the :code:`'xyz'` field, which is reserved for probe position data. If a control device specifies this field, then field will be filled with the control device data;otherwise, the field will be filled @@ -362,7 +362,7 @@ def __new__( shotnum = dheader[index.tolist(), shotnumkey] # define sni - sni = np.ones(shotnum.shape[0], dtype=np.bool) + sni = np.ones(shotnum.shape[0], dtype=bool) # print execution timing if timeit: # pragma: no cover diff --git a/bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py b/bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py index d23f0dde..ea01f0e6 100644 --- a/bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py +++ b/bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py @@ -305,7 +305,7 @@ def test_nan_fill(self, _bf: File, mock_controls): ("bits", np.uint32), ("signal", np.float32), ("command", np.bytes_, 10), - ("valid", np.bool), + ("valid", bool), ], ) data["Shot number"] = np.arange(1, 11, 1, dtype=np.uint32) @@ -372,7 +372,7 @@ def _build_configs(self): "dset paths": dset_paths, "dset field": ("valid",), "shape": (), - "dtype": np.bool, + "dtype": bool, }, }, } diff --git a/changelog/101.pkg_management.1.rst b/changelog/101.pkg_management.1.rst new file mode 100644 index 00000000..2716bdec --- /dev/null +++ b/changelog/101.pkg_management.1.rst @@ -0,0 +1 @@ +Updated `numpy` dependency to ``>=1.20``. diff --git a/changelog/101.pkg_management.2.rst b/changelog/101.pkg_management.2.rst new file mode 100644 index 00000000..3b994511 --- /dev/null +++ b/changelog/101.pkg_management.2.rst @@ -0,0 +1 @@ +Fixed `towncrier` dependency to `towncrier==22.8.0`. diff --git a/changelog/101.trivial.1.rst b/changelog/101.trivial.1.rst new file mode 100644 index 00000000..9c7920ea --- /dev/null +++ b/changelog/101.trivial.1.rst @@ -0,0 +1,2 @@ +Replaced several instances of `numpy` deprecated functionality: `numpy.bool` to +`bool` and `numpy.bytes0` to `numpy.bytes_`. diff --git a/docs/using_lapd/read_from_digi.inc.rst b/docs/using_lapd/read_from_digi.inc.rst index f3707efc..7a7929fa 100644 --- a/docs/using_lapd/read_from_digi.inc.rst +++ b/docs/using_lapd/read_from_digi.inc.rst @@ -326,7 +326,7 @@ fields. configuration. The configuration has be unique to a block of recorded data. For the :code:`'6K Compumotor'` the receptacle number is used as the configuration name, whereas, for the - :code:`'Waveform'` control the confiugration name is the name of the + :code:`'Waveform'` control the configuration name is the name of the configuration group inside the :code:`'Waveform` group. Since the configurations are contain in the :code:`f.file_map.contorols[con_name].configs` dictionary, the diff --git a/requirements/docs.txt b/requirements/docs.txt index c49ab3b0..be9d52dd 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -7,4 +7,4 @@ sphinx-automodapi >= 0.13 sphinx-changelog sphinx-gallery sphinx_rtd_theme -towncrier >= 19.2.0 +towncrier == 22.8.0 diff --git a/requirements/install.txt b/requirements/install.txt index bed445cc..265cf2ec 100644 --- a/requirements/install.txt +++ b/requirements/install.txt @@ -3,5 +3,5 @@ -r build.txt astropy >= 4.3.1 h5py >= 3.0 -numpy >= 1.17 +numpy >= 1.20 scipy >= 0.19 diff --git a/setup.cfg b/setup.cfg index f80a0e4f..1dc95bd2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = # ought to mirror requirements/install.txt astropy >= 4.3.1 h5py >= 3.0 - numpy >= 1.17 + numpy >= 1.20 scipy >= 0.19 [options.extras_require] @@ -70,7 +70,7 @@ docs = sphinx-changelog sphinx-gallery sphinx_rtd_theme - towncrier >= 19.2.0 + towncrier == 22.8.0 developer = # install everything for developers %(docs)s @@ -81,3 +81,4 @@ developer = skip = *.png,*cache*,*egg*,.git,.hypothesis,.idea,.tox,_build,venv ignore-words-list = crate, + oce,