Skip to content

Commit

Permalink
Upate for numpy deprications (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
rocco8773 authored Feb 21, 2023
1 parent b8fe2c8 commit 1d8916f
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 23 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions bapsflib/_hdf/maps/controls/tests/fauxsixk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
]
)

Expand Down
2 changes: 1 addition & 1 deletion bapsflib/_hdf/maps/digitizers/tests/fauxsis3301.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions bapsflib/_hdf/maps/digitizers/tests/fauxsiscrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bapsflib/_hdf/maps/digitizers/tests/test_map_digis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bapsflib/_hdf/utils/hdfreaddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bapsflib/_hdf/utils/tests/test_hdfreadcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -372,7 +372,7 @@ def _build_configs(self):
"dset paths": dset_paths,
"dset field": ("valid",),
"shape": (),
"dtype": np.bool,
"dtype": bool,
},
},
}
Expand Down
1 change: 1 addition & 0 deletions changelog/101.pkg_management.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated `numpy` dependency to ``>=1.20``.
1 change: 1 addition & 0 deletions changelog/101.pkg_management.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed `towncrier` dependency to `towncrier==22.8.0`.
2 changes: 2 additions & 0 deletions changelog/101.trivial.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Replaced several instances of `numpy` deprecated functionality: `numpy.bool` to
`bool` and `numpy.bytes0` to `numpy.bytes_`.
2 changes: 1 addition & 1 deletion docs/using_lapd/read_from_digi.inc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sphinx-automodapi >= 0.13
sphinx-changelog
sphinx-gallery
sphinx_rtd_theme
towncrier >= 19.2.0
towncrier == 22.8.0
2 changes: 1 addition & 1 deletion requirements/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
-r build.txt
astropy >= 4.3.1
h5py >= 3.0
numpy >= 1.17
numpy >= 1.20
scipy >= 0.19
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand All @@ -81,3 +81,4 @@ developer =
skip = *.png,*cache*,*egg*,.git,.hypothesis,.idea,.tox,_build,venv
ignore-words-list =
crate,
oce,

0 comments on commit 1d8916f

Please sign in to comment.