cfsem 3.0.1__tar.gz → 3.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {cfsem-3.0.1 → cfsem-3.0.2}/.github/workflows/test_python.yml +1 -2
  2. {cfsem-3.0.1 → cfsem-3.0.2}/CHANGELOG.md +6 -0
  3. {cfsem-3.0.1 → cfsem-3.0.2}/Cargo.lock +1 -1
  4. {cfsem-3.0.1 → cfsem-3.0.2}/Cargo.toml +1 -1
  5. {cfsem-3.0.1 → cfsem-3.0.2}/PKG-INFO +1 -11
  6. {cfsem-3.0.1 → cfsem-3.0.2}/README.md +2 -3
  7. {cfsem-3.0.1 → cfsem-3.0.2}/pyproject.toml +2 -2
  8. {cfsem-3.0.1 → cfsem-3.0.2}/src/python.rs +164 -194
  9. {cfsem-3.0.1 → cfsem-3.0.2}/uv.lock +15 -12
  10. {cfsem-3.0.1 → cfsem-3.0.2}/.cargo/config.toml +0 -0
  11. {cfsem-3.0.1 → cfsem-3.0.2}/.github/workflows/release_python.yml +0 -0
  12. {cfsem-3.0.1 → cfsem-3.0.2}/.github/workflows/release_rust.yml +0 -0
  13. {cfsem-3.0.1 → cfsem-3.0.2}/.github/workflows/test_rust.yml +0 -0
  14. {cfsem-3.0.1 → cfsem-3.0.2}/.gitignore +0 -0
  15. {cfsem-3.0.1 → cfsem-3.0.2}/.readthedocs.yml +0 -0
  16. {cfsem-3.0.1 → cfsem-3.0.2}/CHANGELOG_PYTHON_ARCHIVE.md +0 -0
  17. {cfsem-3.0.1 → cfsem-3.0.2}/CHANGELOG_RUST_ARCHIVE.md +0 -0
  18. {cfsem-3.0.1 → cfsem-3.0.2}/CONTRIBUTING.md +0 -0
  19. {cfsem-3.0.1 → cfsem-3.0.2}/LICENSE +0 -0
  20. {cfsem-3.0.1 → cfsem-3.0.2}/benches/circular_filament.rs +0 -0
  21. {cfsem-3.0.1 → cfsem-3.0.2}/benches/linear_filament.rs +0 -0
  22. {cfsem-3.0.1 → cfsem-3.0.2}/benches/point_source.rs +0 -0
  23. {cfsem-3.0.1 → cfsem-3.0.2}/build_docs.sh +0 -0
  24. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/__init__.py +0 -0
  25. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/bindings.py +0 -0
  26. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/py.typed +0 -0
  27. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/solenoid_stress/__init__.py +0 -0
  28. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/solenoid_stress/solenoid_1d.py +0 -0
  29. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/solenoid_stress/solenoid_handcalc.py +0 -0
  30. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/solenoid_stress/thick_wall_cylinder_handcalc.py +0 -0
  31. {cfsem-3.0.1 → cfsem-3.0.2}/cfsem/types.py +0 -0
  32. {cfsem-3.0.1 → cfsem-3.0.2}/docs/assets/logo.svg +0 -0
  33. {cfsem-3.0.1 → cfsem-3.0.2}/docs/index.md +0 -0
  34. {cfsem-3.0.1 → cfsem-3.0.2}/docs/javascripts/mathjax.js +0 -0
  35. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/example_outputs/.placeholder +0 -0
  36. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/examples.md +0 -0
  37. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/filament.md +0 -0
  38. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/flux_density.md +0 -0
  39. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/force.md +0 -0
  40. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/grad_shafranov.md +0 -0
  41. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/inductance.md +0 -0
  42. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/math.md +0 -0
  43. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/solenoid_stress.md +0 -0
  44. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/types.md +0 -0
  45. {cfsem-3.0.1 → cfsem-3.0.2}/docs/python/vector_potential.md +0 -0
  46. {cfsem-3.0.1 → cfsem-3.0.2}/docs/requirements.txt +0 -0
  47. {cfsem-3.0.1 → cfsem-3.0.2}/docs/stylesheets/extra.css +0 -0
  48. {cfsem-3.0.1 → cfsem-3.0.2}/examples/helmholtz.py +0 -0
  49. {cfsem-3.0.1 → cfsem-3.0.2}/examples/inductance.py +0 -0
  50. {cfsem-3.0.1 → cfsem-3.0.2}/katex-header.html +0 -0
  51. {cfsem-3.0.1 → cfsem-3.0.2}/mkdocs.yml +0 -0
  52. {cfsem-3.0.1 → cfsem-3.0.2}/src/lib.rs +0 -0
  53. {cfsem-3.0.1 → cfsem-3.0.2}/src/math.rs +0 -0
  54. {cfsem-3.0.1 → cfsem-3.0.2}/src/mesh.rs +0 -0
  55. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/biotsavart.rs +0 -0
  56. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/circular_filament.rs +0 -0
  57. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/gradshafranov.rs +0 -0
  58. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/linear_filament.rs +0 -0
  59. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/mesh_filament.rs +0 -0
  60. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/mod.rs +0 -0
  61. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/point_source.rs +0 -0
  62. {cfsem-3.0.1 → cfsem-3.0.2}/src/physics/volumetric.rs +0 -0
  63. {cfsem-3.0.1 → cfsem-3.0.2}/src/testing.rs +0 -0
  64. {cfsem-3.0.1 → cfsem-3.0.2}/test/__init__.py +0 -0
  65. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_electromagnetics.py +0 -0
  66. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_examples.py +0 -0
  67. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_filaments.py +0 -0
  68. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_funcs.py +0 -0
  69. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_gradshafranov.py +0 -0
  70. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_math.py +0 -0
  71. {cfsem-3.0.1 → cfsem-3.0.2}/test/test_solenoid_stress.py +0 -0
