Exemplo n.º 1
0
 def test_linspace__invalid_num_points(self):
     """ Test TimeSpan.linspace with invalid num_points. """
     test_values = ["5", 0, -1, -2, -5, -10, 4.5, [40]]
     for test_val in test_values:
         with self.subTest(num_points=test_val):
             with self.assertRaises(TimespanError):
                 tspan = TimeSpan.linspace(t=30, num_points=test_val)
Exemplo n.º 2
0
 def test_linspace__invalid_t(self):
     """ Test TimeSpan.linspace with invalid t. """
     test_values = [None, "5", 0, -0.5, -1, -2, -5, -10, [20.5]]
     for test_val in test_values:
         with self.subTest(t=test_val):
             with self.assertRaises(TimespanError):
                 tspan = TimeSpan.linspace(t=test_val, num_points=301)
Exemplo n.º 3
0
 def test_linspace__no_args(self):
     """ Test TimeSpan.linspace without passing any args. """
     tspan = TimeSpan.linspace()
     self.assertEqual(tspan, numpy.linspace(0, 20, 401))
Exemplo n.º 4
0
 def test_linspace__no_num_points(self):
     """ Test TimeSpan.linspace without passing num_points. """
     tspan = TimeSpan.linspace(t=30)
     self.assertEqual(tspan, numpy.linspace(0, 30, int(30 / 0.05) + 1))
Exemplo n.º 5
0
 def test_linspace__no_t(self):
     """ Test TimeSpan.linspace without passing t. """
     tspan = TimeSpan.linspace(num_points=201)
     self.assertEqual(tspan, numpy.linspace(0, 20, 201))
Exemplo n.º 6
0
 def test_linspace(self):
     """ Test TimeSpan.linspace. """
     tspan = TimeSpan.linspace(t=30, num_points=301)
     self.assertEqual(tspan, numpy.linspace(0, 30, 301))
Exemplo n.º 7
0
 def setUp(self):
     """ Setup a clean valid timespan for testing. """
     self.tspan = TimeSpan.linspace(t=100, num_points=101)