Пример #1
0
 def test_divide(self):
     """Test series division."""
     series1 = Series(self.x, self.data_cplx)
     series2 = Series(self.x, self.data_cplx)
     combined = series1 / series2
     self.assertTrue(np.allclose(combined.x, series1.x))
     self.assertTrue(np.allclose(combined.y, np.ones_like(self.data_cplx)))
Пример #2
0
 def test_multiply(self):
     """Test series multiplication."""
     series1 = Series(self.x, self.data_cplx)
     series2 = Series(self.x, self.data_cplx)
     series3 = Series(self.x, self.data_cplx)
     combined = series1 * series2 * series3
     self.assertTrue(np.allclose(combined.x, series1.x))
     self.assertTrue(np.allclose(combined.y, self.data_cplx ** 3))
Пример #3
0
 def test_exponentiate(self):
     """Test series exponentiation."""
     series1 = Series(self.x, self.data_cplx)
     series2 = Series(self.x, self.data_cplx)
     series3 = Series(self.x, self.data_cplx)
     combined = series1 ** series2 ** series3
     self.assertTrue(np.allclose(combined.x, combined.x))
     self.assertTrue(np.allclose(combined.y, self.data_cplx ** self.data_cplx ** self.data_cplx))
Пример #4
0
 def test_addition(self):
     """Test series addition."""
     series1 = Series(self.x, self.data_cplx)
     series2 = Series(self.x, self.data_cplx)
     series3 = Series(self.x, self.data_cplx)
     combined = series1 + series2 + series3
     self.assertTrue(np.allclose(combined.x, combined.x))
     self.assertTrue(np.allclose(combined.y, self.data_cplx * 3))
Пример #5
0
 def test_subtract(self):
     """Test series subtraction."""
     series1 = Series(self.x, self.data_cplx)
     series2 = Series(self.x, self.data_cplx)
     series3 = Series(self.x, self.data_cplx)
     combined = series1 - series2 - series3
     self.assertTrue(np.allclose(combined.x, combined.x))
     self.assertTrue(np.allclose(combined.y, self.data_cplx * -1))
Пример #6
0
 def test_inverse_self(self):
     """Test series inversion with self."""
     series = Series(self.x, self.data_cplx)
     inverted = series.inverse()
     # Division should return a new object, so there shouldn't be issues with data changing
     # later.
     series.y = np.zeros_like(series.y)
     self.assertTrue(np.allclose(inverted.x, series.x))
     self.assertTrue(np.allclose(inverted.y, 1 / self.data_cplx))
Пример #7
0
 def test_divide_self(self):
     """Test series division with self."""
     series = Series(self.x, self.data_cplx)
     combined = series / series
     # Division should return a new object, so there shouldn't be issues with data changing
     # later.
     series.y = np.zeros_like(series.y)
     self.assertTrue(np.allclose(combined.x, series.x))
     self.assertTrue(np.allclose(combined.y, np.ones_like(self.data_cplx)))
Пример #8
0
 def test_multiply_self(self):
     """Test series multiplication with self."""
     series = Series(self.x, self.data_cplx)
     combined = series * series * series
     # Multiplication should return a new object, so there shouldn't be issues with data
     # changing later.
     series.y = np.zeros_like(series.y)
     self.assertTrue(np.allclose(combined.x, series.x))
     self.assertTrue(np.allclose(combined.y, self.data_cplx ** 3))
Пример #9
0
 def test_negate(self):
     """Test series negation."""
     series = Series(self.x, self.data_cplx)
     negated = -series
     # Negation should return a new object, so there shouldn't be issues with data changing
     # later.
     series.y = np.zeros_like(series.y)
     self.assertTrue(np.allclose(negated.x, series.x))
     self.assertTrue(np.allclose(negated.y, -self.data_cplx))
Пример #10
0
 def test_inverse(self):
     """Test series inversion."""
     series = Series(self.x, self.data_cplx)
     # Standard inverse.
     inverted = series.inverse()
     self.assertTrue(np.allclose(inverted.x, series.x))
     self.assertTrue(np.allclose(inverted.y, 1 / self.data_cplx))
     # Alternate inverse.
     inverted = 1 / series
     self.assertTrue(np.allclose(inverted.x, series.x))
     self.assertTrue(np.allclose(inverted.y, 1 / self.data_cplx))
Пример #11
0
 def test_divide_scalar(self):
     """Test series scalar division."""
     series = Series(self.x, self.data_cplx)
     # Right division.
     scaled = series / 5
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx / 5))
     # Left (reflexive) division.
     scaled = 5 / series
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, 5 / self.data_cplx))
Пример #12
0
 def test_multiply_scalar(self):
     """Test series scalar multiplication."""
     series = Series(self.x, self.data_cplx)
     # Right multiplication.
     scaled = series * 5
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx * 5))
     # Left multiplication.
     scaled = 5 * series
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx * 5))
Пример #13
0
 def test_addition_scalar(self):
     """Test series scalar addition."""
     series = Series(self.x, self.data_cplx)
     scaled = series + 5
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx + 5))
Пример #14
0
 def test_from_re_im(self):
     """Test real/imaginary series factory using default scale"""
     self.assertEqual(Series(self.x, self.data_cplx),
                      Series.from_re_im(self.x, re=self.data_re, im=self.data_im))
Пример #15
0
 def test_from_mag_phase_db_rad(self):
     """Test magnitude/phase series factory using db/rad scale"""
     self.assertEqual(Series(self.x, self.data_cplx),
                      Series.from_mag_phase(self.x, self.data_mag_db, self.data_phase_deg,
                                            mag_scale="db", phase_scale="deg"))
Пример #16
0
 def test_from_mag_phase_abs_rad(self):
     """Test magnitude/phase series factory using abs/rad scale"""
     self.assertEqual(Series(self.x, self.data_cplx),
                      Series.from_mag_phase(self.x, self.data_mag_abs, self.data_phase_rad,
                                            mag_scale="abs", phase_scale="rad"))
Пример #17
0
 def test_from_mag_phase_default(self):
     """Test magnitude/phase series factory using default scale"""
     self.assertEqual(Series.from_mag_phase(self.x, self.data_mag_abs, self.data_phase_deg),
                      Series.from_mag_phase(self.x, self.data_mag_abs, self.data_phase_deg,
                                            mag_scale="abs", phase_scale="deg"))
Пример #18
0
 def test_exponentiate_scalar(self):
     """Test series scalar exponentiation."""
     series = Series(self.x, self.data_cplx)
     scaled = series ** 5
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx ** 5))
Пример #19
0
 def _series(self, freqs, data=None, cplx=False):
     if data is None:
         data = self._data(len(freqs), cplx)
     return Series(freqs, data)
Пример #20
0
 def test_subtract_scalar(self):
     """Test series scalar subtraction."""
     series = Series(self.x, self.data_cplx)
     scaled = series - 5
     self.assertTrue(np.allclose(scaled.x, series.x))
     self.assertTrue(np.allclose(scaled.y, self.data_cplx - 5))