Skip to content

Conversation

@phippo
Copy link

@phippo phippo commented Dec 16, 2011

Hi everybody,

I use Quantity to develop a toolkit for neuroscientists. For my work it is important to be able to subclass Quantity. Methods of these subclasses should return again instances of this subclass. Therefore I change in quantity.py:
return Quantity ---> return self.__class__
To test return types I added also test_inheritance.py

Cheers,
Philipp

ddale added a commit that referenced this pull request Dec 16, 2011
allows Quantity to be subclassed
@ddale ddale merged commit 0882871 into python-quantities:master Dec 16, 2011
ddale added a commit that referenced this pull request Dec 20, 2011
This reverts commit 0882871, reversing
changes made to c2df012.
@ddale
Copy link
Member

ddale commented Dec 20, 2011

Please run the unit tests before filing a merge request. Three tests fail with these changes.

@phippo
Copy link
Author

phippo commented Jan 18, 2012

Sorry for that. Tests did not fail on my computer. But I am not sure how you test. I assumed from your test-structure that you use nose. Maybe a one-liner within a tests/README.txt about the correct testing would help.

@phippo
Copy link
Author

phippo commented Mar 2, 2012

As an alternative to subclassing quantities.Quantity I tried to make use of the __array__-method which is used by numpy.ndarray. This method was recommended by a numpy-community. Unfortunately, arithmentics don't work for all methods. For an example __rmul__, see: http://stackoverflow.com/questions/9499100/ . Do you have any idea where the problem could be located?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants