示例#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)
示例#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)
示例#3
0
 def test_structure_projection(self):
     """Test projection slicing on a structure."""
     with self.assertRaises(ConstraintExpressionError):
         apply_projection(parse_projection("types[0]"), SimpleStructure)
示例#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])
示例#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)
示例#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])
示例#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])
示例#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),))]])
示例#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),))]])
示例#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", ())]])
示例#11
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
示例#12
0
 def test_structure_projection(self):
     """Test projection slicing on a structure."""
     with self.assertRaises(ConstraintExpressionError):
         apply_projection(parse_projection("types[0]"), SimpleStructure)
示例#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])
示例#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)
示例#15
0
 def test_basic(self):
     """Test a basic projection."""
     parsed = parse_projection("a,b,c")
     self.assertEqual(parsed, [[("a", ())], [("b", ())], [("c", ())]])
示例#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))"])
示例#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", ())]])
示例#18
0
 def test_simple_projection(self):
     """Test simple projections."""
     dataset = apply_projection(parse_projection("x"), self.dataset)
     self.assertEqual(list(dataset.keys()), ["x"])
示例#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))'])
示例#20
0
 def test_simple_projection(self):
     """Test simple projections."""
     dataset = apply_projection(parse_projection("x"), self.dataset)
     self.assertEqual(list(dataset.keys()), ["x"])