示例#1
0
 def test_result(self):
     out = hs_core(self.f, 1, 10, 4, (0, 0, 0, 0), 10)
     self.assertEqual(out.dim, 4, "Should report 4")
     self.assertEqual(len(out.x_grid), len(out.y_grid),
                      "X grid and Y grid must have the same length")
     self.assertEqual(len(out.x_grid), 10, "Mesh grids length must be 10")
     with self.assertRaises(AttributeError):
         print(out.__plot)
示例#2
0
 def test_json_fetch(self):
     out = hs_core(self.f, 1, 10, 4, (0, 0, 0, 0), 10)
     reload = json.loads(out.to_json())
     self.assertEqual(out.dim, reload['dim'])
     self.assertListEqual(list(out.x_grid[0]), reload['x_grid'][0])
     self.assertListEqual(list(out.y_grid[0]), reload['y_grid'][0])
     self.assertEqual(len(out.data(0, 0)), len(reload['entries']['0']['0']))
     self.assertListEqual(list(out.data(0, 0)[0]),
                          reload['entries']['0']['0'][0])
示例#3
0
 def test_data_fetch(self):
     out = hs_core(self.f, 1, 10, 4, (0, 0, 0, 0), 10)
     expected = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
     self.assertListEqual(out.data(0, 0)[0], expected)
     self.assertListEqual(out.data(0, 0)[1], expected)
     self.assertListEqual(out.data(0, 0)[2], expected)
     with self.assertRaises(IndexError):
         print(out.data(0, 0)[11])
     with self.assertRaises(Exception):
         out.data(4, 6)
     with self.assertRaises(Exception):
         out.data(-4, 6)
     with self.assertRaises(Exception):
         out.data(1, 2.2)
示例#4
0
 def test_dim_consistency(self):
     with self.assertRaises(Exception):
         hs_core(self.f, 0, 10, 4, (0, 0, 0), 10)
     with self.assertRaises(Exception):
         hs_core(self.f, 0, 10, -5, (0, 0, 0, 0), 10)
示例#5
0
 def test_min_max(self):
     with self.assertRaises(Exception):
         hs_core(self.f, 20, 10, 4, (0, 0, 0, 0), 10)