Ejemplo n.º 1
0
    def test_equality_empty(self):
        """Check the equality of two empty GriddedField objects."""
        # Create two different objects with same content.
        a = griddedfield.GriddedField3()
        b = griddedfield.GriddedField3()

        assert a == b
Ejemplo n.º 2
0
 def test_check_dimension1(self):
     """Test if grid and data dimension agree (positive)."""
     gf3 = griddedfield.GriddedField3()
     gf3.grids = [np.arange(5), np.arange(5), []]
     gf3.gridnames = ["A", "B", "C"]
     gf3.data = np.ones((5, 5, 1))
     assert gf3.check_dimension() is True
Ejemplo n.º 3
0
 def test_check_dimension2(self):
     """Test if grid and data dimension agree (negative)."""
     gf3 = griddedfield.GriddedField3()
     gf3.grids = [np.arange(5), np.arange(5), []]
     gf3.gridnames = ["A", "B", "C"]
     gf3.data = np.ones((5, 5))
     gf3.check_dimension()
Ejemplo n.º 4
0
    def test_check_dimension2(self):
        """Test if grid and data dimension agree (negative)."""
        gf3 = griddedfield.GriddedField3()
        gf3.grids = [np.arange(5), np.arange(5), []]
        gf3.gridnames = ["A", "B", "C"]

        # It shold not be allowed to set a Matrix as data in a GriddedField3.
        with pytest.raises(TypeError):
            gf3.data = np.ones((5, 5))
Ejemplo n.º 5
0
 def test_data(self):
     """Test setting and getting of data. """
     reference = np.random.randn(10, 10, 10)
     gf3 = griddedfield.GriddedField3()
     gf3.data = reference
     assert np.array_equal(gf3.data, reference)