예제 #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
예제 #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
예제 #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()
예제 #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))
예제 #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)