def test_init(self): # Manual instantiation frequency = np.array([1, 2, 3]) velocity = np.array([4, 5, 6]) dc = swprepost.DispersionCurve(frequency=frequency, velocity=velocity) expected = swprepost.DispersionSet(identifier=5, misfit=15., rayleigh={0: dc}, love=None) dc_suite = swprepost.DispersionSuite(dispersionset=expected) returned = dc_suite[0] self.assertEqual(expected, returned) # Invalid type self.assertRaises(TypeError, swprepost.DispersionSuite, ["bad dc_set"])
def test_append(self): # Manual instantiation frequency = np.array([1, 2, 3]) velocity = np.array([4, 5, 6]) dc = swprepost.DispersionCurve(frequency=frequency, velocity=velocity) dc_set_0 = swprepost.DispersionSet(identifier=0, misfit=2.1, rayleigh={0: dc}, love=None) dc_suite = swprepost.DispersionSuite(dispersionset=dc_set_0) # Manual Append dc_set_1 = swprepost.DispersionSet(identifier=2, misfit=1.1, rayleigh={0: dc}, love=None) dc_suite.append(dispersionset=dc_set_1, sort=False) # Compare the Result for dc_set in dc_suite: self.assertArrayEqual(frequency, dc_set.rayleigh[0].frequency) self.assertArrayEqual(velocity, dc_set.rayleigh[0].velocity) self.assertListEqual([0, 2], dc_suite.identifiers) self.assertListEqual([2.1, 1.1], dc_suite.misfits)