def test(self): class MyClass(tl.HasTraits): node = NodeTrait() t = MyClass(node=podpac.Node()) with pytest.raises(tl.TraitError): MyClass(node=0)
def test_debug(self): class MyClass(tl.HasTraits): node = NodeTrait() node = podpac.Node() with podpac.settings: podpac.settings["DEBUG"] = False t = MyClass(node=node) assert t.node is node podpac.settings["DEBUG"] = True t = MyClass(node=node) assert t.node is not node
def test_array_node(self): a = np.array([podpac.Node(), podpac.Node()]) json.dumps(a, cls=JSONEncoder)
def test_node(self): node = podpac.Node() json.dumps(node, cls=JSONEncoder)
def test_coordinates_floating_point_consistency(self): c = podpac.Coordinates.from_url( "?VERSION=1.3.0&HEIGHT=512&WIDTH=512&CRS=EPSG%3A3857&BBOX=-8061966.247294108,5322463.153553393,-7983694.730330088,5400734.670517412" ).transform("EPSG:4326") u = c["lon"] u2 = podpac.coordinates.UniformCoordinates1d( u.start - 2 * u.step, u.stop + 2 * u.step + 1e-14, step=u.step, fix_stop_val=True ) u3 = podpac.coordinates.UniformCoordinates1d( u.start - 2 * u.step, u.stop + 2 * u.step + 1e-14, size=u.size + 4, fix_stop_val=True ) assert u2.start == u3.start assert u2.stop == u3.stop step = (u2.stop - u2.start) / (u2.size - 1) assert u2.step == step assert u3.step == step assert_equal(u2.coordinates, u3.coordinates) # Lat has a different order (i.e negative step) u = c["lat"] step = (u.coordinates[-1] - u.coordinates[0]) / (u.size - 1) start = u.coordinates[0] stop = u.coordinates[-1] u2 = podpac.coordinates.UniformCoordinates1d( start - 2 * step, stop + 2 * step + 1e-14, step=step, fix_stop_val=True ) u3 = podpac.coordinates.UniformCoordinates1d( start - 2 * step, stop + 2 * step + 1e-14, size=u.size + 4, fix_stop_val=True ) assert u2.start == u3.start assert u2.stop == u3.stop step = (u2.stop - u2.start) / (u2.size - 1) assert u2.step == step assert u3.step == step assert_equal(u2.coordinates, u3.coordinates) # Need to make sure time data still works u2 = podpac.coordinates.UniformCoordinates1d("2000-01-01", "2000-01-31", step="23,h") u3 = podpac.coordinates.UniformCoordinates1d( "2000-01-01T00", "2000-01-30T17", size=u2.size ) # Won't allow me to specify something inconsistent... assert u2.start == u3.start assert u2.stop == u3.stop step = (u2.stop - u2.start) / (u2.size - 1) assert u2.step == step assert u3.step == step assert_equal(u2.coordinates, u3.coordinates) # Now check consistency without the `fix_stop_val` flag u = c["lon"] u2 = podpac.coordinates.UniformCoordinates1d(u.start - 2 * u.step, u.stop + 2 * u.step + 1e-14, step=u.step) c3 = podpac.Coordinates([u2], ["lon"]) n = podpac.Node().create_output_array(podpac.Coordinates([u2], ["lon"])) u2b = podpac.Coordinates.from_xarray(n) assert_equal(u2b["lon"].coordinates, u2.coordinates) u2 = podpac.coordinates.UniformCoordinates1d(u.start - 2 * u.step, u.stop + 2 * u.step + 1e-14, size=u.size + 4) n = podpac.Node().create_output_array(podpac.Coordinates([u2], ["lon"])) u2b = podpac.Coordinates.from_xarray(n) assert_equal(u2b["lon"].coordinates, u2.coordinates)