Numula icon indicating copy to clipboard operation
Numula copied to clipboard

random volume documentation/code

Open davidedelvento opened this issue 3 years ago • 5 comments

https://github.com/davidpanderson/Numula/wiki/Volume-control#random-volume-perturbation says

ns.v_random_uniform(min, max, pred=None):
ns.v_random_normal(stddev, max_sigma, pred=None):

but that doesn't work

>>> ns.v_random_normal(10, 20, pred=None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Score' object has no attribute 'v_random_normal'. Did you mean: 't_random_normal'?

and in fact there is no v_random anything in https://github.com/davidpanderson/Numula/blob/main/numula/nscore.py

Also, the pip-installed version fails at read_midifile because it does not contain the fix https://github.com/davidpanderson/Numula/blob/main/numula/read_midifile.py#L22 (which obviously is present in github) so you might want to update the PyPI version.

davidedelvento avatar Nov 05 '22 02:11 davidedelvento

All fixed (I think). Thanks for the report.

davidpanderson avatar Nov 05 '22 08:11 davidpanderson

All fixed (I think).

The ones I reported are both fixed, literally speaking, but the example command is still failing as follows

>>> ns.v_random_normal(10, 20, pred=None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/davide/.local/lib/python3.10/site-packages/numula/nuance.py", line 308, in v_random_normal
    y = stddev*(1+y)
UnboundLocalError: local variable 'y' referenced before assignment

Thanks for the report.

You are most welcome.

If you are open to it, let me make you an offer, which would solve these problems, and aid the documentation: unit tests. I think for a project at this stage and of this scope, having unit tests is essential. The project is small enough that adding them now is still feasible, and being a "pet project" probably used by a small userbase would also mean that issue may stay unseen for long time, making it harder to fix them later (when you might forget the details of what was going on), especially if too many pile up with time.

You are most likely already familiar with Unit Test, but for the sake of "explicit is better than implicit", they will be little snippet of codes like the one I reported failing. They should be the same as posted in the documentation, and ideally (for the future) they should be written before the code, something like "if you run this command, this should be the output", which would immediately fail and stay failed until you write the code (I found the "test first" incredibly helpful in my coding)

If you think this is useful, I can give it at first stab at it, by writing

  • the (minimal) boilerplate,
  • the github integration (so github runs them for you if you don't want to run them in your environment) and
  • the actual tests for everything that is documented and/or exists in code (or at least everything I understand)

davidedelvento avatar Nov 05 '22 12:11 davidedelvento

That would be great, and much appreciated.

There are currently a number of tests in examples/test*.py. These could be used for starters. Some of them call pianoteq.play_score() so they'd to be modified to run on github.

BTW, I made a Numula demo video: https://www.youtube.com/watch?v=gQQoDCtSfeU

davidpanderson avatar Nov 06 '22 20:11 davidpanderson

I created a PR #6 only with boilerplate, no actual functionality.

To see what it looks like if you merge, you'll get https://github.com/davidedelvento/Numula/blob/tests/README.md

and you can see tests logs like this https://github.com/davidedelvento/Numula/actions/runs/3407353292/jobs/5666909769

davidedelvento avatar Nov 07 '22 03:11 davidedelvento

Thanks. It will take me a few days to digest this.

davidpanderson avatar Nov 10 '22 04:11 davidpanderson