Skip to content

Commit 1a95c23

Browse files
Some assorted JIT cleanup
1 parent c89f677 commit 1a95c23

File tree

8 files changed

+9
-14
lines changed

8 files changed

+9
-14
lines changed

docs/examples/tutorial_parcels_structure.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"source": [
2626
"1. [**FieldSet**](#1.-FieldSet). Load and set up the fields. These can be velocity fields that are used to advect the particles, but it can also be e.g. temperature.\n",
2727
"2. [**ParticleSet**](#2.-ParticleSet). Define the type of particles. Also additional `Variables` can be added to the particles (e.g. temperature, to keep track of the temperature that particles experience).\n",
28-
"3. [**Kernels**](#3.-Kernels). Define and compile kernels. Kernels perform some specific operation on the particles every time step (e.g. interpolate the temperature from the temperature field to the particle location).\n",
28+
"3. [**Kernels**](#3.-Kernels). Kernels perform some specific operation on the particles every time step (e.g. interpolate the temperature from the temperature field to the particle location).\n",
2929
"4. [**Execution and output**](#4.-Execution-and-Output). Execute the simulation and write and store the output in a Zarr file.\n",
3030
"5. [**Optimising and parallelising**](#5.-Optimising-and-parallelising). Optimise and parallelise the code to run faster.\n",
3131
"\n",

parcels/field.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ class Field:
149149
Maximum allowed value on the field. Data above this value are set to zero
150150
cast_data_dtype : str
151151
Cast Field data to dtype. Supported dtypes are "float32" (np.float32 (default)) and "float64 (np.float64).
152-
Note that dtype can only be "float32" in JIT mode
153152
time_origin : parcels.tools.converters.TimeConverter
154153
Time origin of the time axis (only if grid is None)
155154
interp_method : str

parcels/fieldset.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,8 +1447,7 @@ def get_fields(self) -> list[Field | VectorField]:
14471447

14481448
def add_constant(self, name, value):
14491449
"""Add a constant to the FieldSet. Note that all constants are
1450-
stored as 32-bit floats. While constants can be updated during
1451-
execution in SciPy mode, they can not be updated in JIT mode.
1450+
stored as 32-bit floats.
14521451
14531452
Parameters
14541453
----------

parcels/kernel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Kernel(BaseKernel):
9494
9595
Notes
9696
-----
97-
A Kernel is either created from a compiled <function ...> object
97+
A Kernel is either created from a <function ...> object
9898
or the necessary information (funcname, funccode, funcvars) is provided.
9999
The py_ast argument may be derived from the code string, but for
100100
concatenation, the merged AST plus the new header definition is required.
@@ -159,7 +159,7 @@ def __init__(
159159
user_ctx = globals()
160160
finally:
161161
del stack # Remove cyclic references
162-
# Compile and generate Python function from AST
162+
# Generate Python function from AST
163163
py_mod = ast.parse("")
164164
py_mod.body = [self.py_ast]
165165
exec(compile(py_mod, "<ast>", "exec"), user_ctx)

parcels/particleset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,13 +932,13 @@ def execute(
932932
933933
Notes
934934
-----
935-
``ParticleSet.execute()`` acts as the main entrypoint for simulations, and provides the simulation time-loop. This method encapsulates the logic controlling the switching between kernel execution (where control in handed to C in JIT mode), output file writing, reading in fields for new timesteps, adding new particles to the simulation domain, stopping the simulation, and executing custom functions (``postIterationCallbacks`` provided by the user).
935+
``ParticleSet.execute()`` acts as the main entrypoint for simulations, and provides the simulation time-loop. This method encapsulates the logic controlling the switching between kernel execution, output file writing, reading in fields for new timesteps, adding new particles to the simulation domain, stopping the simulation, and executing custom functions (``postIterationCallbacks`` provided by the user).
936936
"""
937937
# check if particleset is empty. If so, return immediately
938938
if len(self) == 0:
939939
return
940940

941-
# check if pyfunc has changed since last compile. If so, recompile
941+
# check if pyfunc has changed since last generation. If so, regenerate
942942
if self._kernel is None or (self._kernel.pyfunc is not pyfunc and self._kernel is not pyfunc):
943943
# Generate and store Kernel
944944
if isinstance(pyfunc, Kernel):

tests/test_grids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def bath_func(lon):
255255
for i in range(depth_g0.shape[0]):
256256
for k in range(depth_g0.shape[2]):
257257
depth_g0[i, :, k] = bath[i] * k / (depth_g0.shape[2] - 1)
258-
depth_g0 = depth_g0.transpose() # we don't change it on purpose, to check if the transpose op if fixed in jit
258+
depth_g0 = depth_g0.transpose()
259259

260260
grid = RectilinearSGrid(lon_g0, lat_g0, depth=depth_g0)
261261

tests/test_interpolation.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,7 @@ def data_2d():
9090
],
9191
)
9292
def test_raw_2d_interpolation(data_2d, func, eta, xsi, expected):
93-
"""Test the 2D interpolation functions on the raw arrays.
94-
95-
Interpolation via the other interpolation methods are tested in `test_scipy_vs_jit`.
96-
"""
93+
"""Test the 2D interpolation functions on the raw arrays."""
9794
ti = 0
9895
yi, xi = 1, 1
9996
ctx = interpolation.InterpolationContext2D(data_2d, eta, xsi, ti, yi, xi)

tests/test_particles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def addOne(particle, fieldset, time): # pragma: no cover
4747

4848
@pytest.mark.parametrize("type", ["np.int8", "mp.float", "np.int16"])
4949
def test_variable_unsupported_dtypes(fieldset, type):
50-
"""Test that checks errors thrown for unsupported dtypes in JIT mode."""
50+
"""Test that checks errors thrown for unsupported dtypes."""
5151
TestParticle = ScipyParticle.add_variable("p", dtype=type, initial=10.0)
5252
with pytest.raises((RuntimeError, TypeError)):
5353
ParticleSet(fieldset, pclass=TestParticle, lon=[0], lat=[0])

0 commit comments

Comments
 (0)