Skip to content

Commit 648317a

Browse files
authored
Merge pull request #36 from boutproject/numpy2
Support NumPy 2
2 parents 84dafa4 + cbef048 commit 648317a

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ keywords = [
2828
requires-python = ">=3.10"
2929
dependencies = [
3030
"boututils ~= 0.1.10",
31-
"numpy ~= 1.24",
31+
"numpy >= 1.24",
3232
"sympy ~= 1.7",
3333
"scipy ~= 1.10",
3434
"matplotlib ~= 3.7",

zoidberg/fieldtracer.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ def trace_poincare(
351351
raise ValueError("nplot and y_slices cannot both be None")
352352

353353
if y_slices is not None:
354-
y_slices = np.asfarray(y_slices)
354+
y_slices = np.asarray(y_slices)
355355

356356
if np.amin(y_slices) < 0.0 or np.amax(y_slices) > yperiod:
357357
raise ValueError(
@@ -384,8 +384,8 @@ def trace_poincare(
384384
) * y_values[:-1]
385385

386386
# Starting location
387-
xpos = np.asfarray(xpos)
388-
zpos = np.asfarray(zpos)
387+
xpos = np.asarray(xpos)
388+
zpos = np.asarray(zpos)
389389

390390
field_tracer = FieldTracer(magnetic_field)
391391
result = field_tracer.follow_field_lines(xpos, zpos, y_values_over)

zoidberg/grid.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, poloidal_grids, ycoords, Ly, yperiodic=False, name="fci_grid"
5454

5555
self.poloidal_grids = poloidal_grids
5656
self._ngrids = ngrids # This is an implementation detail, whether we have one or multiple separate grids
57-
self.ycoords = np.asfarray(ycoords)
57+
self.ycoords = np.asarray(ycoords)
5858
self.Ly = Ly
5959
self.yperiodic = yperiodic
6060

zoidberg/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def plot_3d_field_line(magnetic_field, xpos, zpos, yperiod, cycles=20, y_res=50)
172172
# Go round toroidally cycles times
173173
phivals_hires = np.linspace(0, cycles * yperiod, num=y_res * cycles, endpoint=False)
174174

175-
xpos = np.asfarray(xpos)
176-
zpos = np.asfarray(zpos)
175+
xpos = np.asarray(xpos)
176+
zpos = np.asarray(zpos)
177177

178178
field_tracer = fieldtracer.FieldTracer(magnetic_field)
179179
result_hires = field_tracer.follow_field_lines(xpos, zpos, phivals_hires)

zoidberg/poloidal_grid.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ def getCoordinate(self, xind, zind, dx=0, dz=0):
172172
"""
173173

174174
# Convert to NumPy arrays if not already
175-
xind = np.asfarray(xind)
176-
zind = np.asfarray(zind)
175+
xind = np.asarray(xind)
176+
zind = np.asarray(zind)
177177
# Make sure dx and dz are integers
178178
dx = int(dx)
179179
dz = int(dz)
@@ -213,8 +213,8 @@ def findIndex(self, R, Z):
213213
"""
214214

215215
# Make sure inputs are NumPy arrays
216-
R = np.asfarray(R)
217-
Z = np.asfarray(Z)
216+
R = np.asarray(R)
217+
Z = np.asarray(Z)
218218

219219
# Check that they have the same shape
220220
assert R.shape == Z.shape
@@ -353,8 +353,8 @@ def findIndex(self, R, Z, tol=1e-10, show=False):
353353
"""
354354

355355
# Make sure inputs are NumPy arrays
356-
R = np.asfarray(R)
357-
Z = np.asfarray(Z)
356+
R = np.asarray(R)
357+
Z = np.asarray(Z)
358358

359359
# Check that they have the same shape
360360
assert R.shape == Z.shape
@@ -378,8 +378,8 @@ def findIndex(self, R, Z, tol=1e-10, show=False):
378378
zind = ind - xind * nz
379379

380380
# Convert indices to float
381-
xind = np.asfarray(xind)
382-
zind = np.asfarray(zind)
381+
xind = np.asarray(xind, dtype=float)
382+
zind = np.asarray(zind, dtype=float)
383383

384384
# Create a mask for the positions
385385
mask = np.ones(xind.shape)

zoidberg/rzline.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ class RZline:
5757
"""
5858

5959
def __init__(self, r, z, anticlockwise=True, spline_order=None, smooth=False):
60-
r = np.asfarray(r)
61-
z = np.asfarray(z)
60+
r = np.asarray(r)
61+
z = np.asarray(z)
6262

6363
# Check the sizes of the variables
6464
n = len(r)
@@ -421,8 +421,8 @@ def line_from_points_poly(rarray, zarray, show=False, spline_order=None):
421421
422422
"""
423423

424-
rarray = np.asfarray(rarray)
425-
zarray = np.asfarray(zarray)
424+
rarray = np.asarray(rarray)
425+
zarray = np.asarray(zarray)
426426

427427
assert rarray.size >= 3
428428
assert rarray.shape == zarray.shape
@@ -610,8 +610,8 @@ def line_from_points(
610610
"""
611611

612612
# Make sure we have Numpy arrays
613-
rarray = np.asfarray(rarray)
614-
zarray = np.asfarray(zarray)
613+
rarray = np.asarray(rarray)
614+
zarray = np.asarray(zarray)
615615

616616
assert rarray.size == zarray.size
617617

0 commit comments

Comments
 (0)