Refactor the sequence interface#12
Refactor the sequence interface#12bastibe merged 1 commit intobastibe:masterfrom mgeier:sequence-interface
Conversation
Refactoring: * factor-out duplicate code to separate method _get_slice_bounds() * replace 4 if-clauses with one call to slice.indices() * issue #6 is still not solved because __len__() is still broken (#11) Change behavior to be more sane: * raise error if step != 1 * this was silently ignored before Change behavior to be closer to Python indexing: * if start > stop (assuming step==1), an empty array is returned * before, the two values were flipped * if negative values exceed length, they are set to maximum * something strange happened before ...
|
Very nice! Thank you so much for this contribution! If I understand your commit correctly, you disallow steps that are greater than 1. This seems to mean that I can't In fact, I wanted to extend the index operator to channel selections. I would love to be able to |
|
Your example should still work, "step" is the third argument to the slice. This would not work: In the future it would of course be nice to support a step size (for whatever reason this should be needed ...), but this needs a bit more work. And I would also like to have the 2-dimensional indexing, this would have been one of my next questions ... |
|
Oh, I get it now. Yes, that is perfect! I am currently pretty short on time, so if you want to give 2-dimensional indexing a shot, I'd be very grateful! I will merge your many contributions tomorrow and recut the binaries. I actually managed to reserve a solid few hours solely for PySoundFile and PySoundCard tomorrow. |
Refactor the sequence interface
|
Thanks for merging! I created an issue for 2D indexing: #15. |
Refactoring:
Change behavior to be more sane:
Change behavior to be closer to Python indexing: