core.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. """ The core's core. """
  2. from __future__ import annotations
  3. # used for canonical ordering of symbolic sequences
  4. # via __cmp__ method:
  5. # FIXME this is *so* irrelevant and outdated!
  6. ordering_of_classes = [
  7. # singleton numbers
  8. 'Zero', 'One', 'Half', 'Infinity', 'NaN', 'NegativeOne', 'NegativeInfinity',
  9. # numbers
  10. 'Integer', 'Rational', 'Float',
  11. # singleton symbols
  12. 'Exp1', 'Pi', 'ImaginaryUnit',
  13. # symbols
  14. 'Symbol', 'Wild', 'Temporary',
  15. # arithmetic operations
  16. 'Pow', 'Mul', 'Add',
  17. # function values
  18. 'Derivative', 'Integral',
  19. # defined singleton functions
  20. 'Abs', 'Sign', 'Sqrt',
  21. 'Floor', 'Ceiling',
  22. 'Re', 'Im', 'Arg',
  23. 'Conjugate',
  24. 'Exp', 'Log',
  25. 'Sin', 'Cos', 'Tan', 'Cot', 'ASin', 'ACos', 'ATan', 'ACot',
  26. 'Sinh', 'Cosh', 'Tanh', 'Coth', 'ASinh', 'ACosh', 'ATanh', 'ACoth',
  27. 'RisingFactorial', 'FallingFactorial',
  28. 'factorial', 'binomial',
  29. 'Gamma', 'LowerGamma', 'UpperGamma', 'PolyGamma',
  30. 'Erf',
  31. # special polynomials
  32. 'Chebyshev', 'Chebyshev2',
  33. # undefined functions
  34. 'Function', 'WildFunction',
  35. # anonymous functions
  36. 'Lambda',
  37. # Landau O symbol
  38. 'Order',
  39. # relational operations
  40. 'Equality', 'Unequality', 'StrictGreaterThan', 'StrictLessThan',
  41. 'GreaterThan', 'LessThan',
  42. ]
  43. class Registry:
  44. """
  45. Base class for registry objects.
  46. Registries map a name to an object using attribute notation. Registry
  47. classes behave singletonically: all their instances share the same state,
  48. which is stored in the class object.
  49. All subclasses should set `__slots__ = ()`.
  50. """
  51. __slots__ = ()
  52. def __setattr__(self, name, obj):
  53. setattr(self.__class__, name, obj)
  54. def __delattr__(self, name):
  55. delattr(self.__class__, name)