def test_mask_defaults_bool_op(self): coords = podpac.Coordinates( [podpac.clinspace(0, 1, 4), podpac.clinspace(0, 1, 3)], dims=["lat", "lon"]) sine_node = Arange() a = sine_node.eval(coords).copy() # Less than node = Mask(source=sine_node, mask=sine_node, bool_op="<") output = node.eval(coords) b = a.copy() b.data[a.data < 1] = np.nan np.testing.assert_allclose(output, b) # Less than equal node = Mask(source=sine_node, mask=sine_node, bool_op="<=") output = node.eval(coords) b = a.copy() b.data[a.data <= 1] = np.nan np.testing.assert_allclose(output, b) # Greater than node = Mask(source=sine_node, mask=sine_node, bool_op=">") output = node.eval(coords) b = a.copy() b.data[a.data > 1] = np.nan np.testing.assert_allclose(output, b) # Greater than equal node = Mask(source=sine_node, mask=sine_node, bool_op=">=") output = node.eval(coords) b = a.copy() b.data[a.data >= 1] = np.nan np.testing.assert_allclose(output, b)
def test_f(self): coords = Coordinates([[1, 2, 3, 4, 5]], ["time"]) node = Arange() q = Queue() _f(node.json, coords.json, q, {}) o = q.get() np.testing.assert_array_equal(o, node.eval(coords))
def test_f_fmt(self): coords = Coordinates([[1, 2, 3, 4, 5]], ["time"]) node = Arange() q = Queue() _f(node.json, coords.json, q, {"format": "dict", "format_kwargs": {}}) o = q.get() np.testing.assert_array_equal(o["data"], node.eval(coords).to_dict()["data"])
def test_mp_results_the_same(self): coords = Coordinates([[1, 2, 3, 4, 5]], ["time"]) node = Arange() o_sp = node.eval(coords) node_mp = Process(source=node) o_mp = node_mp.eval(coords) np.testing.assert_array_equal(o_sp.data, o_mp.data)
def test_mp_results_the_same_set_output(self): coords = Coordinates([[1, 2, 3, 4, 5]], ["time"]) node = Arange() o_sp = node.eval(coords) output = o_sp.copy() output[:] = np.nan node_mp = Process(source=node) o_mp = node_mp.eval(coords, output=output) np.testing.assert_array_equal(o_sp, output)
def test_masked_val(self): coords = podpac.Coordinates( [podpac.clinspace(0, 1, 4), podpac.clinspace(0, 1, 3)], dims=["lat", "lon"]) sine_node = Arange() a = sine_node.eval(coords).copy() a.data[a.data == 1] = -9999 node = Mask(source=sine_node, mask=sine_node, masked_val=-9999) output = node.eval(coords) np.testing.assert_allclose(output, a)
def test_mask_defaults(self): coords = podpac.Coordinates( [podpac.crange(-90, 90, 1.0), podpac.crange(-180, 180, 1.0)], dims=["lat", "lon"]) sine_node = Arange() a = sine_node.eval(coords).copy() a.data[a.data == 1] = np.nan node = Mask(source=sine_node, mask=sine_node) output = node.eval(coords) np.testing.assert_allclose(output, a)
def test_in_place(self): coords = podpac.Coordinates( [podpac.clinspace(0, 1, 4), podpac.clinspace(0, 1, 3)], dims=["lat", "lon"]) sine_node = Arange() node = Mask(source=sine_node, mask=sine_node, in_place=True) output = node.eval(coords) a = sine_node.eval(coords) # In-place editing doesn't seem to work here # np.testing.assert_allclose(output, node.source._output) coords = podpac.Coordinates( [podpac.clinspace(0, 1, 4), podpac.clinspace(0, 2, 3)], dims=["lat", "lon"]) sine_node = Arange() node = Mask(source=sine_node, mask=sine_node, in_place=False) output = node.eval(coords) a = sine_node.eval(coords) assert not np.all(a == output)
def test_Arange(self): coords = podpac.Coordinates([[0, 1, 2], [0, 1, 2, 3, 4]], dims=["lat", "lon"]) node = Arange() output = node.eval(coords) assert output.shape == coords.shape
def get_data(self, coordinates, slc): node = Arange() return node.eval(coordinates)