@@ -40,8 +40,7 @@ jobs:
40
40
  source .venv/bin/activate
41
41
 
42
42
  uv pip install maturin
43
- # uv run --locked maturin develop --features=python
44
- uv pip install .[dev]
43
+ uv pip install . --group dev
45
44
 
46
45
  # Python lint, test, and coverage
47
46
  uv run --locked ruff check ./cfsem
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.0.2 2025-11-05
4
+
5
+ ### Changed
6
+
7
+ * Use numpy borrow interface instead of manually borrowchecking numpy arrays
8
+
3
9
  ## 3.0.1 2025-11-05
4
10
 
5
11
  ### Changed
@@ -64,7 +64,7 @@ checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268"
64
64
 
65
65
  [[package]]
66
66
  name = "cfsem"
67
- version = "3.0.1"
67
+ version = "3.0.2"
68
68
  dependencies = [
69
69
  "criterion",
70
70
  "itertools 0.14.0",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "cfsem"
3
- version = "3.0.1"
3
+ version = "3.0.2"
4
4
  edition = "2024"
5
5
  authors = ["Commonwealth Fusion Systems <jlogan@cfs.energy>"]
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cfsem
3
- Version: 3.0.1
3
+ Version: 3.0.2
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -9,16 +9,6 @@ Requires-Dist: interpn[pydantic]>=0.7
9
9
  Requires-Dist: findiff>=0.12.1
10
10
  Requires-Dist: pydantic>=2
11
11
  Requires-Dist: pydantic-numpy>=6
12
- Requires-Dist: pytest>=7.1.3 ; extra == 'dev'
13
- Requires-Dist: coverage>=6.5.0 ; extra == 'dev'
14
- Requires-Dist: ruff>=0.6.2 ; extra == 'dev'
15
- Requires-Dist: pyright==1.1.402 ; extra == 'dev'
16
- Requires-Dist: scipy>=1.8 ; extra == 'dev'
17
- Requires-Dist: mkdocs>=1.6.0 ; extra == 'dev'
18
- Requires-Dist: mkdocs-material>=9.5.25 ; extra == 'dev'
19
- Requires-Dist: mkdocstrings[python]>=0.25.1 ; extra == 'dev'
20
- Requires-Dist: matplotlib>=3.9 ; extra == 'dev'
21
- Provides-Extra: dev
22
12
  License-File: LICENSE
23
13
  Summary: Quasi-steady electromagnetics including filamentized approximations, Biot-Savart, and Grad-Shafranov.
24
14
  Home-Page: https://github.com/cfs-energy/cfsem-py
@@ -45,7 +45,7 @@ Requirements
45
45
  To install in the active python environment, do
46
46
 
47
47
  ```bash
48
- uv pip install -e .[dev]
48
+ uv pip install -e . --group dev
49
49
  ```
50
50
 
51
51
  To build the Rust bindings only, do
@@ -61,8 +61,7 @@ Some computationally-expensive calculations are written in Rust. These calculati
61
61
  To build with all of the optimizations available on your local machine, you can do:
62
62
 
63
63
  ```bash
64
- RUSTCFLAGS="-Ctarget-cpu=native" maturin develop --release --features=python
65
- pip install -e .[dev]
64
+ RUSTCFLAGS="-Ctarget-cpu=native" pip install -e . --group dev --reinstall
66
65
  ```
67
66
 
68
67
  ## Contributing
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "cfsem"
7
- version = "3.0.1"
7
+ version = "3.0.2"
8
8
  description = "Quasi-steady electromagnetics including filamentized approximations, Biot-Savart, and Grad-Shafranov."
9
9
  authors = [{name = "Commonwealth Fusion Systems", email = "jlogan@cfs.energy"}]
10
10
  requires-python = ">=3.10, <3.14"
@@ -22,7 +22,7 @@ dependencies = [
22
22
  ]
23
23
  license = "MIT"
24
24
 
25
- [project.optional-dependencies]
25
+ [dependency-groups]
26
26
  dev = [
27
27
  # Tests
28
28
  "pytest >= 7.1.3",
@@ -1,5 +1,5 @@
1
1
  use numpy::PyArray1;
2
- use numpy::PyArrayMethods;
2
+ use numpy::borrow::{PyReadonlyArray1, PyReadwriteArray1};
3
3
  use pyo3::exceptions;
4
4
  use pyo3::prelude::*;
5
5
  use std::fmt::Debug;
@@ -20,19 +20,19 @@ impl From<PyInteropError> for PyErr {
20
20
  }
21
21
 
22
22
  #[pyfunction]
23
- fn filament_helix_path<'py>(
23
+ fn filament_helix_path(
24
24
  path: (
25
- Bound<'py, PyArray1<f64>>,
26
- Bound<'py, PyArray1<f64>>,
27
- Bound<'py, PyArray1<f64>>,
25
+ PyReadonlyArray1<f64>,
26
+ PyReadonlyArray1<f64>,
27
+ PyReadonlyArray1<f64>,
28
28
  ), // [m]
29
29
  helix_start_offset: (f64, f64, f64),
30
30
  twist_pitch: f64,
31
31
  angle_offset: f64,
32
- out: (
33
- Bound<'py, PyArray1<f64>>,
34
- Bound<'py, PyArray1<f64>>,
35
- Bound<'py, PyArray1<f64>>,
32
+ mut out: (
33
+ PyReadwriteArray1<f64>,
34
+ PyReadwriteArray1<f64>,
35
+ PyReadwriteArray1<f64>,
36
36
  ),
37
37
  ) -> PyResult<()> {
38
38
  // Unpack
@@ -52,17 +52,17 @@ fn filament_helix_path<'py>(
52
52
  }
53
53
 
54
54
  #[pyfunction]
55
- fn rotate_filaments_about_path<'py>(
55
+ fn rotate_filaments_about_path(
56
56
  path: (
57
- Bound<'py, PyArray1<f64>>,
58
- Bound<'py, PyArray1<f64>>,
59
- Bound<'py, PyArray1<f64>>,
57
+ PyReadonlyArray1<f64>,
58
+ PyReadonlyArray1<f64>,
59
+ PyReadonlyArray1<f64>,
60
60
  ), // [m]
61
61
  angle_offset: f64,
62
- out: (
63
- Bound<'py, PyArray1<f64>>,
64
- Bound<'py, PyArray1<f64>>,
65
- Bound<'py, PyArray1<f64>>,
62
+ mut out: (
63
+ PyReadwriteArray1<f64>,
64
+ PyReadwriteArray1<f64>,
65
+ PyReadwriteArray1<f64>,
66
66
  ),
67
67
  ) -> PyResult<()> {
68
68
  // Unpack
@@ -83,12 +83,12 @@ fn rotate_filaments_about_path<'py>(
83
83
 
84
84
  /// Python bindings for cfsemrs::physics::flux_circular_filament
85
85
  #[pyfunction]
86
- fn flux_circular_filament<'py>(
87
- current: Bound<'py, PyArray1<f64>>,
88
- rfil: Bound<'py, PyArray1<f64>>,
89
- zfil: Bound<'py, PyArray1<f64>>,
90
- rprime: Bound<'py, PyArray1<f64>>,
91
- zprime: Bound<'py, PyArray1<f64>>,
86
+ fn flux_circular_filament(
87
+ current: PyReadonlyArray1<f64>,
88
+ rfil: PyReadonlyArray1<f64>,
89
+ zfil: PyReadonlyArray1<f64>,
90
+ rprime: PyReadonlyArray1<f64>,
91
+ zprime: PyReadonlyArray1<f64>,
92
92
  par: bool,
93
93
  ) -> PyResult<Py<PyArray1<f64>>> {
94
94
  // Get references to contiguous data as slice
@@ -117,19 +117,19 @@ fn flux_circular_filament<'py>(
117
117
  }
118
118
 
119
119
  // Acquire global interpreter lock, which will be released when it goes out of scope
120
- Python::with_gil(|py| {
120
+ Python::attach(|py| {
121
121
  Ok(PyArray1::from_vec(py, psi).unbind()) // Make PyObject
122
122
  })
123
123
  }
124
124
 
125
125
  /// Python bindings for cfsemrs::physics::circular_filament::vector_potential_circular_filament
126
126
  #[pyfunction]
127
- fn vector_potential_circular_filament<'py>(
128
- current: Bound<'py, PyArray1<f64>>,
129
- rfil: Bound<'py, PyArray1<f64>>,
130
- zfil: Bound<'py, PyArray1<f64>>,
131
- rprime: Bound<'py, PyArray1<f64>>,
132
- zprime: Bound<'py, PyArray1<f64>>,
127
+ fn vector_potential_circular_filament(
128
+ current: PyReadonlyArray1<f64>,
129
+ rfil: PyReadonlyArray1<f64>,
130
+ zfil: PyReadonlyArray1<f64>,
131
+ rprime: PyReadonlyArray1<f64>,
132
+ zprime: PyReadonlyArray1<f64>,
133
133
  par: bool,
134
134
  ) -> PyResult<Py<PyArray1<f64>>> {
135
135
  // Get references to contiguous data as slice
@@ -158,19 +158,19 @@ fn vector_potential_circular_filament<'py>(
158
158
  }
159
159
 
160
160
  // Acquire global interpreter lock, which will be released when it goes out of scope
161
- Python::with_gil(|py| {
161
+ Python::attach(|py| {
162
162
  Ok(PyArray1::from_vec(py, out).unbind()) // Make PyObject
163
163
  })
164
164
  }
165
165
 
166
166
  /// Python bindings for cfsemrs::physics::flux_density_circular_filament
167
167
  #[pyfunction]
168
- fn flux_density_circular_filament<'py>(
169
- current: Bound<'py, PyArray1<f64>>,
170
- rfil: Bound<'py, PyArray1<f64>>,
171
- zfil: Bound<'py, PyArray1<f64>>,
172
- rprime: Bound<'py, PyArray1<f64>>,
173
- zprime: Bound<'py, PyArray1<f64>>,
168
+ fn flux_density_circular_filament(
169
+ current: PyReadonlyArray1<f64>,
170
+ rfil: PyReadonlyArray1<f64>,
171
+ zfil: PyReadonlyArray1<f64>,
172
+ rprime: PyReadonlyArray1<f64>,
173
+ zprime: PyReadonlyArray1<f64>,
174
174
  par: bool,
175
175
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
176
176
  // Get references to contiguous data as slice
@@ -200,7 +200,7 @@ fn flux_density_circular_filament<'py>(
200
200
  }
201
201
 
202
202
  // Acquire global interpreter lock, which will be released when it goes out of scope
203
- Python::with_gil(|py| {
203
+ Python::attach(|py| {
204
204
  let br: Py<PyArray1<f64>> = PyArray1::from_slice(py, &br).unbind(); // Make PyObject
205
205
  let bz: Py<PyArray1<f64>> = PyArray1::from_slice(py, &bz).unbind(); // Make PyObject
206
206
 
@@ -210,23 +210,23 @@ fn flux_density_circular_filament<'py>(
210
210
 
211
211
  /// Python bindings for cfsemrs::physics::linear_filament::flux_density_linear_filament
212
212
  #[pyfunction]
213
- fn flux_density_linear_filament<'py>(
213
+ fn flux_density_linear_filament(
214
214
  xyzp: (
215
- Bound<'py, PyArray1<f64>>,
216
- Bound<'py, PyArray1<f64>>,
217
- Bound<'py, PyArray1<f64>>,
215
+ PyReadonlyArray1<f64>,
216
+ PyReadonlyArray1<f64>,
217
+ PyReadonlyArray1<f64>,
218
218
  ), // [m] Test point coords
219
219
  xyzfil: (
220
- Bound<'py, PyArray1<f64>>,
221
- Bound<'py, PyArray1<f64>>,
222
- Bound<'py, PyArray1<f64>>,
220
+ PyReadonlyArray1<f64>,
221
+ PyReadonlyArray1<f64>,
222
+ PyReadonlyArray1<f64>,
223
223
  ), // [m] Filament origin coords (start of segment)
224
224
  dlxyzfil: (
225
- Bound<'py, PyArray1<f64>>,
226
- Bound<'py, PyArray1<f64>>,
227
- Bound<'py, PyArray1<f64>>,
225
+ PyReadonlyArray1<f64>,
226
+ PyReadonlyArray1<f64>,
227
+ PyReadonlyArray1<f64>,
228
228
  ), // [m] Filament length delta
229
- ifil: Bound<'py, PyArray1<f64>>, // [A] filament current
229
+ ifil: PyReadonlyArray1<f64>, // [A] filament current
230
230
  par: bool,
231
231
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
232
232
  // Get references to contiguous data as slice
@@ -234,8 +234,7 @@ fn flux_density_linear_filament<'py>(
234
234
  _3tup_slice_ro!(xyzp);
235
235
  _3tup_slice_ro!(xyzfil);
236
236
  _3tup_slice_ro!(dlxyzfil);
237
- let ifilro = ifil.readonly();
238
- let ifil = ifilro.as_slice()?;
237
+ let ifil = ifil.as_slice()?;
239
238
 
240
239
  // Do calculations
241
240
  let n = xyzp.0.len();
@@ -258,23 +257,23 @@ fn flux_density_linear_filament<'py>(
258
257
 
259
258
  /// Python bindings for cfsemrs::physics::linear_filament::vector_potential_linear_filament
260
259
  #[pyfunction]
261
- fn vector_potential_linear_filament<'py>(
260
+ fn vector_potential_linear_filament(
262
261
  xyzp: (
263
- Bound<'py, PyArray1<f64>>,
264
- Bound<'py, PyArray1<f64>>,
265
- Bound<'py, PyArray1<f64>>,
262
+ PyReadonlyArray1<f64>,
263
+ PyReadonlyArray1<f64>,
264
+ PyReadonlyArray1<f64>,
266
265
  ), // [m] Test point coords
267
266
  xyzfil: (
268
- Bound<'py, PyArray1<f64>>,
269
- Bound<'py, PyArray1<f64>>,
270
- Bound<'py, PyArray1<f64>>,
267
+ PyReadonlyArray1<f64>,
268
+ PyReadonlyArray1<f64>,
269
+ PyReadonlyArray1<f64>,
271
270
  ), // [m] Filament origin coords (start of segment)
272
271
  dlxyzfil: (
273
- Bound<'py, PyArray1<f64>>,
274
- Bound<'py, PyArray1<f64>>,
275
- Bound<'py, PyArray1<f64>>,
272
+ PyReadonlyArray1<f64>,
273
+ PyReadonlyArray1<f64>,
274
+ PyReadonlyArray1<f64>,
276
275
  ), // [m] Filament length delta
277
- ifil: Bound<'py, PyArray1<f64>>, // [A] filament current
276
+ ifil: PyReadonlyArray1<f64>, // [A] filament current
278
277
  par: bool,
279
278
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
280
279
  // Get references to contiguous data as slice
@@ -282,9 +281,7 @@ fn vector_potential_linear_filament<'py>(
282
281
  _3tup_slice_ro!(xyzp);
283
282
  _3tup_slice_ro!(xyzfil);
284
283
  _3tup_slice_ro!(dlxyzfil);
285
-
286
- let ifilro = ifil.readonly();
287
- let ifil = ifilro.as_slice()?;
284
+ let ifil = ifil.as_slice()?;
288
285
 
289
286
  // Do calculations
290
287
  let n = xyzp.0.len();
@@ -312,26 +309,26 @@ fn vector_potential_linear_filament<'py>(
312
309
  }
313
310
 
314
311
  #[pyfunction]
315
- fn inductance_piecewise_linear_filaments<'py>(
312
+ fn inductance_piecewise_linear_filaments(
316
313
  xyzfil0: (
317
- Bound<'py, PyArray1<f64>>,
318
- Bound<'py, PyArray1<f64>>,
319
- Bound<'py, PyArray1<f64>>,
314
+ PyReadonlyArray1<f64>,
315
+ PyReadonlyArray1<f64>,
316
+ PyReadonlyArray1<f64>,
320
317
  ), // [m] Filament origin coords (start of segment)
321
318
  dlxyzfil0: (
322
- Bound<'py, PyArray1<f64>>,
323
- Bound<'py, PyArray1<f64>>,
324
- Bound<'py, PyArray1<f64>>,
319
+ PyReadonlyArray1<f64>,
320
+ PyReadonlyArray1<f64>,
321
+ PyReadonlyArray1<f64>,
325
322
  ), // [m] Filament length delta
326
323
  xyzfil1: (
327
- Bound<'py, PyArray1<f64>>,
328
- Bound<'py, PyArray1<f64>>,
329
- Bound<'py, PyArray1<f64>>,
324
+ PyReadonlyArray1<f64>,
325
+ PyReadonlyArray1<f64>,
326
+ PyReadonlyArray1<f64>,
330
327
  ), // [m] Filament origin coords (start of segment)
331
328
  dlxyzfil1: (
332
- Bound<'py, PyArray1<f64>>,
333
- Bound<'py, PyArray1<f64>>,
334
- Bound<'py, PyArray1<f64>>,
329
+ PyReadonlyArray1<f64>,
330
+ PyReadonlyArray1<f64>,
331
+ PyReadonlyArray1<f64>,
335
332
  ), // [m] Filament length delta
336
333
  self_inductance: bool, // Whether this is being used as a self-inductance calc
337
334
  ) -> PyResult<f64> {
@@ -362,15 +359,13 @@ fn inductance_piecewise_linear_filaments<'py>(
362
359
 
363
360
  /// Python bindings for cfsemrs::physics::gradshafranov::gs_operator_order2
364
361
  #[pyfunction]
365
- fn gs_operator_order2<'py>(
366
- rs: Bound<'py, PyArray1<f64>>,
367
- zs: Bound<'py, PyArray1<f64>>,
362
+ fn gs_operator_order2(
363
+ rs: PyReadonlyArray1<f64>,
364
+ zs: PyReadonlyArray1<f64>,
368
365
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<usize>>, Py<PyArray1<usize>>)> {
369
366
  // Process inputs
370
- let rsro = rs.readonly();
371
- let rs = rsro.as_slice()?;
372
- let zsro = zs.readonly();
373
- let zs = zsro.as_slice()?;
367
+ let rs = rs.as_slice()?;
368
+ let zs = zs.as_slice()?;
374
369
 
375
370
  // Do calculations
376
371
  let (vals, rows, cols) = physics::gradshafranov::gs_operator_order2(rs, zs);
@@ -380,15 +375,13 @@ fn gs_operator_order2<'py>(
380
375
 
381
376
  /// Python bindings for cfsemrs::physics::gradshafranov::gs_operator_order4
382
377
  #[pyfunction]
383
- fn gs_operator_order4<'py>(
384
- rs: Bound<'py, PyArray1<f64>>,
385
- zs: Bound<'py, PyArray1<f64>>,
378
+ fn gs_operator_order4(
379
+ rs: PyReadonlyArray1<f64>,
380
+ zs: PyReadonlyArray1<f64>,
386
381
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<usize>>, Py<PyArray1<usize>>)> {
387
382
  // Process inputs
388
- let rsro = rs.readonly();
389
- let rs = rsro.as_slice()?;
390
- let zsro = zs.readonly();
391
- let zs = zsro.as_slice()?;
383
+ let rs = rs.as_slice()?;
384
+ let zs = zs.as_slice()?;
392
385
 
393
386
  // Do calculations
394
387
  let (vals, rows, cols) = physics::gradshafranov::gs_operator_order4(rs, zs);
@@ -410,14 +403,14 @@ fn ellipk(x: f64) -> f64 {
410
403
 
411
404
  /// Python bindings for cfsemrs::physics::flux_density_circular_filament_cartesian
412
405
  #[pyfunction]
413
- fn flux_density_circular_filament_cartesian<'py>(
414
- current: Bound<'py, PyArray1<f64>>,
415
- rfil: Bound<'py, PyArray1<f64>>,
416
- zfil: Bound<'py, PyArray1<f64>>,
406
+ fn flux_density_circular_filament_cartesian(
407
+ current: PyReadonlyArray1<f64>,
408
+ rfil: PyReadonlyArray1<f64>,
409
+ zfil: PyReadonlyArray1<f64>,
417
410
  xyzobs: (
418
- Bound<'py, PyArray1<f64>>,
419
- Bound<'py, PyArray1<f64>>,
420
- Bound<'py, PyArray1<f64>>,
411
+ PyReadonlyArray1<f64>,
412
+ PyReadonlyArray1<f64>,
413
+ PyReadonlyArray1<f64>,
421
414
  ), // [m] Observation point coords
422
415
  par: bool,
423
416
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
@@ -456,19 +449,19 @@ fn flux_density_circular_filament_cartesian<'py>(
456
449
 
457
450
  /// Python bindings for cfsemrs::physics::mutual_inductance_circular_to_linear
458
451
  #[pyfunction]
459
- fn mutual_inductance_circular_to_linear<'py>(
460
- rfil: Bound<'py, PyArray1<f64>>,
461
- zfil: Bound<'py, PyArray1<f64>>,
462
- nfil: Bound<'py, PyArray1<f64>>,
452
+ fn mutual_inductance_circular_to_linear(
453
+ rfil: PyReadonlyArray1<f64>,
454
+ zfil: PyReadonlyArray1<f64>,
455
+ nfil: PyReadonlyArray1<f64>,
463
456
  xyzfil: (
464
- Bound<'py, PyArray1<f64>>,
465
- Bound<'py, PyArray1<f64>>,
466
- Bound<'py, PyArray1<f64>>,
457
+ PyReadonlyArray1<f64>,
458
+ PyReadonlyArray1<f64>,
459
+ PyReadonlyArray1<f64>,
467
460
  ), // [m] Filament origin coords (start of segment)
468
461
  dlxyzfil: (
469
- Bound<'py, PyArray1<f64>>,
470
- Bound<'py, PyArray1<f64>>,
471
- Bound<'py, PyArray1<f64>>,
462
+ PyReadonlyArray1<f64>,
463
+ PyReadonlyArray1<f64>,
464
+ PyReadonlyArray1<f64>,
472
465
  ), // [m] Filament length delta
473
466
  par: bool,
474
467
  ) -> PyResult<f64> {
@@ -499,23 +492,23 @@ fn mutual_inductance_circular_to_linear<'py>(
499
492
 
500
493
  /// Python bindings for cfsemrs::physics::point_source::flux_density_dipole
501
494
  #[pyfunction]
502
- fn flux_density_dipole<'py>(
495
+ fn flux_density_dipole(
503
496
  loc: (
504
- Bound<'py, PyArray1<f64>>,
505
- Bound<'py, PyArray1<f64>>,
506
- Bound<'py, PyArray1<f64>>,
497
+ PyReadonlyArray1<f64>,
498
+ PyReadonlyArray1<f64>,
499
+ PyReadonlyArray1<f64>,
507
500
  ), // [m] dipole locations in cartesian coordinates
508
501
  moment: (
509
- Bound<'py, PyArray1<f64>>,
510
- Bound<'py, PyArray1<f64>>,
511
- Bound<'py, PyArray1<f64>>,
502
+ PyReadonlyArray1<f64>,
503
+ PyReadonlyArray1<f64>,
504
+ PyReadonlyArray1<f64>,
512
505
  ), // [A-m^2] dipole moment vector
513
506
  obs: (
514
- Bound<'py, PyArray1<f64>>,
515
- Bound<'py, PyArray1<f64>>,
516
- Bound<'py, PyArray1<f64>>,
507
+ PyReadonlyArray1<f64>,
508
+ PyReadonlyArray1<f64>,
509
+ PyReadonlyArray1<f64>,
517
510
  ), // [m] Observation point coords
518
- outer_radius: Bound<'py, PyArray1<f64>>,
511
+ outer_radius: PyReadonlyArray1<f64>,
519
512
  par: bool,
520
513
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
521
514
  // Get references to contiguous data as slice
@@ -535,7 +528,7 @@ fn flux_density_dipole<'py>(
535
528
  match func(
536
529
  loc,
537
530
  moment,
538
- outer_radius.readonly().as_slice()?,
531
+ outer_radius.as_slice()?,
539
532
  obs,
540
533
  (&mut outx, &mut outy, &mut outz),
541
534
  ) {
@@ -551,23 +544,23 @@ fn flux_density_dipole<'py>(
551
544
 
552
545
  /// Python bindings for cfsemrs::physics::point_source::vector_potential_dipole
553
546
  #[pyfunction]
554
- fn vector_potential_dipole<'py>(
547
+ fn vector_potential_dipole(
555
548
  loc: (
556
- Bound<'py, PyArray1<f64>>,
557
- Bound<'py, PyArray1<f64>>,
558
- Bound<'py, PyArray1<f64>>,
549
+ PyReadonlyArray1<f64>,
550
+ PyReadonlyArray1<f64>,
551
+ PyReadonlyArray1<f64>,
559
552
  ), // [m] dipole locations in cartesian coordinates
560
553
  moment: (
561
- Bound<'py, PyArray1<f64>>,
562
- Bound<'py, PyArray1<f64>>,
563
- Bound<'py, PyArray1<f64>>,
554
+ PyReadonlyArray1<f64>,
555
+ PyReadonlyArray1<f64>,
556
+ PyReadonlyArray1<f64>,
564
557
  ), // [A-m^2] dipole moment vector
565
558
  obs: (
566
- Bound<'py, PyArray1<f64>>,
567
- Bound<'py, PyArray1<f64>>,
568
- Bound<'py, PyArray1<f64>>,
559
+ PyReadonlyArray1<f64>,
560
+ PyReadonlyArray1<f64>,
561
+ PyReadonlyArray1<f64>,
569
562
  ), // [m] Observation point coords
570
- outer_radius: Bound<'py, PyArray1<f64>>,
563
+ outer_radius: PyReadonlyArray1<f64>,
571
564
  par: bool,
572
565
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
573
566
  // Get references to contiguous data as slice
@@ -587,7 +580,7 @@ fn vector_potential_dipole<'py>(
587
580
  match func(
588
581
  loc,
589
582
  moment,
590
- outer_radius.readonly().as_slice()?,
583
+ outer_radius.as_slice()?,
591
584
  obs,
592
585
  (&mut outx, &mut outy, &mut outz),
593
586
  ) {
@@ -603,19 +596,19 @@ fn vector_potential_dipole<'py>(
603
596
 
604
597
  /// Python bindings for cfsemrs::physics::body_force_density_circular_filament_cartesian
605
598
  #[pyfunction]
606
- fn body_force_density_circular_filament_cartesian<'py>(
607
- current: Bound<'py, PyArray1<f64>>,
608
- rfil: Bound<'py, PyArray1<f64>>,
609
- zfil: Bound<'py, PyArray1<f64>>,
599
+ fn body_force_density_circular_filament_cartesian(
600
+ current: PyReadonlyArray1<f64>,
601
+ rfil: PyReadonlyArray1<f64>,
602
+ zfil: PyReadonlyArray1<f64>,
610
603
  obs: (
611
- Bound<'py, PyArray1<f64>>,
612
- Bound<'py, PyArray1<f64>>,
613
- Bound<'py, PyArray1<f64>>,
604
+ PyReadonlyArray1<f64>,
605
+ PyReadonlyArray1<f64>,
606
+ PyReadonlyArray1<f64>,
614
607
  ), // [m] Filament origin coords (start of segment)
615
608
  j: (
616
- Bound<'py, PyArray1<f64>>,
617
- Bound<'py, PyArray1<f64>>,
618
- Bound<'py, PyArray1<f64>>,
609
+ PyReadonlyArray1<f64>,
610
+ PyReadonlyArray1<f64>,
611
+ PyReadonlyArray1<f64>,
619
612
  ), // [A/m^2] current density at observation points
620
613
  par: bool,
621
614
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
@@ -651,57 +644,37 @@ fn body_force_density_circular_filament_cartesian<'py>(
651
644
 
652
645
  /// Python bindings for cfsemrs::physics::body_force_density_linear_filament
653
646
  #[pyfunction]
654
- fn body_force_density_linear_filament<'py>(
647
+ fn body_force_density_linear_filament(
655
648
  xyzfil: (
656
- Bound<'py, PyArray1<f64>>,
657
- Bound<'py, PyArray1<f64>>,
658
- Bound<'py, PyArray1<f64>>,
649
+ PyReadonlyArray1<f64>,
650
+ PyReadonlyArray1<f64>,
651
+ PyReadonlyArray1<f64>,
659
652
  ), // [m] Filament origin coords (start of segment)
660
653
  dlxyzfil: (
661
- Bound<'py, PyArray1<f64>>,
662
- Bound<'py, PyArray1<f64>>,
663
- Bound<'py, PyArray1<f64>>,
654
+ PyReadonlyArray1<f64>,
655
+ PyReadonlyArray1<f64>,
656
+ PyReadonlyArray1<f64>,
664
657
  ), // [m] Filament length delta
665
- ifil: Bound<'py, PyArray1<f64>>, // [A] filament current
658
+ ifil: PyReadonlyArray1<f64>, // [A] filament current
666
659
  obs: (
667
- Bound<'py, PyArray1<f64>>,
668
- Bound<'py, PyArray1<f64>>,
669
- Bound<'py, PyArray1<f64>>,
660
+ PyReadonlyArray1<f64>,
661
+ PyReadonlyArray1<f64>,
662
+ PyReadonlyArray1<f64>,
670
663
  ), // [m] Filament origin coords (start of segment)
671
664
  j: (
672
- Bound<'py, PyArray1<f64>>,
673
- Bound<'py, PyArray1<f64>>,
674
- Bound<'py, PyArray1<f64>>,
665
+ PyReadonlyArray1<f64>,
666
+ PyReadonlyArray1<f64>,
667
+ PyReadonlyArray1<f64>,
675
668
  ), // [A/m^2] current density at observation points
676
669
  par: bool,
677
670
  ) -> PyResult<(Py<PyArray1<f64>>, Py<PyArray1<f64>>, Py<PyArray1<f64>>)> {
678
671
  // Get references to contiguous data as slice
679
672
  // or error if data is not contiguous
680
- let xfilro = xyzfil.0.readonly();
681
- let yfilro = xyzfil.1.readonly();
682
- let zfilro = xyzfil.2.readonly();
683
- let xyzfil = (xfilro.as_slice()?, yfilro.as_slice()?, zfilro.as_slice()?);
684
-
685
- let dlxfilro = dlxyzfil.0.readonly();
686
- let dlyfilro = dlxyzfil.1.readonly();
687
- let dlzfilro = dlxyzfil.2.readonly();
688
- let dlxyzfil = (
689
- dlxfilro.as_slice()?,
690
- dlyfilro.as_slice()?,
691
- dlzfilro.as_slice()?,
692
- );
693
- let ifilro = ifil.readonly();
694
- let ifil = ifilro.as_slice()?;
695
-
696
- let obsxro = obs.0.readonly();
697
- let obsyro = obs.1.readonly();
698
- let obszro = obs.2.readonly();
699
- let obs = (obsxro.as_slice()?, obsyro.as_slice()?, obszro.as_slice()?);
700
-
701
- let jxro = j.0.readonly();
702
- let jyro = j.1.readonly();
703
- let jzro = j.2.readonly();
704
- let j = (jxro.as_slice()?, jyro.as_slice()?, jzro.as_slice()?);
673
+ _3tup_slice_ro!(xyzfil);
674
+ _3tup_slice_ro!(dlxyzfil);
675
+ let ifil = ifil.as_slice()?;
676
+ _3tup_slice_ro!(obs);
677
+ _3tup_slice_ro!(j);
705
678
 
706
679
  // Select variant
707
680
  let func = match par {
@@ -785,30 +758,27 @@ fn _cfsem<'py>(_py: Python, m: Bound<'py, PyModule>) -> PyResult<()> {
785
758
  Ok(())
786
759
  }
787
760
 
788
- /// Convert a 3-tuple of PyArray to read-only slices, shadowing the original name
761
+ /// Convert a 3-tuple of PyReadonlyArray to read-only slices, shadowing the original name
789
762
  macro_rules! _3tup_slice_ro {
790
763
  ($x:ident) => {
791
- let _ro = ($x.0.readonly(), $x.1.readonly(), $x.2.readonly());
792
- let $x = (_ro.0.as_slice()?, _ro.1.as_slice()?, _ro.2.as_slice()?);
764
+ let $x = ($x.0.as_slice()?, $x.1.as_slice()?, $x.2.as_slice()?);
793
765
  };
794
766
  }
795
767
 
796
- /// Convert a 2-tuple of PyArray to read-only slices, shadowing the original name
768
+ /// Convert a 2-tuple of PyReadonlyArray to read-only slices, shadowing the original name
797
769
  macro_rules! _2tup_slice_ro {
798
770
  ($x:ident) => {
799
- let _ro = ($x.0.readonly(), $x.1.readonly());
800
- let $x = (_ro.0.as_slice()?, _ro.1.as_slice()?);
771
+ let $x = ($x.0.as_slice()?, $x.1.as_slice()?);
801
772
  };
802
773
  }
803
774
 
804
- /// Convert a 3-tuple of PyArray to read-write slices, shadowing the original name
775
+ /// Convert a 3-tuple of PyReadwriteArray to read-write slices, shadowing the original name
805
776
  macro_rules! _3tup_slice_mut {
806
777
  ($x:ident) => {
807
- let mut _rw = ($x.0.readwrite(), $x.1.readwrite(), $x.2.readwrite());
808
778
  let $x = (
809
- _rw.0.as_slice_mut()?,
810
- _rw.1.as_slice_mut()?,
811
- _rw.2.as_slice_mut()?,
779
+ $x.0.as_slice_mut()?,
780
+ $x.1.as_slice_mut()?,
781
+ $x.2.as_slice_mut()?,
812
782
  );
813
783
  };
814
784
  }
@@ -817,7 +787,7 @@ macro_rules! _3tup_slice_mut {
817
787
  macro_rules! _3tup_ret {
818
788
  (($x:ident, $xt:ty), ($y:ident, $yt:ty), ($z:ident, $zt:ty)) => {
819
789
  // Acquire global interpreter lock, which will be released when it goes out of scope
820
- Python::with_gil(|py| {
790
+ Python::attach(|py| {
821
791
  let $x: Py<PyArray1<$xt>> = PyArray1::from_vec(py, $x).unbind();
822
792
  let $y: Py<PyArray1<$yt>> = PyArray1::from_vec(py, $y).unbind();
823
793
  let $z: Py<PyArray1<$zt>> = PyArray1::from_vec(py, $z).unbind();
@@ -48,7 +48,7 @@ wheels = [
48
48
 
49
49
  [[package]]
50
50
  name = "cfsem"
51
- version = "3.0.1"
51
+ version = "3.0.2"
52
52
  source = { editable = "." }
53
53
  dependencies = [
54
54
  { name = "findiff" },
@@ -59,7 +59,7 @@ dependencies = [
59
59
  { name = "pydantic-numpy" },
60
60
  ]
61
61
 
62
- [package.optional-dependencies]
62
+ [package.dev-dependencies]
63
63
  dev = [
64
64
  { name = "coverage" },
65
65
  { name = "matplotlib" },
@@ -74,22 +74,25 @@ dev = [
74
74
 
75
75
  [package.metadata]
76
76
  requires-dist = [
77
- { name = "coverage", marker = "extra == 'dev'", specifier = ">=6.5.0" },
78
77
  { name = "findiff", specifier = ">=0.12.1" },
79
78
  { name = "interpn", extras = ["pydantic"], specifier = ">=0.7" },
80
- { name = "matplotlib", marker = "extra == 'dev'", specifier = ">=3.9" },
81
- { name = "mkdocs", marker = "extra == 'dev'", specifier = ">=1.6.0" },
82
- { name = "mkdocs-material", marker = "extra == 'dev'", specifier = ">=9.5.25" },
83
- { name = "mkdocstrings", extras = ["python"], marker = "extra == 'dev'", specifier = ">=0.25.1" },
84
79
  { name = "numpy", specifier = ">=2" },
85
80
  { name = "pydantic", specifier = ">=2" },
86
81
  { name = "pydantic-numpy", specifier = ">=6" },
87
- { name = "pyright", marker = "extra == 'dev'", specifier = "==1.1.402" },
88
- { name = "pytest", marker = "extra == 'dev'", specifier = ">=7.1.3" },
89
- { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.6.2" },
90
- { name = "scipy", marker = "extra == 'dev'", specifier = ">=1.8" },
91
82
  ]
92
- provides-extras = ["dev"]
83
+
84
+ [package.metadata.requires-dev]
85
+ dev = [
86
+ { name = "coverage", specifier = ">=6.5.0" },
87
+ { name = "matplotlib", specifier = ">=3.9" },
88
+ { name = "mkdocs", specifier = ">=1.6.0" },
89
+ { name = "mkdocs-material", specifier = ">=9.5.25" },
90
+ { name = "mkdocstrings", extras = ["python"], specifier = ">=0.25.1" },
91
+ { name = "pyright", specifier = "==1.1.402" },
92
+ { name = "pytest", specifier = ">=7.1.3" },
93
+ { name = "ruff", specifier = ">=0.6.2" },
94
+ { name = "scipy", specifier = ">=1.8" },
95
+ ]
93
96
 
94
97
  [[package]]
95
98
  name = "charset-normalizer"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes