Ejemplo n.º 1
0
    def test_lazyness(self):
        # Index coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_type_name, bounds_type_name) in \
                coords_all_dtypes_and_lazynesses(self, AuxCoord):

            sub_coord = main_coord[:2, 1]

            msg = ('Indexing coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed laziness of {} from {!r} to {!r}.')
            coord_dtype = main_coord.dtype
            sub_points_lazyness = lazyness_string(sub_coord.core_points())
            self.assertEqual(
                sub_points_lazyness, points_type_name,
                msg.format(coord_dtype, points_type_name, bounds_type_name,
                           'points', points_type_name, sub_points_lazyness))

            if bounds_type_name is not 'no':
                sub_bounds_lazy = lazyness_string(sub_coord.core_bounds())
                self.assertEqual(
                    sub_bounds_lazy, bounds_type_name,
                    msg.format(coord_dtype, points_type_name, bounds_type_name,
                               'bounds', bounds_type_name, sub_bounds_lazy))
Ejemplo n.º 2
0
    def test_lazyness(self):
        # Copy coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_lazyness, bounds_lazyness) in \
                coords_all_dtypes_and_lazynesses(self, AuxCoord):

            coord_dtype = main_coord.dtype
            copied_coord = main_coord.copy()

            msg = ('Copying main_coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed lazyness of {} from {!r} to {!r}.')

            copied_pts_lazyness = lazyness_string(copied_coord.core_points())
            self.assertEqual(
                copied_pts_lazyness, points_lazyness,
                msg.format(coord_dtype, points_lazyness, bounds_lazyness,
                           'points', points_lazyness, copied_pts_lazyness))

            if bounds_lazyness != 'no':
                copied_bds_lazy = lazyness_string(copied_coord.core_bounds())
                self.assertEqual(
                    copied_bds_lazy, bounds_lazyness,
                    msg.format(coord_dtype, points_lazyness, bounds_lazyness,
                               'bounds', bounds_lazyness, copied_bds_lazy))
Ejemplo n.º 3
0
    def test_lazyness(self):
        # Index coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_type_name, bounds_type_name) in \
                coords_all_dtypes_and_lazynesses(self, AuxCoord):

            sub_coord = main_coord[:2, 1]

            msg = ('Indexing coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed laziness of {} from {!r} to {!r}.')
            coord_dtype = main_coord.dtype
            sub_points_lazyness = lazyness_string(sub_coord.core_points())
            self.assertEqual(
                sub_points_lazyness, points_type_name,
                msg.format(coord_dtype,
                           points_type_name, bounds_type_name,
                           'points', points_type_name, sub_points_lazyness))

            if bounds_type_name is not 'no':
                sub_bounds_lazy = lazyness_string(sub_coord.core_bounds())
                self.assertEqual(
                    sub_bounds_lazy, bounds_type_name,
                    msg.format(coord_dtype,
                               points_type_name, bounds_type_name,
                               'bounds', bounds_type_name, sub_bounds_lazy))
Ejemplo n.º 4
0
    def test_lazyness(self):
        # Copy coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_lazyness, bounds_lazyness) in \
                coords_all_dtypes_and_lazynesses(self, AuxCoord):

            coord_dtype = main_coord.dtype
            copied_coord = main_coord.copy()

            msg = ('Copying main_coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed lazyness of {} from {!r} to {!r}.')

            copied_pts_lazyness = lazyness_string(copied_coord.core_points())
            self.assertEqual(copied_pts_lazyness, points_lazyness,
                             msg.format(coord_dtype,
                                        points_lazyness, bounds_lazyness,
                                        'points',
                                        points_lazyness, copied_pts_lazyness))

            if bounds_lazyness != 'no':
                copied_bds_lazy = lazyness_string(copied_coord.core_bounds())
                self.assertEqual(copied_bds_lazy, bounds_lazyness,
                                 msg.format(coord_dtype,
                                            points_lazyness, bounds_lazyness,
                                            'bounds',
                                            bounds_lazyness, copied_bds_lazy))
Ejemplo n.º 5
0
    def test_lazyness(self):
        # Index coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_type_name, bounds_type_name) in \
                coords_all_dtypes_and_lazynesses(self, DimCoord):
            # N.B. 'points_type_name' and 'bounds_type_name' in the iteration
            # are the original types (lazy/real/none) of the points+bounds,
            # but the DimCoord itself only ever has real data.
            if points_type_name == 'lazy':
                points_type_name = 'real'
            if bounds_type_name == 'lazy':
                bounds_type_name = 'real'

            sub_coord = main_coord[:2]

            msg = ('Indexing coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed "lazyness" of {} from {!r} to {!r}.')
            coord_dtype = main_coord.dtype
            sub_points_lazyness = lazyness_string(sub_coord.core_points())
            self.assertEqual(
                sub_points_lazyness, points_type_name,
                msg.format(coord_dtype, points_type_name, bounds_type_name,
                           'points', points_type_name, sub_points_lazyness))

            if bounds_type_name is not 'no':
                sub_bounds_lazy = lazyness_string(sub_coord.core_bounds())
                self.assertEqual(
                    sub_bounds_lazy, bounds_type_name,
                    msg.format(coord_dtype, points_type_name, bounds_type_name,
                               'bounds', bounds_type_name, sub_bounds_lazy))
