def test_reference(self): data = Table.from_numpy(None, [[2, 1, 3], [4, 2, 6]]) reference = data[:1] p = NormalizeReference(reference=reference)(data) np.testing.assert_almost_equal(p, [[1, 1, 1], [2, 2, 2]]) s = NormalizePhaseReference(reference=reference)(data) np.testing.assert_almost_equal(s, [[0, 0, 0], [2, 1, 3]])
def createinstance(params): method = params.get("method", Normalize.Vector) lower = params.get("lower", 0) upper = params.get("upper", 4000) int_method_index = params.get("int_method", 0) int_method = IntegrateEditor.Integrators_classes[int_method_index] attr = params.get("attr", None) if method != NORMALIZE_BY_REFERENCE: return Normalize(method=method, lower=lower, upper=upper, int_method=int_method, attr=attr) else: # avoids circular imports from orangecontrib.spectroscopy.widgets.owpreprocess import REFERENCE_DATA_PARAM reference = params.get(REFERENCE_DATA_PARAM, None) return NormalizeReference(reference=reference)
def createinstance(params): method = params.get("method", Normalize.Vector) lower = params.get("lower", 0) upper = params.get("upper", 4000) int_method_index = params.get("int_method", 0) int_method = IntegrateEditor.Integrators_classes[int_method_index] attr = params.get("attr", None) if method not in (NORMALIZE_BY_REFERENCE, PHASE_REFERENCE): return Normalize(method=method, lower=lower, upper=upper, int_method=int_method, attr=attr) else: # avoids circular imports reference = params.get(REFERENCE_DATA_PARAM, None) if method == PHASE_REFERENCE: return NormalizePhaseReference(reference=reference) return NormalizeReference(reference=reference)
def test_reference_exceptions(self): with self.assertRaises(MissingReferenceException): NormalizeReference(reference=None) with self.assertRaises(WrongReferenceException): NormalizeReference(reference=Table.from_numpy(None, [[2], [6]]))
def test_reference_exceptions(self): with self.assertRaises(MissingReferenceException): NormalizeReference(reference=None) with self.assertRaises(WrongReferenceException): NormalizeReference(reference=Orange.data.Table([[2], [6]]))
def test_reference(self): data = Orange.data.Table([[2, 1, 3], [4, 2, 6]]) reference = data[:1] p = NormalizeReference(reference=reference)(data) np.testing.assert_almost_equal(p, [[1, 1, 1], [2, 2, 2]])