Skip to content

Commit

Permalink
Fix failing ASV benchmarks (#1118)
Browse files Browse the repository at this point in the history
* update benchmarks

* update docstrings and cross section benchmark

* update benchmarks

* update cross section bench

* add loop

* update teardown
  • Loading branch information
philipc2 authored Dec 23, 2024
1 parent 79275c5 commit 1f25c7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
23 changes: 16 additions & 7 deletions benchmarks/mpas_ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def time_inverse_distance_weighted_remapping(self):

class HoleEdgeIndices(DatasetBenchmark):
def time_construct_hole_edge_indices(self, resolution):
ux.grid.geometry._construct_hole_edge_indices(self.uxds.uxgrid.edge_face_connectivity)
ux.grid.geometry._construct_boundary_edge_indices(self.uxds.uxgrid.edge_face_connectivity)


class DualMesh(DatasetBenchmark):
Expand Down Expand Up @@ -167,10 +167,19 @@ def time_check_norm(self, resolution):
from uxarray.grid.validation import _check_normalization
_check_normalization(self.uxgrid)

class CrossSection:
param_names = DatasetBenchmark.param_names + ['lat_step']
params = DatasetBenchmark.params + [[1, 2, 4]]

class CrossSections(DatasetBenchmark):
param_names = DatasetBenchmark.param_names + ['n_lat']
params = DatasetBenchmark.params + [[1, 2, 4, 8]]
def time_constant_lat_fast(self, resolution, n_lat):
for lat in np.linspace(-89, 89, n_lat):
self.uxds.uxgrid.constant_latitude_cross_section(lat, method='fast')
def setup(self, resolution, lat_step):
self.uxgrid = ux.open_grid(file_path_dict[resolution][0])
self.uxgrid.normalize_cartesian_coordinates()
self.lats = np.arange(-45, 45, lat_step)
_ = self.uxgrid.bounds

def teardown(self, resolution, lat_step):
del self.uxgrid

def time_const_lat(self, resolution, lat_step):
for lat in self.lats:
self.uxgrid.cross_section.constant_latitude(lat)
4 changes: 2 additions & 2 deletions uxarray/cross_sections/dataarray_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def constant_latitude(self, lat: float):
Examples
--------
>>> # Extract data at 15.5°S latitude
>>> cross_section = uxda.constant_latitude(lat=-15.5)
>>> cross_section = uxda.cross_section.constant_latitude(lat=-15.5)
Notes
-----
Expand Down Expand Up @@ -86,7 +86,7 @@ def constant_longitude(self, lon: float):
Examples
--------
>>> # Extract data at 0° longitude
>>> cross_section = uxda.constant_latitude(lon=0.0)
>>> cross_section = uxda.cross_section.constant_latitude(lon=0.0)
Notes
-----
Expand Down
4 changes: 2 additions & 2 deletions uxarray/cross_sections/grid_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def constant_latitude(
Examples
--------
>>> # Extract data at 15.5°S latitude
>>> cross_section = grid.constant_latitude(lat=-15.5)
>>> cross_section = grid.cross_section.constant_latitude(lat=-15.5)
Notes
-----
Expand Down Expand Up @@ -103,7 +103,7 @@ def constant_longitude(
Examples
--------
>>> # Extract data at 0° longitude
>>> cross_section = grid.constant_latitude(lon=0.0)
>>> cross_section = grid.cross_section.constant_latitude(lon=0.0)
Notes
-----
Expand Down

0 comments on commit 1f25c7c

Please sign in to comment.