def chain_normalizer(self, func, encoder): if isinstance(encoder, WolframDispatch): encoder.update_dispatch() return composition( *map(safe_import_string, iterate(func or (), partial(encoder.as_method(), self))))
def test_composition(self): self.assertEqual(composition()(1), 1) self.assertEqual(composition(lambda s: s + 2)(1), 3) self.assertEqual(composition(lambda s: s + 2, lambda s: s * 3)(1), 9)
def annotation(fn): return wraps(fn)(composition(fn, *func))