Ejemplo n.º 6
0
    def test_lazyness(self):
        # Index coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_coord, points_type_name, bounds_type_name) in \
                coords_all_dtypes_and_lazynesses(self, DimCoord):
            # N.B. 'points_type_name' and 'bounds_type_name' in the iteration
            # are the original types (lazy/real/none) of the points+bounds,
            # but the DimCoord itself only ever has real data.
            if points_type_name == 'lazy':
                points_type_name = 'real'
            if bounds_type_name == 'lazy':
                bounds_type_name = 'real'

            sub_coord = main_coord[:2]

            msg = ('Indexing coord of dtype {} '
                   'with {} points and {} bounds '
                   'changed "lazyness" of {} from {!r} to {!r}.')
            coord_dtype = main_coord.dtype
            sub_points_lazyness = lazyness_string(sub_coord.core_points())
            self.assertEqual(
                sub_points_lazyness, points_type_name,
                msg.format(coord_dtype,
                           points_type_name, bounds_type_name,
                           'points', points_type_name, sub_points_lazyness))

            if bounds_type_name is not 'no':
                sub_bounds_lazy = lazyness_string(sub_coord.core_bounds())
                self.assertEqual(
                    sub_bounds_lazy, bounds_type_name,
                    msg.format(coord_dtype,
                               points_type_name, bounds_type_name,
                               'bounds', bounds_type_name, sub_bounds_lazy))
Ejemplo n.º 7
0
    def test_lazyness(self):
        # Copy ancillary variables with real+lazy data, and either an int or
        # floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_ancill_var, data_lazyness) in data_all_dtypes_and_lazynesses(
            self
        ):

            ancill_var_dtype = main_ancill_var.dtype
            copied_ancill_var = main_ancill_var.copy()

            msg = (
                "Copying main_ancill_var of dtype {} with {} data "
                "changed lazyness of {} from {!r} to {!r}."
            )

            copied_data_lazyness = lazyness_string(
                copied_ancill_var.core_data()
            )
            self.assertEqual(
                copied_data_lazyness,
                data_lazyness,
                msg.format(
                    ancill_var_dtype,
                    data_lazyness,
                    "points",
                    data_lazyness,
                    copied_data_lazyness,
                ),
            )
Ejemplo n.º 8
0
    def test_lazyness(self):
        # Index ancillary variables with real+lazy data, and either an int or
        # floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (main_ancill_var, data_lazyness) in data_all_dtypes_and_lazynesses(
            self
        ):

            sub_ancill_var = main_ancill_var[:2, 1]

            msg = (
                "Indexing main_ancill_var of dtype {} with {} data "
                "changed laziness of {} from {!r} to {!r}."
            )
            ancill_var_dtype = main_ancill_var.dtype
            sub_data_lazyness = lazyness_string(sub_ancill_var.core_data())
            self.assertEqual(
                sub_data_lazyness,
                data_lazyness,
                msg.format(
                    ancill_var_dtype,
                    data_lazyness,
                    "data",
                    data_lazyness,
                    sub_data_lazyness,
                ),
            )
Ejemplo n.º 9
0
    def test_lazyness(self):
        # Index coords with all combinations of real+lazy points+bounds, and
        # either an int or floating dtype.
        # Check that lazy data stays lazy and real stays real, in all cases.
        for (
            main_coord,
            points_type_name,
            bounds_type_name,
        ) in coords_all_dtypes_and_lazynesses(self, AuxCoord):

            sub_coord = main_coord[:2, 1]

            msg = (
                "Indexing coord of dtype {} "
                "with {} points and {} bounds "
                "changed laziness of {} from {!r} to {!r}."
            )
            coord_dtype = main_coord.dtype
            sub_points_lazyness = lazyness_string(sub_coord.core_points())
            self.assertEqual(
                sub_points_lazyness,
                points_type_name,
                msg.format(
                    coord_dtype,
                    points_type_name,
                    bounds_type_name,
                    "points",
                    points_type_name,
                    sub_points_lazyness,
                ),
            )

            if bounds_type_name != "no":
                sub_bounds_lazy = lazyness_string(sub_coord.core_bounds())
                self.assertEqual(
                    sub_bounds_lazy,
                    bounds_type_name,
                    msg.format(
                        coord_dtype,
                        points_type_name,
                        bounds_type_name,
                        "bounds",
                        bounds_type_name,
                        sub_bounds_lazy,
                    ),
                )