Ejemplo n.º 1
0
 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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 def test_structure_projection(self):
     """Test projection slicing on a structure."""
     with self.assertRaises(ConstraintExpressionError):
         apply_projection(parse_projection("types[0]"), SimpleStructure)
Ejemplo n.º 4
0
 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])
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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])
Ejemplo n.º 7
0
 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])
Ejemplo n.º 8
0
 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),))]])
Ejemplo n.º 9
0
 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),))]])
Ejemplo n.º 10
0
 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", ())]])
Ejemplo n.º 11
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
Ejemplo n.º 12
0
 def test_structure_projection(self):
     """Test projection slicing on a structure."""
     with self.assertRaises(ConstraintExpressionError):
         apply_projection(parse_projection("types[0]"), SimpleStructure)
Ejemplo n.º 13
0
 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])
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
Ejemplo n.º 16
0
 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))"])
Ejemplo n.º 17
0
 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", ())]])
Ejemplo n.º 18
0
 def test_simple_projection(self):
     """Test simple projections."""
     dataset = apply_projection(parse_projection("x"), self.dataset)
     self.assertEqual(list(dataset.keys()), ["x"])
Ejemplo n.º 19
0
 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))'])
Ejemplo n.º 20
0
 def test_simple_projection(self):
     """Test simple projections."""
     dataset = apply_projection(parse_projection("x"), self.dataset)
     self.assertEqual(list(dataset.keys()), ["x"])