def test_sequence(self): """Test that dataset has the correct data proxies for sequences.""" dataset = DAPHandler("http://localhost:8001/", self.app2).dataset self.assertEqual(list(dataset.keys()), ["cast"]) self.assertEqual( list(dataset.cast.keys()), [ 'id', 'lon', 'lat', 'depth', 'time', 'temperature', 'salinity', 'pressure']) # check the sequence self.assertIsInstance(dataset.cast.data, SequenceProxy) self.assertEqual( dataset.cast.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.cast.data.id, "cast") self.assertEqual(dataset.cast.data.shape, ()) self.assertEqual(dataset.cast.data.selection, []) self.assertEqual(dataset.cast.data.slice, (slice(None),)) # check a child self.assertIsInstance(dataset.cast.lon.data, SequenceProxy) self.assertEqual( dataset.cast.lon.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.cast.lon.data.id, "cast.lon") self.assertEqual(dataset.cast.lon.data.shape, ()) self.assertEqual(dataset.cast.lon.data.dtype, np.dtype(">i4")) self.assertEqual(dataset.cast.lon.data.selection, []) self.assertEqual(dataset.cast.lon.data.slice, (slice(None),))
def test_grid_gzip(self): """Test that dataset has the correct data proxies for grids.""" dataset = DAPHandler("http://localhost:8001/", self.app3).dataset self.assertEqual(list(dataset.keys()), ["SimpleGrid", "x", "y"]) self.assertEqual( list(dataset.SimpleGrid.keys()), ["SimpleGrid", "x", "y"]) # test one of the axis self.assertIsInstance(dataset.SimpleGrid.x.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.x.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.x.data.id, "SimpleGrid.x") self.assertEqual(dataset.SimpleGrid.x.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.x.data.shape, (3,)) self.assertEqual( dataset.SimpleGrid.x.data.slice, (slice(None),)) # test the grid self.assertIsInstance(dataset.SimpleGrid.SimpleGrid.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.baseurl, "http://localhost:8001/") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.id, "SimpleGrid.SimpleGrid") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (2, 3)) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.slice, (slice(None), slice(None))) self.assertEqual( repr(dataset.SimpleGrid[:]), "<GridType with array 'SimpleGrid' and maps 'x', 'y'>")
def test_grid_output_grid_false(self): """Test that dataset has the correct data proxies for grids with option output_grid set to False.""" dataset = DAPHandler("http://localhost:8001/", self.app1, output_grid=False).dataset self.assertEqual(list(dataset.keys()), ["SimpleGrid", "x", "y"]) self.assertEqual( list(dataset.SimpleGrid.keys()), ["SimpleGrid", "x", "y"]) # test one of the axis self.assertIsInstance(dataset.SimpleGrid.x.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.x.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.x.data.id, "SimpleGrid.x") self.assertEqual(dataset.SimpleGrid.x.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.x.data.shape, (3,)) self.assertEqual( dataset.SimpleGrid.x.data.slice, (slice(None),)) # test the grid self.assertIsInstance(dataset.SimpleGrid.SimpleGrid.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.baseurl, "http://localhost:8001/") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.id, "SimpleGrid.SimpleGrid") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (2, 3)) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.slice, (slice(None), slice(None))) np.testing.assert_array_equal(dataset.SimpleGrid[:], [[0, 1, 2], [3, 4, 5]])
def test_grid_output_grid_false(self): """Test that dataset has the correct data proxies for grids with option output_grid set to False.""" dataset = DAPHandler("http://localhost:8001/", self.app1, output_grid=False).dataset self.assertEqual(dataset.keys(), ["SimpleGrid", "x", "y"]) self.assertEqual(dataset.SimpleGrid.keys(), ["SimpleGrid", "x", "y"]) # test one of the axis self.assertIsInstance(dataset.SimpleGrid.x.data, BaseProxy) self.assertEqual(dataset.SimpleGrid.x.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.x.data.id, "SimpleGrid.x") self.assertEqual(dataset.SimpleGrid.x.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.x.data.shape, (3, )) self.assertEqual(dataset.SimpleGrid.x.data.slice, (slice(None), )) # test the grid self.assertIsInstance(dataset.SimpleGrid.SimpleGrid.data, BaseProxy) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.id, "SimpleGrid.SimpleGrid") self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (2, 3)) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.slice, (slice(None), slice(None))) np.testing.assert_array_equal(dataset.SimpleGrid[:], [[0, 1, 2], [3, 4, 5]])
def test_grid(self): """Test that dataset has the correct data proxies for grids.""" dataset = DAPHandler("http://localhost:8001/", self.app1).dataset self.assertEqual(dataset.keys(), ["SimpleGrid", "x", "y"]) self.assertEqual(dataset.SimpleGrid.keys(), ["SimpleGrid", "x", "y"]) # test one of the axis self.assertIsInstance(dataset.SimpleGrid.x.data, BaseProxy) self.assertEqual(dataset.SimpleGrid.x.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.x.data.id, "SimpleGrid.x") self.assertEqual(dataset.SimpleGrid.x.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.x.data.shape, (3, )) self.assertEqual(dataset.SimpleGrid.x.data.slice, (slice(None), )) # test the grid self.assertIsInstance(dataset.SimpleGrid.SimpleGrid.data, BaseProxy) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.id, "SimpleGrid.SimpleGrid") self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (2, 3)) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.slice, (slice(None), slice(None))) self.assertEqual( repr(dataset.SimpleGrid[:]), "<GridType with array 'SimpleGrid' and maps 'x', 'y'>")
def test_sequence(self): """Test that dataset has the correct data proxies for sequences.""" dataset = DAPHandler("http://localhost:8001/", self.app2).dataset self.assertEqual(dataset.keys(), ["cast"]) self.assertEqual(dataset.cast.keys(), [ 'id', 'lon', 'lat', 'depth', 'time', 'temperature', 'salinity', 'pressure' ]) # check the sequence self.assertIsInstance(dataset.cast.data, SequenceProxy) self.assertEqual(dataset.cast.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.cast.data.id, "cast") self.assertEqual(dataset.cast.data.shape, ()) self.assertEqual(dataset.cast.data.selection, []) self.assertEqual(dataset.cast.data.slice, (slice(None), )) # check a child self.assertIsInstance(dataset.cast.lon.data, SequenceProxy) self.assertEqual(dataset.cast.lon.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.cast.lon.data.id, "cast.lon") self.assertEqual(dataset.cast.lon.data.shape, ()) self.assertEqual(dataset.cast.lon.data.dtype, np.dtype(">i4")) self.assertEqual(dataset.cast.lon.data.selection, []) self.assertEqual(dataset.cast.lon.data.slice, (slice(None), ))
def test_grid(self): """Test that dataset has the correct data proxies for grids.""" dataset = DAPHandler("http://localhost:8001/", self.app1).dataset self.assertEqual(dataset.keys(), ["SimpleGrid", "x", "y"]) self.assertEqual( dataset.SimpleGrid.keys(), ["SimpleGrid", "x", "y"]) # test one of the axis self.assertIsInstance(dataset.SimpleGrid.x.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.x.data.baseurl, "http://localhost:8001/") self.assertEqual(dataset.SimpleGrid.x.data.id, "SimpleGrid.x") self.assertEqual(dataset.SimpleGrid.x.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.x.data.shape, (3,)) self.assertEqual( dataset.SimpleGrid.x.data.slice, (slice(None),)) # test the grid self.assertIsInstance(dataset.SimpleGrid.SimpleGrid.data, BaseProxy) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.baseurl, "http://localhost:8001/") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.id, "SimpleGrid.SimpleGrid") self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.dtype, np.dtype('>i4')) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (2, 3)) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.slice, (slice(None), slice(None)))
def test_grid_array_with_projection(self): """Test that a grid array can be properly pre sliced.""" dataset = DAPHandler("http://localhost:8001/?SimpleGrid.SimpleGrid[0]", self.app1).dataset # object should be a structure, not a grid self.assertEqual(dataset.keys(), ["SimpleGrid"]) self.assertNotIsInstance(dataset.SimpleGrid, GridType) self.assertIsInstance(dataset.SimpleGrid, StructureType) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (1, 3)) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.slice, (slice(0, 1, 1), slice(0, 3, 1)))
def test_grid_array_with_projection(self): """Test that a grid array can be properly pre sliced.""" dataset = DAPHandler( "http://localhost:8001/?SimpleGrid.SimpleGrid[0]", self.app1).dataset # object should be a structure, not a grid self.assertEqual(list(dataset.keys()), ["SimpleGrid"]) self.assertNotIsInstance(dataset.SimpleGrid, GridType) self.assertIsInstance(dataset.SimpleGrid, StructureType) self.assertEqual(dataset.SimpleGrid.SimpleGrid.data.shape, (1, 3)) self.assertEqual( dataset.SimpleGrid.SimpleGrid.data.slice, (slice(0, 1, 1), slice(0, 3, 1)))