Skip to content

Commit

Permalink
Merge pull request #430 from hiddenSymmetries/numpytypes
Browse files Browse the repository at this point in the history
Numpy type hinting
  • Loading branch information
mbkumar authored Jun 25, 2024
2 parents 87dd0cc + 9dd34c5 commit d824abb
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-11]
platform: [ubuntu-latest, macos-12]
python-version: ["3.9"]

runs-on: ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/extensive_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
pip install wheel "numpy<2.0.0" scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
- name: Install booz_xform
if: contains(matrix.packages, 'vmec') || contains(matrix.packages, 'all')
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/non_simd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
pip install wheel "numpy<2.0.0" scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz ground bentley_ottmann
- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install numpy cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec pyoculus h5py ground bentley_ottmann
pip install "numpy<2.0.0" cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec pyoculus h5py ground bentley_ottmann
- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-11, ubuntu-20.04]
os: [macos-12, ubuntu-20.04]

steps:
- uses: actions/checkout@v4
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ keywords = [
"magnetostatics"
]
dependencies = [
"numpy>=1.21",
"numpy>=1.21,<2.0.0",
"jax>=0.2.5",
"jaxlib>=0.1.56",
"scipy>=1.5.4",
"Deprecated>=1.2.10",
"nptyping>=1.3.0",
"monty>=2021.6.10",
"ruamel.yaml",
"sympy",
Expand Down
11 changes: 6 additions & 5 deletions src/simsopt/_core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
This module contains small utility functions and classes.
"""

from typing import Union, Sequence, Any
from typing import Union, Sequence # , Any
from numbers import Integral, Real

from nptyping import NDArray, Float, Int, Bool
import numpy as np
from numpy.typing import NDArray

RealArray = Union[Sequence[Real], NDArray[Any, Float]]
IntArray = Union[Sequence[Integral], NDArray[Any, Int]]
RealArray = Union[Sequence[Real], NDArray[np.double]]
IntArray = Union[Sequence[Integral], NDArray[np.int_]]
StrArray = Sequence[str]
BoolArray = Union[Sequence[bool], NDArray[Any, Bool]]
BoolArray = Union[Sequence[bool], NDArray[bool]]
Key = Union[Integral, str]

8 changes: 3 additions & 5 deletions src/simsopt/geo/surfaceobjectives.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from typing import Any

import numpy as np
from nptyping import NDArray, Float

import simsoptpp as sopp
from .._core.optimizable import Optimizable
from .._core.derivative import Derivative, derivative_dec
from .._core.types import RealArray
from .surface import Surface
from .surfacexyztensorfourier import SurfaceXYZTensorFourier
from ..objectives.utilities import forward_backward
Expand Down Expand Up @@ -517,8 +515,8 @@ def boozer_surface_residual(surface, iota, G, biotsavart, derivatives=0, weight_


def parameter_derivatives(surface: Surface,
shape_gradient: NDArray[Any, Float]
) -> NDArray[Any, Float]:
shape_gradient: RealArray
) -> RealArray:
r"""
Converts the shape gradient of a given figure of merit, :math:`f`,
to derivatives with respect to parameters defining a surface. For
Expand Down

0 comments on commit d824abb

Please sign in to comment.