Skip to content

Commit

Permalink
Correct Quantity.list to .tolist, overriding the correct ndarray method
Browse files Browse the repository at this point in the history
  • Loading branch information
mhvk committed Oct 24, 2014
1 parent c4784e7 commit 501025e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,9 @@ Bug Fixes
- Operations on quantities with incompatible types now raises a much
more informative ``TypeError``. [#2934]

- ``Quantity.tolist`` now overrides the ``ndarray`` method to give a
``NotImplementedError`` (by renaming the previous ``list`` method). [#3050]

- ``astropy.utils``

- Fixed an issue with the ``deprecated`` decorator on classes that invoke
Expand Down
2 changes: 1 addition & 1 deletion astropy/units/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ def item(self, *args):
# item returns python built-ins, so use initializer, not _new_view
return self.__class__(super(Quantity, self).item(*args), self.unit)

def list(self):
def tolist(self):
raise NotImplementedError("cannot make a list of Quantities. Get "
"list of values with q.value.list()")

Expand Down
2 changes: 1 addition & 1 deletion astropy/units/tests/test_quantity_array_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_not_implemented(self):
q1.choose([0, 0, 1])

with pytest.raises(NotImplementedError):
q1.list()
q1.tolist()
with pytest.raises(NotImplementedError):
q1.tostring()
with pytest.raises(NotImplementedError):
Expand Down

0 comments on commit 501025e

Please sign in to comment.