Skip to content

Commit

Permalink
Make NDArrayType.__len__() a method, not a property
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavies-st committed Apr 4, 2019
1 parent 3e36570 commit 4b2e81e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

- Overhaul packaging infrastructure. Remove use of ``astropy_helpers``. [#670]

- Fix bug in ``NDArrayType.__len__``. It must be a method, not a
property. [#673]

2.3.3 (2019-04-02)
------------------

Expand Down
1 change: 0 additions & 1 deletion asdf/tags/core/ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def dtype(self):
else:
return self._array.dtype

@property
def __len__(self):
if self._array is None:
return self._shape[0]
Expand Down
11 changes: 11 additions & 0 deletions asdf/tags/core/tests/test_ndarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ def check_asdf(asdf):

helpers.assert_roundtrip_tree(tree, tmpdir, asdf_check_func=check_asdf)

def test_len_roundtrip(tmpdir):
sequence = np.arange(0, 10, dtype=np.int)
tree = {
'sequence': sequence
}

def check_len(asdf):
s = asdf.tree["sequence"]
assert len(s) == 10

helpers.assert_roundtrip_tree(tree, tmpdir, asdf_check_func=check_len)

def test_mask_arbitrary():
content = """
Expand Down

0 comments on commit 4b2e81e

Please sign in to comment.