Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement all mathematical special methods on UGenMethodMixin. #14

Closed
16 of 47 tasks
josiah-wolf-oberholtzer opened this issue Nov 2, 2014 · 0 comments
Closed
16 of 47 tasks

Comments

@josiah-wolf-oberholtzer
Copy link
Member

josiah-wolf-oberholtzer commented Nov 2, 2014

UGens should support all mathematical operators available in Python via special methods.

Implement these special methods on synthdeftools.UGenMethodMixin, using the methods already defined there as a template (e.g. UGenMethodMixin.__add__(...)).

Some of these methods may already be implemented on the synthdeftools.Op class. When available, port those methods over from the staticmethods implemented on Op to bound instance methods on UGenMethodMixin. Remove the ported method from Op. Eventually, Op should be removed entirely.

It is not guaranteed that all Python operators will translate into SuperCollider UGen operators, or vice-versa. Use good judgement, and go with whatever is least surprising.

Consult the synthdeftools.UnaryOperator and synthdeftools.BinaryOperator enumerations for the names to use when building new operator methods.

Comparators:

  • object.__lt__(self, other)
  • object.__le__(self, other)
  • object.__gt__(self, other)
  • object.__ge__(self, other)

Do not implement __eq__ or __ne__. Implementing equality operators will cause other crucial functionality to break. Equality is already implemented via Op.is_equal(...) and Op.is_not_equal(...).

See below for more methods to not implement.

Basic arithmetic operations:

  • object.__add__(self, other)
  • object.__and__(self, other)
  • object.__floordiv__(self, other)
  • object.__lshift__(self, other)
  • object.__mod__(self, other)
  • object.__mul__(self, other)
  • object.__or__(self, other)
  • object.__pow__(self, other[, modulo])
  • object.__rshift__(self, other)
  • object.__sub__(self, other)
  • object.__truediv__(self, other)
  • object.__xor__(self, other)

Reflexives:

  • object.__radd__(self, other)
  • object.__rand__(self, other)
  • object.__rfloordiv__(self, other)
  • object.__rlshift__(self, other)
  • object.__rmod__(self, other)
  • object.__rmul__(self, other)
  • object.__ror__(self, other)
  • object.__rpow__(self, other)
  • object.__rrshift__(self, other)
  • object.__rsub__(self, other)
  • object.__rtruediv__(self, other)
  • object.__rxor__(self, other)

In-place operations:

  • object.__iadd__(self, other)
  • object.__iand__(self, other)
  • object.__ifloordiv__(self, other)
  • object.__ilshift__(self, other)
  • object.__imod__(self, other)
  • object.__imul__(self, other)
  • object.__ior__(self, other)
  • object.__ipow__(self, other[, modulo])
  • object.__irshift__(self, other)
  • object.__isub__(self, other)
  • object.__itruediv__(self, other)
  • object.__ixor__(self, other)

Unary operations:

  • object.__abs__(self)
  • object.__invert__(self)
  • object.__neg__(self)
  • object.__pos__(self)

Casting operations:

  • object.__float__(self)
  • object.__int__(self)
  • object.__round__(self[, n])

Do not implement:

  • object.__divmod__(self, other)
  • object.__eq__(self, other)
  • object.__ne__(self, other)
  • object.__matmul__(self, other)
  • object.__rdivmod__(self, other)
  • object.__imatmul__(self, other)
  • object.__rmatmul__(self, other)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant