Esempio n. 1
0
    def test_empty(self):
        a = create_data_array(self.coords, data=None)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == float

        a = create_data_array(self.coords, data=None, dtype=bool)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == bool
Esempio n. 2
0
    def test_array(self):
        data = np.random.random(self.coords.shape)
        a = create_data_array(self.coords, data=data)
        assert isinstance(a, UnitsDataArray)
        assert a.dtype == float
        np.testing.assert_equal(a.data, data)

        data = np.round(10 * np.random.random(self.coords.shape))
        a = create_data_array(self.coords, data=data, dtype=int)
        assert isinstance(a, UnitsDataArray)
        assert a.dtype == int
        np.testing.assert_equal(a.data, data.astype(int))
Esempio n. 3
0
    def test_full(self):
        a = create_data_array(self.coords, data=10)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == float
        assert np.all(a == 10)

        a = create_data_array(self.coords, data=10, dtype=int)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == int
        assert np.all(a == 10)
Esempio n. 4
0
    def test_ones(self):
        a = create_data_array(self.coords, data=1)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == float
        assert np.all(a == 1.0)

        a = create_data_array(self.coords, data=1, dtype=bool)
        assert isinstance(a, UnitsDataArray)
        assert a.shape == self.coords.shape
        assert a.dtype == bool
        assert np.all(a)
Esempio n. 5
0
    def create_output_array(self, coords, data=np.nan, **kwargs):
        """
        Initialize an output data array

        Parameters
        ----------
        coords : podpac.Coordinates
            {arr_coords}
        data : None, number, or array-like (optional)
            {arr_init_type}
        **kwargs
            {arr_kwargs}

        Returns
        -------
        {arr_return}
        """

        attrs = {'layer_style': self.style, 'units': self.units}
        return create_data_array(coords,
                                 data=data,
                                 dtype=self.dtype,
                                 attrs=attrs,
                                 **kwargs)
Esempio n. 6
0
 def test_invalid_coords(self):
     with pytest.raises(TypeError):
         create_data_array((3, 4))
Esempio n. 7
0
 def test_default(self):
     a = create_data_array(self.coords)
     assert isinstance(a, UnitsDataArray)
     assert a.shape == self.coords.shape
     assert np.all(np.isnan(a))