Skip to content

Commit 99061d8

Browse files
committed
Fix dtype handling in iris.util.regular_points for NumPy v2.
1 parent aa5cdff commit 99061d8

File tree

9 files changed

+25
-13
lines changed

9 files changed

+25
-13
lines changed

lib/iris/tests/results/FF/air_temperature_1.cml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
3232
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
3333
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
34-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
34+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
3535
<geogCS earth_radius="6371229.0"/>
3636
</dimCoord>
3737
</coord>
3838
<coord datadims="[1]">
3939
<dimCoord circular="True" id="f913a8b3" points="[ 0. , 3.75, 7.5 , ..., 348.75, 352.5 ,
40-
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float64">
40+
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
4141
<geogCS earth_radius="6371229.0"/>
4242
</dimCoord>
4343
</coord>

lib/iris/tests/results/FF/air_temperature_2.cml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
3232
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
3333
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
34-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
34+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
3535
<geogCS earth_radius="6371229.0"/>
3636
</dimCoord>
3737
</coord>
3838
<coord datadims="[1]">
3939
<dimCoord circular="True" id="f913a8b3" points="[ 0. , 3.75, 7.5 , ..., 348.75, 352.5 ,
40-
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float64">
40+
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
4141
<geogCS earth_radius="6371229.0"/>
4242
</dimCoord>
4343
</coord>

lib/iris/tests/results/FF/soil_temperature_1.cml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
2525
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
2626
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
27-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
27+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
2828
<geogCS earth_radius="6371229.0"/>
2929
</dimCoord>
3030
</coord>
3131
<coord datadims="[1]">
3232
<dimCoord circular="True" id="f913a8b3" points="[ 0. , 3.75, 7.5 , ..., 348.75, 352.5 ,
33-
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float64">
33+
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
3434
<geogCS earth_radius="6371229.0"/>
3535
</dimCoord>
3636
</coord>

lib/iris/tests/results/FF/surface_altitude_1.cml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
2525
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
2626
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
27-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
27+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
2828
<geogCS earth_radius="6371229.0"/>
2929
</dimCoord>
3030
</coord>
3131
<coord datadims="[1]">
3232
<dimCoord circular="True" id="f913a8b3" points="[ 0. , 3.75, 7.5 , ..., 348.75, 352.5 ,
33-
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float64">
33+
356.25]" shape="(96,)" standard_name="longitude" units="Unit('degrees')" value_type="float32">
3434
<geogCS earth_radius="6371229.0"/>
3535
</dimCoord>
3636
</coord>

lib/iris/tests/results/usecases/pp_to_cf_conversion/from_netcdf/002000000000.44.101.131200.1920.09.01.00.00.b_0.cml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
3939
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
4040
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
41-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64" var_name="latitude">
41+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32" var_name="latitude">
4242
<geogCS earth_radius="6371229.0"/>
4343
</dimCoord>
4444
</coord>

lib/iris/tests/results/usecases/pp_to_cf_conversion/from_pp/002000000000.44.101.131200.1920.09.01.00.00.b.cml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
32.5, 35. , 37.5, 40. , 42.5, 45. , 47.5,
3838
50. , 52.5, 55. , 57.5, 60. , 62.5, 65. ,
3939
67.5, 70. , 72.5, 75. , 77.5, 80. , 82.5,
40-
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float64">
40+
85. , 87.5, 90. ]" shape="(73,)" standard_name="latitude" units="Unit('degrees')" value_type="float32">
4141
<geogCS earth_radius="6371229.0"/>
4242
</dimCoord>
4343
</coord>

lib/iris/tests/results/usecases/pp_to_cf_conversion/to_netcdf/002000000000.44.101.131200.1920.09.01.00.00.b_0.cdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ variables:
1818
depth:units = "m" ;
1919
depth:standard_name = "depth" ;
2020
depth:positive = "down" ;
21-
double latitude(latitude) ;
21+
float latitude(latitude) ;
2222
latitude:axis = "Y" ;
2323
latitude:units = "degrees_north" ;
2424
latitude:standard_name = "latitude" ;

lib/iris/tests/unit/fileformats/pp_load_rules/test__all_other_rules.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def test_multiple_unordered_lbprocs(self):
113113
x_bounds=None,
114114
_x_coord_name=lambda: "longitude",
115115
_y_coord_name=lambda: "latitude",
116+
# Not under test but needed for the Mock to play nicely.
117+
bzy=1,
118+
bdy=1,
116119
)
117120
res = _all_other_rules(field)[CELL_METHODS_INDEX]
118121
expected = [
@@ -133,6 +136,9 @@ def test_multiple_unordered_rotated_lbprocs(self):
133136
x_bounds=None,
134137
_x_coord_name=lambda: "grid_longitude",
135138
_y_coord_name=lambda: "grid_latitude",
139+
# Not under test but needed for the Mock to play nicely.
140+
bzy=1,
141+
bdy=1,
136142
)
137143
res = _all_other_rules(field)[CELL_METHODS_INDEX]
138144
expected = [

lib/iris/util.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,10 +1415,16 @@ def regular_points(zeroth, step, count):
14151415
This function does maintain laziness when called; it doesn't realise data.
14161416
See more at :doc:`/userguide/real_and_lazy_data`.
14171417
"""
1418-
points = (zeroth + step) + step * np.arange(count, dtype=np.float32)
1418+
1419+
def make_steps(dtype: np.dtype):
1420+
start = np.add(zeroth, step, dtype=dtype)
1421+
steps = np.multiply(step, np.arange(count), dtype=dtype)
1422+
return np.add(start, steps, dtype=dtype)
1423+
1424+
points = make_steps(np.float32)
14191425
_, regular = iris.util.points_step(points)
14201426
if not regular:
1421-
points = (zeroth + step) + step * np.arange(count, dtype=np.float64)
1427+
points = make_steps(np.float64)
14221428
return points
14231429

14241430

0 commit comments

Comments
 (0)