Exemplo n.º 1
0
 def test_get_data(self):
     """test get data from reprojected source"""
     source = Array(source=self.data, coordinates=self.coordinates)
     with pytest.warns(DeprecationWarning):
         node = ReprojectedSource(
             source=source, reprojected_coordinates=source.coordinates)
     output = node.eval(node.coordinates)
Exemplo n.º 2
0
    def test_source_interpolation(self):
        """test get data from reprojected source"""

        # no source_interpolation
        source = Array(source=self.data,
                       coordinates=self.coordinates,
                       interpolation="nearest")
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=source,
                reprojected_coordinates=self.reprojected_coordinates)
        assert source.interpolation == "nearest"
        assert node.source.interpolation == "nearest"
        assert node.eval_source.interpolation == "nearest"
        assert node.eval_source.coordinates == source.coordinates
        np.testing.assert_array_equal(node.eval_source.source, source.source)

        # matching source_interpolation
        source = Array(source=self.data,
                       coordinates=self.coordinates,
                       interpolation="nearest")
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=source,
                reprojected_coordinates=self.reprojected_coordinates,
                source_interpolation="nearest")
        assert source.interpolation == "nearest"
        assert node.source.interpolation == "nearest"
        assert node.eval_source.interpolation == "nearest"
        assert node.eval_source.coordinates == source.coordinates
        np.testing.assert_array_equal(node.eval_source.source, source.source)

        # non-matching source_interpolation
        source = Array(source=self.data,
                       coordinates=self.coordinates,
                       interpolation="nearest")
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=source,
                reprojected_coordinates=self.reprojected_coordinates,
                source_interpolation="bilinear")
        assert source.interpolation == "nearest"
        assert node.source.interpolation == "nearest"
        assert node.eval_source.interpolation == "bilinear"
        assert node.eval_source.coordinates == source.coordinates
        np.testing.assert_array_equal(node.eval_source.source, source.source)

        # no source.interpolation to set (trigger logger warning)
        source = Node()
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=source,
                reprojected_coordinates=self.reprojected_coordinates,
                source_interpolation="bilinear")
Exemplo n.º 3
0
    def test_deserialize_reprojected_coordinates(self):
        node1 = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates)
        node2 = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates.definition)
        node3 = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates.json)

        assert node1.reprojected_coordinates == self.reprojected_coordinates
        assert node2.reprojected_coordinates == self.reprojected_coordinates
        assert node3.reprojected_coordinates == self.reprojected_coordinates
Exemplo n.º 4
0
    def test_coordinates(self):
        """test coordinates"""

        # source has no coordinates, just use reprojected_coordinates
        node = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates)
        assert node.coordinates == self.reprojected_coordinates

        # source has coordinates
        source = Array(coordinates=self.coordinates)
        node = ReprojectedSource(
            source=source,
            reprojected_coordinates=self.reprojected_coordinates)
        assert node.coordinates == self.reprojected_coordinates
Exemplo n.º 5
0
    def test_init(self):
        """test basic init of class"""

        node = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates)
        assert isinstance(node, ReprojectedSource)
Exemplo n.º 6
0
    def test_base_ref(self):
        """test base ref"""

        node = ReprojectedSource(
            source=Node(),
            reprojected_coordinates=self.reprojected_coordinates)
        assert "_reprojected" in node.base_ref
Exemplo n.º 7
0
    def test_coordinates(self):
        """test coordinates"""

        # source has no coordinates, just use reprojected_coordinates
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=Node(),
                reprojected_coordinates=self.reprojected_coordinates)
        assert node.coordinates == self.reprojected_coordinates

        # source has coordinates
        source = Array(coordinates=self.coordinates)
        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=source,
                reprojected_coordinates=self.reprojected_coordinates)
        assert node.coordinates == self.reprojected_coordinates
Exemplo n.º 8
0
    def test_init(self):
        """test basic init of class"""

        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=Node(),
                reprojected_coordinates=self.reprojected_coordinates)
        assert isinstance(node, ReprojectedSource)
Exemplo n.º 9
0
    def test_deserialize_reprojected_coordinates(self):
        with pytest.warns(DeprecationWarning):
            node1 = ReprojectedSource(
                source=Node(),
                reprojected_coordinates=self.reprojected_coordinates)
        with pytest.warns(DeprecationWarning):
            node2 = ReprojectedSource(source=Node(),
                                      reprojected_coordinates=self.
                                      reprojected_coordinates.definition)
        with pytest.warns(DeprecationWarning):
            node3 = ReprojectedSource(
                source=Node(),
                reprojected_coordinates=self.reprojected_coordinates.json)

        assert node1.reprojected_coordinates == self.reprojected_coordinates
        assert node2.reprojected_coordinates == self.reprojected_coordinates
        assert node3.reprojected_coordinates == self.reprojected_coordinates
Exemplo n.º 10
0
    def test_base_ref(self):
        """test base ref"""

        with pytest.warns(DeprecationWarning):
            node = ReprojectedSource(
                source=Node(),
                reprojected_coordinates=self.reprojected_coordinates)
        assert "_reprojected" in node.base_ref
Exemplo n.º 11
0
 def test_get_data(self):
     """test get data from reprojected source"""
     source = Array(source=self.data, coordinates=self.coordinates)
     node = ReprojectedSource(source=source,
                              reprojected_coordinates=source.coordinates)
     output = node.eval(node.coordinates)
Exemplo n.º 12
0
 def test_interpolation_warning(self):
     node = ReprojectedSource(source=Arange(),
                              reprojected_coordinates=self.coordinates)
     output = node.eval(node.coordinates)