diff --git a/pymt/component/component.py b/pymt/component/component.py index 7ced9fd1..69b313dc 100644 --- a/pymt/component/component.py +++ b/pymt/component/component.py @@ -55,6 +55,7 @@ 100.0 >>> comp.finalize() """ + import warnings import yaml diff --git a/pymt/component/grid.py b/pymt/component/grid.py index 52690ebe..302d4027 100644 --- a/pymt/component/grid.py +++ b/pymt/component/grid.py @@ -25,15 +25,15 @@ def raster_node_coordinates(shape, spacing=None, origin=None): >>> from pymt.component.grid import raster_node_coordinates >>> (y, x) = raster_node_coordinates((2, 3)) >>> y - array([[ 0., 0., 0.], - [ 1., 1., 1.]]) + array([[0., 0., 0.], + [1., 1., 1.]]) >>> x - array([[ 0., 1., 2.], - [ 0., 1., 2.]]) + array([[0., 1., 2.], + [0., 1., 2.]]) >>> (x, ) = raster_node_coordinates((3, ), (2., ), (1., )) >>> x - array([ 1., 3., 5.]) + array([1., 3., 5.]) """ spacing = spacing or np.ones_like(shape, dtype=float) origin = origin or np.zeros_like(shape, dtype=float) @@ -74,11 +74,11 @@ def get_raster_node_coordinates(grid, grid_id): >>> g = RasterGrid() >>> (y, x) = get_raster_node_coordinates(g, 0) >>> y - array([[ 2., 2., 2.], - [ 3., 3., 3.]]) + array([[2., 2., 2.], + [3., 3., 3.]]) >>> x - array([[ 1., 3., 5.], - [ 1., 3., 5.]]) + array([[1., 3., 5.], + [1., 3., 5.]]) """ (shape, spacing, origin) = ( grid.get_grid_shape(grid_id), @@ -115,11 +115,11 @@ def get_rectilinear_node_coordinates(grid, grid_id): >>> g = RectilinearGrid() >>> (y, x) = get_rectilinear_node_coordinates(g, 0) >>> y - array([[ 2., 2., 2.], - [ 7., 7., 7.]]) + array([[2., 2., 2.], + [7., 7., 7.]]) >>> x - array([[ 0., 3., 4.], - [ 0., 3., 4.]]) + array([[0., 3., 4.], + [0., 3., 4.]]) """ coordinate_vectors = [] for coordinate_name in ["z", "y", "x"]: @@ -160,11 +160,11 @@ def get_structured_node_coordinates(grid, grid_id): >>> g = StructuredGrid() >>> (y, x) = get_structured_node_coordinates(g, 0) >>> y - array([[ 2., 2., 2.], - [ 7., 7., 7.]]) + array([[2., 2., 2.], + [7., 7., 7.]]) >>> x - array([[ 0., 3., 4.], - [ 0., 3., 4.]]) + array([[0., 3., 4.], + [0., 3., 4.]]) """ node_coordinates = [] for coordinate_name in ["z", "y", "x"]: @@ -246,11 +246,11 @@ class GridMixIn: >>> c.get_grid_type(0) 'RASTER' >>> c.get_x(0) - array([[ 0., 1., 2.], - [ 0., 1., 2.]]) + array([[0., 1., 2.], + [0., 1., 2.]]) >>> c.get_y(0) - array([[ 0., 0., 0.], - [ 2., 2., 2.]]) + array([[0., 0., 0.], + [2., 2., 2.]]) """ def __init__(self): diff --git a/pymt/events/manager.py b/pymt/events/manager.py index 08f8713e..0d091a8a 100644 --- a/pymt/events/manager.py +++ b/pymt/events/manager.py @@ -45,6 +45,7 @@ hello! hello from finalize """ + from configparser import ConfigParser from io import StringIO diff --git a/pymt/events/port.py b/pymt/events/port.py index 9e71a19e..6533fe02 100644 --- a/pymt/events/port.py +++ b/pymt/events/port.py @@ -1,5 +1,6 @@ """Wrap a port as a :class:`Timeline` event. """ + import os import sys diff --git a/pymt/framework/bmi_bridge.py b/pymt/framework/bmi_bridge.py index e1e0ef37..6120dd00 100644 --- a/pymt/framework/bmi_bridge.py +++ b/pymt/framework/bmi_bridge.py @@ -1,4 +1,5 @@ """Bridge between BMI and a PyMT component.""" + import ctypes import json import os @@ -91,7 +92,6 @@ def __str__(self): class _BmiCapV1: - """Add methods for backward compatibility.""" @staticmethod diff --git a/pymt/framework/services.py b/pymt/framework/services.py index 758bc8c7..80f2e914 100644 --- a/pymt/framework/services.py +++ b/pymt/framework/services.py @@ -1,5 +1,6 @@ """Access to framework services. """ + import warnings _COMPONENT_CLASSES = {} diff --git a/pymt/grids/field.py b/pymt/grids/field.py index 02d22f60..f3766182 100644 --- a/pymt/grids/field.py +++ b/pymt/grids/field.py @@ -267,7 +267,7 @@ class RasterField(UniformRectilinear, StructuredField): array([ 0., 10., 20., 30., 40.]) >>> g.get_field ('Point Data') - array([ 0., 1., 2., 3., 4., 5.]) + array([0., 1., 2., 3., 4., 5.]) A 3D-Field, diff --git a/pymt/grids/map.py b/pymt/grids/map.py index fdc5e1d0..ad4d4639 100644 --- a/pymt/grids/map.py +++ b/pymt/grids/map.py @@ -19,9 +19,9 @@ >>> g = RectilinearMap ([0, 2], [0, 1, 2]) >>> g.get_x () -array([ 0., 1., 2., 0., 1., 2.]) +array([0., 1., 2., 0., 1., 2.]) >>> g.get_y () -array([ 0., 0., 0., 2., 2., 2.]) +array([0., 0., 0., 2., 2., 2.]) Node 1 is shared by both cell 0, and 1; node 5 only is part of cell 1. diff --git a/pymt/grids/meshgrid.py b/pymt/grids/meshgrid.py index 60fdaf2e..aed2a05c 100644 --- a/pymt/grids/meshgrid.py +++ b/pymt/grids/meshgrid.py @@ -35,17 +35,17 @@ >>> y = np.linspace(0, 1, ny) >>> xv, yv = meshgrid(x, y) >>> xv -array([[ 0. , 0.5, 1. ], - [ 0. , 0.5, 1. ]]) +array([[0. , 0.5, 1. ], + [0. , 0.5, 1. ]]) >>> yv -array([[ 0., 0., 0.], - [ 1., 1., 1.]]) +array([[0., 0., 0.], + [1., 1., 1.]]) >>> xv, yv = meshgrid(x, y, sparse=True) # make sparse output arrays >>> xv -array([[ 0. , 0.5, 1. ]]) +array([[0. , 0.5, 1. ]]) >>> yv -array([[ 0.], - [ 1.]]) +array([[0.], + [1.]]) `meshgrid` is very useful to evaluate functions on a grid. diff --git a/pymt/grids/raster.py b/pymt/grids/raster.py index ee9b9626..0510e809 100644 --- a/pymt/grids/raster.py +++ b/pymt/grids/raster.py @@ -10,9 +10,9 @@ >>> g = UniformRectilinear ((2,3), (1,2), (.5, 0), indexing='ij', units=('m', 'km')) >>> g.get_x() -array([ 0., 2., 4., 0., 2., 4.]) +array([0., 2., 4., 0., 2., 4.]) >>> g.get_y() -array([ 0.5, 0.5, 0.5, 1.5, 1.5, 1.5]) +array([0.5, 0.5, 0.5, 1.5, 1.5, 1.5]) >>> [g.get_x_units(), g.get_y_units()] ['km', 'm'] >>> g.get_z_units() @@ -28,9 +28,9 @@ >>> g.get_shape() array([2, 3]) >>> g.get_spacing() -array([ 1., 2.]) +array([1., 2.]) >>> g.get_origin() -array([ 0.5, 0. ]) +array([0.5, 0. ]) >>> g.get_offset() array([4, 8]) >>> g.get_connectivity() @@ -42,15 +42,15 @@ >>> g = UniformRectilinearPoints ((2,3), (1,2), (.5, 0), indexing='ij', set_connectivity=True) >>> g.get_x() -array([ 0., 2., 4., 0., 2., 4.]) +array([0., 2., 4., 0., 2., 4.]) >>> g.get_y() -array([ 0.5, 0.5, 0.5, 1.5, 1.5, 1.5]) +array([0.5, 0.5, 0.5, 1.5, 1.5, 1.5]) >>> g.get_shape() array([2, 3]) >>> g.get_spacing() -array([ 1., 2.]) +array([1., 2.]) >>> g.get_origin() -array([ 0.5, 0. ]) +array([0.5, 0. ]) >>> g.get_point_count() 6 @@ -72,17 +72,17 @@ >>> g = UniformRectilinearPoints ((5, ), (1., ), (.5,), indexing='ij', set_connectivity=True) >>> g.get_x() -array([ 0.5, 1.5, 2.5, 3.5, 4.5]) +array([0.5, 1.5, 2.5, 3.5, 4.5]) **3D-grid of cells** >>> g = UniformRectilinear ((4, 3, 2), (1, 2, 3), (-1, 0, 1), indexing='ij') >>> g.get_x() -array([ 1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., - 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., 4.]) +array([1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., 4., 1., + 4., 1., 4., 1., 4., 1., 4.]) >>> g.get_y() -array([ 0., 0., 2., 2., 4., 4., 0., 0., 2., 2., 4., 4., 0., - 0., 2., 2., 4., 4., 0., 0., 2., 2., 4., 4.]) +array([0., 0., 2., 2., 4., 4., 0., 0., 2., 2., 4., 4., 0., 0., 2., 2., 4., + 4., 0., 0., 2., 2., 4., 4.]) >>> g.get_z() array([-1., -1., -1., -1., -1., -1., 0., 0., 0., 0., 0., 0., 1., 1., 1., 1., 1., 1., 2., 2., 2., 2., 2., 2.]) diff --git a/pymt/grids/rectilinear.py b/pymt/grids/rectilinear.py index 379ca029..7998d38c 100644 --- a/pymt/grids/rectilinear.py +++ b/pymt/grids/rectilinear.py @@ -10,9 +10,9 @@ >>> g.get_cell_count() 6 >>> g.get_x() -array([ 1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) +array([1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) >>> g.get_y() -array([ 1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) +array([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) >>> g.get_shape() array([3, 4]) @@ -20,9 +20,9 @@ >>> g = Rectilinear([1., 2., 4., 8.], [1., 2., 3.], indexing='ij') >>> g.get_x() -array([ 1., 2., 3., 1., 2., 3., 1., 2., 3., 1., 2., 3.]) +array([1., 2., 3., 1., 2., 3., 1., 2., 3., 1., 2., 3.]) >>> g.get_y() -array([ 1., 1., 1., 2., 2., 2., 4., 4., 4., 8., 8., 8.]) +array([1., 1., 1., 2., 2., 2., 4., 4., 4., 8., 8., 8.]) >>> g.get_shape() array([4, 3]) @@ -38,9 +38,9 @@ >>> g = RectilinearPoints ([1., 2., 4., 8.], [1., 2., 3.], indexing='ij', set_connectivity=True) >>> g.get_x() -array([ 1., 2., 3., 1., 2., 3., 1., 2., 3., 1., 2., 3.]) +array([1., 2., 3., 1., 2., 3., 1., 2., 3., 1., 2., 3.]) >>> g.get_y() -array([ 1., 1., 1., 2., 2., 2., 4., 4., 4., 8., 8., 8.]) +array([1., 1., 1., 2., 2., 2., 4., 4., 4., 8., 8., 8.]) >>> g.get_shape () array([4, 3]) >>> g.get_point_count() @@ -63,7 +63,7 @@ >>> g = Rectilinear([1,3,4,5,6], set_connectivity=True) >>> g.get_x() -array([ 1., 3., 4., 5., 6.]) +array([1., 3., 4., 5., 6.]) >>> g.get_point_count() 5 >>> g.get_cell_count() @@ -78,17 +78,17 @@ >>> g = Rectilinear ([0, 1], [2, 3], set_connectivity=True, indexing='ij') >>> g.get_x() -array([ 2., 3., 2., 3.]) +array([2., 3., 2., 3.]) >>> g.get_y() -array([ 0., 0., 1., 1.]) +array([0., 0., 1., 1.]) >>> g = Rectilinear ([0, 1], [2, 3], [4, 5], set_connectivity=True, indexing='ij') >>> g.get_x() -array([ 4., 5., 4., 5., 4., 5., 4., 5.]) +array([4., 5., 4., 5., 4., 5., 4., 5.]) >>> g.get_y() -array([ 2., 2., 3., 3., 2., 2., 3., 3.]) +array([2., 2., 3., 3., 2., 2., 3., 3.]) >>> g.get_z() -array([ 0., 0., 0., 0., 1., 1., 1., 1.]) +array([0., 0., 0., 0., 1., 1., 1., 1.]) >>> g.get_point_count() 8 >>> g.get_cell_count() @@ -96,8 +96,8 @@ >>> g = Rectilinear([0, 1, 2, 3], [4, 5, 6], [7, 8], set_connectivity=True, indexing='ij') >>> g.get_x() -array([ 7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., - 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., 8.]) +array([7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., 8., 7., + 8., 7., 8., 7., 8., 7., 8.]) >>> g.get_shape() array([4, 3, 2]) >>> x = g.get_x() @@ -153,7 +153,7 @@ def get_x_coordinates(self): >>> g = Rectilinear([0, 1], [2, 3], [4, 5], set_connectivity=True, indexing='ij') >>> g.get_x_coordinates() - array([ 4., 5.]) + array([4., 5.]) """ return self._x_coordinates @@ -164,7 +164,7 @@ def get_y_coordinates(self): >>> g = Rectilinear([0, 1], [2, 3], [4, 5], set_connectivity=True, indexing='ij') >>> g.get_y_coordinates() - array([ 2., 3.]) + array([2., 3.]) """ return self._y_coordinates @@ -175,7 +175,7 @@ def get_z_coordinates(self): >>> g = Rectilinear([0, 1], [2, 3], [4, 5], set_connectivity=True, indexing='ij') >>> g.get_z_coordinates() - array([ 0., 1.]) + array([0., 1.]) """ return self._z_coordinates diff --git a/pymt/grids/structured.py b/pymt/grids/structured.py index e29b2ef2..9f33853b 100644 --- a/pymt/grids/structured.py +++ b/pymt/grids/structured.py @@ -11,9 +11,9 @@ >>> g.get_cell_count() 6 >>> g.get_x() -array([ 1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) +array([1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) >>> g.get_y() -array([ 1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) +array([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) >>> g.get_shape() array([3, 4]) @@ -22,9 +22,9 @@ >>> (x, y) = np.meshgrid ([1., 2., 4., 8.], [1., 2., 3.]) >>> g = Structured (y.flatten (), x.flatten (), (3, 4), indexing='ij') >>> g.get_x() -array([ 1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) +array([1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) >>> g.get_y() -array([ 1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) +array([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) >>> g.get_shape() array([3, 4]) @@ -41,9 +41,9 @@ >>> (x, y) = np.meshgrid ([1., 2., 4., 8.], [1., 2., 3.]) >>> g = StructuredPoints (y.flatten (), x.flatten (), (3, 4), indexing='ij', set_connectivity=True) >>> g.get_x() -array([ 1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) +array([1., 2., 4., 8., 1., 2., 4., 8., 1., 2., 4., 8.]) >>> g.get_y() -array([ 1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) +array([1., 1., 1., 1., 2., 2., 2., 2., 3., 3., 3., 3.]) >>> g.get_shape() array([3, 4]) @@ -91,11 +91,11 @@ >>> g = Structured(z, y, x, (2, 2, 2)) >>> g.get_x() -array([ 0., 1., 0., 1., 0., 1., 0., 1.]) +array([0., 1., 0., 1., 0., 1., 0., 1.]) >>> g.get_y() -array([ 0., 0., 1., 1., 0., 0., 1., 1.]) +array([0., 0., 1., 1., 0., 0., 1., 1.]) >>> g.get_z() -array([ 0., 0., 0., 0., 1., 1., 1., 1.]) +array([0., 0., 0., 0., 1., 1., 1., 1.]) >>> g.get_connectivity() array([0, 1, 3, 2, 4, 5, 7, 6]) @@ -106,6 +106,7 @@ >>> g.get_connectivity() array([1, 0, 2, 3, 5, 4, 6, 7]) """ + import warnings import numpy as np diff --git a/pymt/grids/unstructured.py b/pymt/grids/unstructured.py index f4e94fb6..6d3a602b 100644 --- a/pymt/grids/unstructured.py +++ b/pymt/grids/unstructured.py @@ -212,10 +212,10 @@ class Unstructured(UnstructuredPoints): 2 >>> g.get_x() - array([ 0., 2., 1., 3.]) + array([0., 2., 1., 3.]) >>> g.get_y() - array([ 0., 0., 1., 1.]) + array([0., 0., 1., 1.]) >>> g.get_connectivity() array([0, 2, 1, 2, 3, 1]) @@ -247,11 +247,11 @@ class Unstructured(UnstructuredPoints): >>> g.get_cell_count() 1 >>> g.get_x() - array([ 0., 1., 0., 1., 0., 1., 0., 1.]) + array([0., 1., 0., 1., 0., 1., 0., 1.]) >>> g.get_y() - array([ 0., 0., 1., 1., 0., 0., 1., 1.]) + array([0., 0., 1., 1., 0., 0., 1., 1.]) >>> g.get_z() - array([ 0., 0., 0., 0., 1., 1., 1., 1.]) + array([0., 0., 0., 0., 1., 1., 1., 1.]) """ def __init__(self, *args, **kwds): diff --git a/pymt/mappers/mapper.py b/pymt/mappers/mapper.py index cf7c6244..61f4e3c1 100644 --- a/pymt/mappers/mapper.py +++ b/pymt/mappers/mapper.py @@ -12,15 +12,15 @@ >>> dst = Rectilinear([.5, 1.5, 2.5], [.25, 1.25]) >>> src.get_x() -array([ 0., 2., 0., 2., 0., 2.]) +array([0., 2., 0., 2., 0., 2.]) >>> src.get_y() -array([ 0., 0., 1., 1., 2., 2.]) +array([0., 0., 1., 1., 2., 2.]) >>> dst.get_x() -array([ 0.25, 1.25, 0.25, 1.25, 0.25, 1.25]) +array([0.25, 1.25, 0.25, 1.25, 0.25, 1.25]) >>> dst.get_y() -array([ 0.5, 0.5, 1.5, 1.5, 2.5, 2.5]) +array([0.5, 0.5, 1.5, 1.5, 2.5, 2.5]) >>> src_vals = np.arange(src.get_point_count(), dtype=np.float64) @@ -32,7 +32,7 @@ >>> mapper = NearestVal() >>> mapper.initialize(dst, src) >>> mapper.run(src_vals) -array([ 0., 1., 2., 3., 4., 5.]) +array([0., 1., 2., 3., 4., 5.]) >>> mappers = find_mapper(dst, src) >>> len(mappers) @@ -102,10 +102,10 @@ >>> mapper.initialize(dst, src) >>> mapper.run(src_vals, bad_val=-999) -array([ 1.5, 4. , 1. ]) +array([1.5, 4. , 1. ]) >>> mapper.run(src_vals, bad_val=-999, method=np.sum) -array([ 3., 4., 1.]) +array([3., 4., 1.]) >>> src_vals[0] = -9999 >>> dst_vals = np.zeros(dst.get_cell_count ()) - 1 @@ -129,7 +129,7 @@ >>> dst_vals = np.zeros(dst.get_cell_count()) - 1 >>> _ = mapper.run(src_vals, dst_vals=dst_vals) >>> dst_vals -array([ 1. , 0.5, 3. ]) +array([1. , 0.5, 3. ]) A big mapper ============ diff --git a/pymt/mappers/pointtopoint.py b/pymt/mappers/pointtopoint.py index d17bb07e..44ba5195 100644 --- a/pymt/mappers/pointtopoint.py +++ b/pymt/mappers/pointtopoint.py @@ -37,10 +37,10 @@ def copy_good_values(src, dst, bad_val=-999): >>> rv is y True >>> y - array([[ 0., 1., 2.], - [ 3., 4., 5.]]) + array([[0., 1., 2.], + [3., 4., 5.]]) >>> copy_good_values(x, np.zeros(6), bad_val=3.) - array([ 0., 0., 0., 0., 4., 5.]) + array([0., 0., 0., 0., 4., 5.]) """ if src.size != dst.size: raise ValueError("size mismatch between source and destination arrays") @@ -65,7 +65,7 @@ class NearestVal(IGridMapper): >>> mapper = NearestVal() >>> mapper.initialize(dst, src) >>> mapper.run(np.arange(6.)) - array([ 0., 1., 2., 3., 4., 5.]) + array([0., 1., 2., 3., 4., 5.]) """ _name = "PointToPoint" diff --git a/pymt/portprinter/port_printer.py b/pymt/portprinter/port_printer.py index 72927b8f..9786ff56 100644 --- a/pymt/portprinter/port_printer.py +++ b/pymt/portprinter/port_printer.py @@ -60,7 +60,7 @@ def resync_field_to_port(self): @classmethod def from_string(cls, source, prefix="print"): config = ConfigParser() - config.readfp(StringIO(source)) + config.read_file(StringIO(source)) return cls._from_config(config, prefix=prefix) @classmethod diff --git a/pymt/timeline.py b/pymt/timeline.py index 2a85294f..be1425f5 100644 --- a/pymt/timeline.py +++ b/pymt/timeline.py @@ -66,6 +66,7 @@ ('event', 0) ('event', 2) """ + import bisect diff --git a/tests/framework/test_bmi_ugrid.py b/tests/framework/test_bmi_ugrid.py index e64ed8a4..4d5f89dc 100644 --- a/tests/framework/test_bmi_ugrid.py +++ b/tests/framework/test_bmi_ugrid.py @@ -1,4 +1,5 @@ """Unit tests for the pymt.framwork.bmi_ugrid module.""" + import numpy as np import xarray as xr @@ -78,8 +79,8 @@ def test_points_grid(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 2 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray class BmiUnstructured(BmiPoints): @@ -105,8 +106,8 @@ def test_unstructured_grid(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 2 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray class BmiStructuredQuadrilateral: @@ -137,8 +138,8 @@ def test_structured_quadrilateral_grid(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 2 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray class BmiRectilinear: @@ -170,8 +171,8 @@ def test_rectilinear_grid(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 2 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray class BmiRectilinear3D: @@ -207,8 +208,8 @@ def test_rectilinear_grid_3d(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 3 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray assert len(grid.data_vars["node_x"].data) == np.prod(bmi.grid_shape(grid_id)) @@ -241,5 +242,5 @@ def test_uniform_rectilinear_grid(): assert isinstance(grid, xr.Dataset) assert grid.ndim == 2 assert grid.metadata["type"] == bmi.grid_type(grid_id) - assert grid.data_vars["mesh"].attrs["type"] == bmi.grid_type(grid_id) - assert type(grid.data_vars["node_x"].data) == np.ndarray + assert grid.data_vars["mesh"].attrs["type"] is bmi.grid_type(grid_id) + assert type(grid.data_vars["node_x"].data) is np.ndarray diff --git a/tests/portprinter/test_port_printer_queue.py b/tests/portprinter/test_port_printer_queue.py index d53339d2..ebda4321 100644 --- a/tests/portprinter/test_port_printer_queue.py +++ b/tests/portprinter/test_port_printer_queue.py @@ -48,9 +48,9 @@ def test_multiple_printers(tmpdir, with_two_components): assert os.path.isfile("air__density.nc") ds = xarray.open_dataset("air__density.nc", engine="h5netcdf") assert "air__density" in ds.variables - assert ds.dims["time"] == 5 + assert ds.sizes["time"] == 5 assert os.path.isfile("glacier_top_surface__slope.nc") ds = xarray.open_dataset("glacier_top_surface__slope.nc", engine="h5netcdf") assert "glacier_top_surface__slope" in ds.variables - assert ds.dims["time"] == 5 + assert ds.sizes["time"] == 5 diff --git a/tests/printers/nc/test_database.py b/tests/printers/nc/test_database.py index 5575f7ea..717d55b6 100644 --- a/tests/printers/nc/test_database.py +++ b/tests/printers/nc/test_database.py @@ -46,9 +46,9 @@ def test_2d_constant_shape(tmpdir): assert set(root.dims) == {"y", "x", "time"} assert set(root.data_vars) == {"mesh", "Elevation"} - assert root.dims["x"] == 3 - assert root.dims["y"] == 2 - assert root.dims["time"] == 2 + assert root.sizes["x"] == 3 + assert root.sizes["y"] == 2 + assert root.sizes["time"] == 2 assert root.variables["Elevation"].shape == (2, 2, 3) @@ -105,9 +105,9 @@ def test_2d_changing_shape(tmpdir): assert set(root.dims) == {"y", "x", "time"} assert set(root.data_vars) == {"mesh", "Temperature"} - assert root.dims["x"] == 3 - assert root.dims["y"] == 3 - assert root.dims["time"] == 1 + assert root.sizes["x"] == 3 + assert root.sizes["y"] == 3 + assert root.sizes["time"] == 1 assert root.data_vars["Temperature"].shape == (1, 3, 3) assert root.data_vars["Temperature"][0].data == approx(