Skip to content

Commit

Permalink
Merge pull request #56 from neutrons/numpy_v2
Browse files Browse the repository at this point in the history
Update to numpy v2
  • Loading branch information
Kvieta1990 authored Nov 18, 2024
2 parents 768aad2 + 067e8df commit 7b5492d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 21 deletions.
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,14 @@ Using tox for all stages of testing (all python versions and linting), just run:
NOTE: You must have the version of python installed to run a test suite against that version via tox.
Recommended way to install python versions is `pyenv`

### Linting
[Flake8](https://flake8.pycqa.org/en/latest/) is used for style guide enforcement (i.e. linting):

From the parent directory of the module, run:

`flake8 .`

Using pipenv and flake8:
`pipenv run flake8 .`

Using tox
`tox -e lint`

Using pipenv and tox:
`pipenv run tox -e lint`
### Formatting and Static analysis
[pre-commit](https://pre-commit.com/) is used for style enforcement and static analysis.
To install, after creating the environment run
```sh
pre-commit install
```
and it will run for every commit.
```sh
pre-commit run --all
```
will run it without committing.
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 7b5492d

Please sign in to comment.