-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
188 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright Iris contributors | ||
# | ||
# This file is part of Iris and is released under the BSD license. | ||
# See LICENSE in the root of the repository for full licensing details. | ||
"""Stats benchmark tests.""" | ||
|
||
import iris | ||
from iris.analysis.stats import pearsonr | ||
import iris.tests | ||
|
||
|
||
class PearsonR: | ||
def setup(self): | ||
cube_temp = iris.load_cube( | ||
iris.tests.get_data_path( | ||
("NetCDF", "global", "xyt", "SMALL_total_column_co2.nc") | ||
) | ||
) | ||
|
||
# Make data non-lazy. | ||
cube_temp.data | ||
|
||
self.cube_a = cube_temp[:6] | ||
self.cube_b = cube_temp[20:26] | ||
self.cube_b.replace_coord(self.cube_a.coord("time")) | ||
for name in ["latitude", "longitude"]: | ||
self.cube_b.coord(name).guess_bounds() | ||
self.weights = iris.analysis.cartography.area_weights(self.cube_b) | ||
|
||
def time_real(self): | ||
pearsonr(self.cube_a, self.cube_b, weights=self.weights) | ||
|
||
def time_lazy(self): | ||
for cube in self.cube_a, self.cube_b: | ||
cube.data = cube.lazy_data() | ||
|
||
result = pearsonr(self.cube_a, self.cube_b, weights=self.weights) | ||
result.data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.