Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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])
Esempio 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)
Esempio 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])
Esempio 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])
Esempio 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),))]])
Esempio 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),))]])
Esempio 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", ())]])
Esempio n. 11
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
Esempio 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)
Esempio 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])
Esempio 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)
Esempio n. 15
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
Esempio 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))"])
Esempio 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", ())]])
Esempio 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"])
Esempio 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))'])
Esempio 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"])