def test_mean(self): waveform_a = WaveForm("A", u_s(1).prefixed_unit, (1, 1)) waveform_a[0] = 2 waveform_b = WaveForm("B", u_s(1).prefixed_unit, (1, 1)) waveform_b[0] = 3 waveform_result = waveform_a * waveform_b waveform_mean = np.mean(waveform_result) self.assertEqual(waveform_mean.value, 6) self.assertEqual(waveform_mean.unit, waveform_result.unit) self.assertEqual(waveform_mean.power, waveform_result.power)
def test_ufunc(self): waveform_a = WaveForm("A", u_s(1).prefixed_unit, (1, 1)) waveform_a[0] = 2 waveform_b = WaveForm("B", u_s(1).prefixed_unit, (1, 1)) waveform_b[0] = 3 waveform_result = waveform_a * waveform_b self.assertEqual(waveform_result[0, 0], 6) self.assertEqual(waveform_result.prefixed_unit.unit, (u_s(1) * u_s(1)).unit) self.assertEqual(waveform_result.prefixed_unit.power, (u_s(1) * u_s(1)).power)
def to_waveform(self, abscissa=None, to_real=False, to_float=False): """ Return a :obj:`PySpice.Probe.WaveForm` instance. """ data = self._data if to_real: data = data.real # Fixme: else UnitValue instead of UnitValues # if to_float: # data = float(data[0]) if self._unit is not None: return WaveForm.from_unit_values(self.simplified_name, self._unit(data), abscissa=abscissa) else: return WaveForm.from_array(self.simplified_name, data, abscissa=abscissa)
def to_waveform(self, abscissa=None, to_real=False, to_float=False): """ Return a :obj:`PySpice.Probe.WaveForm` instance. """ data = self._data if to_real: data = data.real # Fixme: else UnitValue instead of UnitValues # if to_float: # data = float(data[0]) if self._unit is not None: return WaveForm.from_unit_values(self.simplified_name, self._unit(data), abscissa=abscissa) else: return WaveForm.from_array(self.simplified_name, data, abscissa=abscissa)
def to_waveform(self, abscissa=None, to_real=False, to_float=False): """ Return a :obj:`PySpice.Probe.WaveForm` instance. """ data = self.data if to_real: data = data.real if to_float: data = float(data[0]) return WaveForm(self.simplified_name, self.unit(data), abscissa=abscissa)
def test_waveformx(self): waveform = WaveForm('Test', u_kHz(100).prefixed_unit, (1, 1)) new_waveform = pickle.loads(pickle.dumps(waveform)) self.assertEqual(waveform, new_waveform)