fab-jul/pymodsynth

Fix horrible stacktraces

fab-jul opened this issue · 4 comments

Example:

File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/play.py", line 298, in callback
    current_output = self.output_gen(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 593, in __call__
    result = self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 459, in __call__
    return self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 570, in out
    left = self._maybe_call(self.left, clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 580, in _maybe_call
    return module_or_number(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 459, in __call__
    return self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 571, in out
    right = self._maybe_call(self.right, clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 580, in _maybe_call
    return module_or_number(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 459, in __call__
    return self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 570, in out
    left = self._maybe_call(self.left, clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 580, in _maybe_call
    return module_or_number(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 593, in __call__
    result = self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 447, in out
    inputs[name] = getattr(self, name).out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/filters.py", line 159, in out
    input_signal = self.signal(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 459, in __call__
    return self.out(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 570, in out
    left = self._maybe_call(self.left, clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 580, in _maybe_call
    return module_or_number(clock_signal)
  File "/Users/fabian/PycharmProjects/pymodsynth/playground_v2/mz/base.py", line 594, in __call__
    clock_signal.assert_same_shape(result, self.name)

An unrelated problem is with invalid inputs, they cause weird errors. Examples would be returning a module instead of an array.

(this requires some more checks in the base classes)

in general we probably want to annotate and reraise all exceptions? need to think more

probably should enforce np outputs and add error checking in out given inputs, also for floats!