Skip to content

Commit

Permalink
Update to numpy v2
Browse files Browse the repository at this point in the history
This also turns on ruff rules for numpy checks
  • Loading branch information
peterfpeterson committed Nov 15, 2024
1 parent 768aad2 commit 602aa43
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ requirements:
build:
- setuptools
- versioningit
- numpy
- numpy=2
- h5py
run:
- python
- numpy
- numpy=2
- h5py

test:
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ channels:
- conda-forge
dependencies:
- h5py
- numpy=1 # for now
- numpy=2
- pre-commit
- pytest
- pytest-cov
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ markers = [
[tool.ruff]
line-length = 120
# https://beta.ruff.rs/docs/rules/
lint.select = ["A", "ARG","ASYNC","BLE","C90", "E", "F", "I", "N", "UP032", "W"]
lint.select = ["A", "ARG","ASYNC","BLE","C90", "E", "F", "I", "N", "UP032", "W", "NPY"]
lint.ignore = [ "N802", "N806", # function should be lowercase
"N816" # Variable in global scope should not be mixedCase
]
Expand Down
2 changes: 1 addition & 1 deletion src/pystog/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def fourier_transform(self, xin, yin, xout, xmin=None, xmax=None, dy_in=None, **
for i, x in enumerate(xout):
kernel = factor * yin * np.sin(xin * x)
ekernel = np.square(factor * err * np.sin(xin * x))
yout[i] = np.trapz(kernel, x=xin)
yout[i] = np.trapezoid(kernel, x=xin)
eout[i] = np.sqrt((np.diff(xin) ** 2 * (ekernel[1:] + ekernel[:-1]) / 2).sum())

if kwargs.get("OmittedXrangeCorrection", False):
Expand Down
3 changes: 2 additions & 1 deletion tests/test_stog.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ def test_stog_real_space_function_exception(self):
class TestStogStorageArrays(TestStogBase):
def setUp(self):
super(TestStogStorageArrays, self).setUp()
self.target = np.random.randn(3, 10)
randn = np.random.default_rng()
self.target = randn.random(size=(3, 10))

def test_stog_reciprocal_individuals_setter(self):
stog = StoG()
Expand Down

0 comments on commit 602aa43

Please sign in to comment.