def test_array_slice(self): """Test slices applied to a grid.""" dataset = apply_projection(parse_projection("SimpleGrid[1]"), self.dataset) np.testing.assert_array_equal(dataset.SimpleGrid.x.data, self.dataset.SimpleGrid[1].x.data) np.testing.assert_array_equal(dataset.SimpleGrid.y.data, self.dataset.SimpleGrid[1].y.data) np.testing.assert_array_equal( dataset.SimpleGrid.SimpleGrid.data, self.dataset.SimpleGrid[1:2].SimpleGrid.data)
def test_array_slice(self): """Test slices applied to a grid.""" dataset = apply_projection( parse_projection("SimpleGrid[1]"), self.dataset) np.testing.assert_array_equal( dataset.SimpleGrid.x.data, self.dataset.SimpleGrid[1].x.data) np.testing.assert_array_equal( dataset.SimpleGrid.y.data, self.dataset.SimpleGrid[1].y.data) np.testing.assert_array_equal( dataset.SimpleGrid.SimpleGrid.data, self.dataset.SimpleGrid[1:2].SimpleGrid.data)
def test_structure_projection(self): """Test projection slicing on a structure.""" with self.assertRaises(ConstraintExpressionError): apply_projection(parse_projection("types[0]"), SimpleStructure)
def test_sequence_projection(self): """Test projection slicing on sequences.""" dataset = apply_projection(parse_projection("sequence[2]"), self.dataset) np.testing.assert_array_equal(dataset.sequence.data, VerySimpleSequence.sequence.data[2])
def test_array(self): """Test that the grid degenerates into a structure.""" dataset = apply_projection(parse_projection("SimpleGrid.SimpleGrid"), self.dataset) self.assertIsInstance(dataset.SimpleGrid, StructureType)
def test_simple_projection_with_index(self): """Test simple projections.""" dataset = apply_projection(parse_projection("x[1]"), self.dataset) np.testing.assert_array_equal(dataset.x.data, [1])
def test_simple_projection_with_index(self): """Test simple projections.""" dataset = apply_projection(parse_projection("x[1]"), self.dataset) np.testing.assert_array_equal( dataset.x.data, [1])
def test_hyperslab(self): """Test a projection with a hyperslab.""" parsed = parse_projection("a,b.c[0:2:9]") self.assertEqual( parsed, [[("a", ())], [("b", ()), ("c", (slice(0, 10, 2),))]])
def test_hyperslab(self): """Test a projection with a hyperslab.""" parsed = parse_projection("a,b.c[0:2:9]") self.assertEqual(parsed, [[("a", ())], [("b", ()), ("c", (slice(0, 10, 2),))]])
def test_deep(self): """Test a projection with a deep id.""" parsed = parse_projection("a.b.c,d") self.assertEqual(parsed, [[("a", ()), ("b", ()), ("c", ())], [("d", ())]])
def test_basic(self): """Test a basic projection.""" parsed = parse_projection("a,b,c") self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
def test_sequence_projection(self): """Test projection slicing on sequences.""" dataset = apply_projection( parse_projection("sequence[2]"), self.dataset) np.testing.assert_array_equal( dataset.sequence.data, VerySimpleSequence.sequence.data[2])
def test_array(self): """Test that the grid degenerates into a structure.""" dataset = apply_projection( parse_projection("SimpleGrid.SimpleGrid"), self.dataset) self.assertIsInstance(dataset.SimpleGrid, StructureType)
def test_nested_function_call(self): """Test a projection with a function call.""" parsed = parse_projection("mean(mean(a[0],1))") self.assertEqual(parsed, ["mean(mean(a[0],1))"])
def test_deep(self): """Test a projection with a deep id.""" parsed = parse_projection("a.b.c,d") self.assertEqual( parsed, [[("a", ()), ("b", ()), ("c", ())], [("d", ())]])
def test_simple_projection(self): """Test simple projections.""" dataset = apply_projection(parse_projection("x"), self.dataset) self.assertEqual(list(dataset.keys()), ["x"])
def test_nested_function_call(self): """Test a projection with a function call.""" parsed = parse_projection("mean(mean(a[0],1))") self.assertEqual( parsed, ['mean(mean(a[0],1))'])