Thread: [Pythonsound-devel] (no subject)
Status: Beta
Brought to you by:
mupuxeddu
|
From: Paul W. <sli...@ya...> - 2001-10-06 20:32:00
Attachments:
diff.txt
|
I'm still exploring omde/score.py, which seems to be the area that
largely overlaps my pysco ideas. I thought as long as I'm trying
things out to see what they do, I might as well save my test cases and
add a doctest hook to the module. In the process, I found a few things
that I'm pretty sure are bugs and took the liberty of fixing them.
The attached diff is against cvs of today, Oct 6, 19:50 UTC.
Notes on changes:
- General modifications:
* Added many tests to docstrings.
* Added _test() to run doctest on the docstrings.
- Event:
CHANGED: Changed all spellings of "strech" to "stretch".
FIXED BUG: stretch_absolute_backward used 'alfa' should be 'time'
FIXED BUG: stretch_relative_backward used 'alfa', should be 'alpha'
FIXED INCONSISTENCY: stretch_relative_backward was always returning floats;
other methods return ints if given int arguments. Should be consistent.
- F:
BUG FIXED: but maybe it was a feature.... but if F(number=None),
it's free to choose a number that was already specified by the user.
I changed it to keep track of all used numbers and choose the lowest
unused number.
BUG FIXED: F.end() added, to always return F.onset instead of F.duration
(which is actually not duration but table length).
Using F and I polymorphically would not have worked.
- Aggregate:
BUG FIXED: removed first definition of load() ... it was defined twice
and the first looked broken.
ADDED: append() which adds one object to the list.
We have extend(), why not continue the list metaphor?
BUG FIXED: extend() had the wrong order of arguments to isinstance()
CHANGED: saveAs to raise a proper TypeError if wrong argument given
CHANGED: deepcopy() wasn't returning anything.
BUG FIXED: clone() was missing, though some other methods use it.
I assume it's the same as deepcopy. One name should be used throughout.
SUGGESTION: a shorter name for calculate_onset_min_max, et al,
would be get_onset_min_max.
BUG FIXED: calculate_onset_min_max always returned None as minimum.
BUG FIXED: calculate_begin_end always returned None as the start.
BUG FIXED: calculate_onset_min_max, et al. will now work with
classes that derive from both Event and Aggregate.
--
................ paul winkler ................
custom calendars: http://www.calendargalaxy.com
A member of ARMS: http://www.reacharms.com
home page: http://www.slinkp.com
|
|
From: Maurizio U. P. <um...@ti...> - 2001-10-07 22:24:21
|
Thank you very much for the work! I'm in a hurry. I'll reply you completely and commit it tonight or tomorrow. Maurizio Umberto Puxeddu. |
|
From: Maurizio U. P. <um...@ti...> - 2001-10-09 16:38:28
|
On Sat, 6 Oct 2001, Paul Winkler wrote: > I'm still exploring omde/score.py, which seems to be the area that > largely overlaps my pysco ideas. I thought as long as I'm trying > things out to see what they do, I might as well save my test cases and > add a doctest hook to the module. In the process, I found a few things > that I'm pretty sure are bugs and took the liberty of fixing them. Thank you very much: you do work that I planned to do plus things that I hadn't noticed. > The attached diff is against cvs of today, Oct 6, 19:50 UTC. > > Notes on changes: > > - General modifications: > * Added many tests to docstrings. > * Added _test() to run doctest on the docstrings. > > - Event: > CHANGED: Changed all spellings of "strech" to "stretch". > FIXED BUG: stretch_absolute_backward used 'alfa' should be 'time' > FIXED BUG: stretch_relative_backward used 'alfa', should be 'alpha' > FIXED INCONSISTENCY: stretch_relative_backward was always returning floats; > other methods return ints if given int arguments. Should be consistent. > > - F: > BUG FIXED: but maybe it was a feature.... but if F(number=None), > it's free to choose a number that was already specified by the user. > I changed it to keep track of all used numbers and choose the lowest > unused number. > > BUG FIXED: F.end() added, to always return F.onset instead of F.duration > (which is actually not duration but table length). > Using F and I polymorphically would not have worked. There was I reason for not to add the end() method... but I don't remember what... The problem of the "duration" of tables was known to me. This is the reason the attach() method and related code. But it's a temporary workaround. See below. > - Aggregate: > BUG FIXED: removed first definition of load() ... it was defined twice > and the first looked broken. > > ADDED: append() which adds one object to the list. > We have extend(), why not continue the list metaphor? > > BUG FIXED: extend() had the wrong order of arguments to isinstance() > > CHANGED: saveAs to raise a proper TypeError if wrong argument given > > CHANGED: deepcopy() wasn't returning anything. > > BUG FIXED: clone() was missing, though some other methods use it. > I assume it's the same as deepcopy. One name should be used throughout. > > SUGGESTION: a shorter name for calculate_onset_min_max, et al, > would be get_onset_min_max. calculate_ was there to remeber that it is not at accessor method but it has to do some work. Could we use calc_ as a compromise? > BUG FIXED: calculate_onset_min_max always returned None as minimum. > > BUG FIXED: calculate_begin_end always returned None as the start. Did you checked it? min(None, everything) is always everything. It's like None is infinite and this is the reason to use max2(). > BUG FIXED: calculate_onset_min_max, et al. will now work with > classes that derive from both Event and Aggregate. Ok. The only problems is that I made a lot of changes on that file too today and moved ScoreEvent, I, F etc in omde.csound. BTW, I find some problems putting *all* conversion to csound numeric score notation out of the omde.score module. Maurizio Umberto Puxeddu. |
|
From: Paul W. <sli...@ya...> - 2001-10-09 17:26:38
|
On Tue, Oct 09, 2001 at 06:35:41PM +0200, Maurizio Umberto Puxeddu wrote: > > BUG FIXED: F.end() added, to always return F.onset instead of F.duration > > (which is actually not duration but table length). > > Using F and I polymorphically would not have worked. > There was I reason for not to add the end() method... but I don't remember > what... If you remember, I'd be curious to hear. I can't think of any problems with F.end(). > The problem of the "duration" of tables was known to me. This is the > reason the attach() method and related code. But it's a temporary > workaround. Aha, I didn't make the connection. I was wondering what those were for! > > SUGGESTION: a shorter name for calculate_onset_min_max, et al, > > would be get_onset_min_max. > > calculate_ was there to remeber that it is not at accessor method but it > has to do some work. Could we use calc_ as a compromise? If you like. But why is it necessary for the programmer to remember that this method "has to do some work"? He/she is only interested in the return value. > > BUG FIXED: calculate_onset_min_max always returned None as minimum. > > > > BUG FIXED: calculate_begin_end always returned None as the start. > > Did you checked it? > min(None, everything) is always everything. It's like None is infinite and > this is the reason to use max2(). $ python Python 2.1 (#5, Oct 8 2001, 00:32:31) [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 Type "copyright", "credits" or "license" for more information. >>> min (None, 1) >>> print min (None, 1) None -- ................ paul winkler ................ custom calendars: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com |
|
From: Maurizio U. P. <um...@ti...> - 2001-10-09 18:03:35
|
On Tue, 9 Oct 2001, Paul Winkler wrote: > If you like. But why is it necessary for the programmer to remember > that this method "has to do some work"? He/she is only interested in > the return value. If you know that a call is potentially going to consume much time, you can think of caching the values instead of calling it twice. Nothing more. Probably the best way should be caching onset min, onset max and end max values instead of caching onset and duration, isn't it? I think I'll do this. > > > BUG FIXED: calculate_onset_min_max always returned None as minimum. > > > > > > BUG FIXED: calculate_begin_end always returned None as the start. > > > > Did you checked it? > > min(None, everything) is always everything. It's like None is infinite and > > this is the reason to use max2(). > > $ python > Python 2.1 (#5, Oct 8 2001, 00:32:31) > [GCC 2.96 20000731 (Red Hat Linux 7.0)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> min (None, 1) > >>> print min (None, 1) > None Python 2.0 (#2, May 22 2001, 11:42:51) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 Type "copyright", "credits" or "license" for more information. >>> min(None, 1) 1 >>> Ok. I defined min2 in omde.utility. Should be fixed in the CVS. Maurizio Umberto Puxeddu. |
|
From: Paul W. <sli...@ya...> - 2001-10-09 18:25:21
|
On Tue, Oct 09, 2001 at 08:00:50PM +0200, Maurizio Umberto Puxeddu wrote: > On Tue, 9 Oct 2001, Paul Winkler wrote: > > > If you like. But why is it necessary for the programmer to remember > > that this method "has to do some work"? He/she is only interested in > > the return value. > > If you know that a call is potentially going to consume much time, > you can think of caching the values instead of calling it > twice. Nothing more. OK, I see your point. > Probably the best way should be caching onset min, onset max and end > max values instead of caching onset and duration, isn't it? I think I'll > do this. This is starting to sound rather like pysco. :) Especially since Aggregate now subclasses Event. In pysco, I didn't provide methods like those you have - I just had attributes, and required that time-modifying methods must update the relevant attributes. This meant that accessing the values is always fast, but modifying an Aggregate might be slow. pysco.Event had two attributes: endbeat (this is duration, which is actually a better name) last_at (this corresponds to calculate_min_max_onset()[1]) For non-Aggregates, last_at was just 0. I think omde is well on the way to being "like pysco but better"! -- ................ paul winkler ................ custom calendars: http://www.calendargalaxy.com A member of ARMS: http://www.reacharms.com home page: http://www.slinkp.com |