Skip to content

Commit

Permalink
Merge pull request #1674 from braingram/update_3p0px
Browse files Browse the repository at this point in the history
Update 3p0px
  • Loading branch information
braingram authored Oct 30, 2023
2 parents 959a83d + 7f6cd94 commit 8e7fe6c
Show file tree
Hide file tree
Showing 15 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ jobs:
needs: [core, asdf-schemas]
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish_pure_python.yml@v1
with:
python-version: "3.11"
upload_to_pypi: false
upload_to_anaconda: false
test_extras: tests
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
default_python: '3.10'
envs: |
- linux: asdf-astropy
- linux: specutils
stsci:
uses: OpenAstronomy/github-actions-workflows/.github/workflows/tox.yml@v1
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ repos:
exclude: "asdf/(extern||_jsonschema)/.*"

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.292'
rev: 'v0.1.1'
hooks:
- id: ruff
args: ["--fix"]

- repo: https://github.com/psf/black
rev: 23.9.1
rev: 23.10.1
hooks:
- id: black

Expand All @@ -59,6 +59,6 @@ repos:
- id: blacken-docs

- repo: https://github.com/abravalheri/validate-pyproject
rev: "v0.14"
rev: "v0.15"
hooks:
- id: validate-pyproject
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
3.0.1 (unreleased)
3.0.1 (2023-10-30)
------------------

The ASDF Standard is at v1.6.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-
- Fix bug in ``asdftool diff`` for arrays within a list [#1672]

3.0.0 (2023-10-16)
------------------
Expand Down
3 changes: 2 additions & 1 deletion asdf/_tests/commands/tests/data/blocks.diff
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ tree:
-
> 9000
< 10000
ndarrays at "foobar" differ by shape, datatype and contents
> ndarrays differ by shape, datatype and contents
< ndarrays differ by shape, datatype and contents
9 changes: 9 additions & 0 deletions asdf/_tests/commands/tests/data/ndarray_in_list.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
< tree:
< list:
< - a:
< offset:
< 16
< strides:
< - -8
> ndarrays differ by contents
< ndarrays differ by contents
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion asdf/_tests/commands/tests/data/ndarrays.diff
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
ndarrays at "a" differ by contents
tree:
a:
> ndarrays differ by contents
< ndarrays differ by contents
5 changes: 4 additions & 1 deletion asdf/_tests/commands/tests/data/simple_inline_array.diff
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
ndarrays at "array" differ by contents
tree:
array:
> ndarrays differ by contents
< ndarrays differ by contents
6 changes: 6 additions & 0 deletions asdf/_tests/commands/tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def test_diff_ndarray():
_assert_diffs_equal(filenames, result_file, minimal=False)


def test_diff_ndarray_in_list():
filenames = ["ndarray_in_list0.asdf", "ndarray_in_list1.asdf"]
result_file = "ndarray_in_list.diff"
_assert_diffs_equal(filenames, result_file, minimal=False)


def test_diff_block():
filenames = ["block0.asdf", "block1.asdf"]
result_file = "blocks.diff"
Expand Down
12 changes: 6 additions & 6 deletions asdf/_tests/test_generic_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap)


def test_open2(tree, tmp_path):
Expand All @@ -135,7 +135,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap)


@pytest.mark.parametrize("mode", ["r", "w", "rw"])
Expand Down Expand Up @@ -172,7 +172,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert isinstance(ff._blocks.blocks[0].cached_data, np.memmap)
ff.tree["science_data"][0] = 42


Expand Down Expand Up @@ -208,7 +208,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert not isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert not isinstance(ff._blocks.blocks[0].cached_data, np.memmap)
ff.tree["science_data"][0] = 42


Expand All @@ -224,7 +224,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert not isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert not isinstance(ff._blocks.blocks[0].cached_data, np.memmap)
ff.tree["science_data"][0] = 42


Expand Down Expand Up @@ -252,7 +252,7 @@ def get_read_fd():

with _roundtrip(tree, get_write_fd, get_read_fd) as ff:
assert len(ff._blocks.blocks) == 2
assert not isinstance(ff._blocks.blocks[0].cached_data, np.core.memmap)
assert not isinstance(ff._blocks.blocks[0].cached_data, np.memmap)


@pytest.mark.remote_data()
Expand Down
13 changes: 7 additions & 6 deletions asdf/commands/diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ class ArrayNode:
of but not necessarily display. This allows the diff output to be
cleaner."""

def __init__(self, name):
def __init__(self, name, index):
self.name = name
self.index = index

def __hash__(self):
return hash(self.name)
Expand Down Expand Up @@ -191,7 +192,7 @@ def print_in_tree(diff_ctx, node_list, thing, other, use_marker=False, last_was_
# If tree element is list, recursively print list contents
if isinstance(thing, list):
for i, subthing in enumerate(thing):
key = ArrayNode(f"{node_list[-1]}_{i}")
key = ArrayNode(f"{node_list[-1]}_{i}", i)
last_was_list = print_in_tree(
diff_ctx,
[*node_list, key],
Expand Down Expand Up @@ -277,9 +278,9 @@ def compare_ndarrays(diff_ctx, array0, array1, keys):
differences.append("contents")

if differences:
prefix = " " * (len(keys) + 1)
msg = f"ndarrays at \"{'.'.join(keys)}\" differ by {human_list(differences)}"
diff_ctx.iostream.write(prefix + RED + msg + RESET_NEWLINE)
msg = f"ndarrays differ by {human_list(differences)}"
print_in_tree(diff_ctx, keys, msg, False, ignore_lwl=True)
print_in_tree(diff_ctx, keys, msg, True, ignore_lwl=True)


def both_are_ndarrays(tree0, tree1):
Expand Down Expand Up @@ -321,7 +322,7 @@ def compare_trees(diff_ctx, tree0, tree1, keys=None):
compare_dicts(diff_ctx, tree0, tree1, keys)
elif isinstance(tree0, list) and isinstance(tree1, list):
for i, (obj0, obj1) in enumerate(zip(tree0, tree1)):
key = ArrayNode(f"item_{i}")
key = ArrayNode(f"item_{i}", i)
compare_trees(diff_ctx, obj0, obj1, [*keys, key])
else:
compare_objects(diff_ctx, tree0, tree1, keys)
Expand Down
6 changes: 3 additions & 3 deletions asdf/generic_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ def clear(self, nbytes):

def memmap_array(self, offset, size):
"""
Memmap a chunk of the file into a `np.core.memmap` object.
Memmap a chunk of the file into a `np.memmap` object.
Parameters
----------
Expand All @@ -649,7 +649,7 @@ def memmap_array(self, offset, size):
Returns
-------
array : np.core.memmap
array : np.memmap
"""
msg = f"memmapping is not implemented for {self.__class__.__name__}"
raise NotImplementedError(msg)
Expand Down Expand Up @@ -680,7 +680,7 @@ def read_into_array(self, size):
Returns
-------
array : np.core.memmap
array : np.memmap
"""
buff = self.read(size)
return np.frombuffer(buff, np.uint8, size, 0)
Expand Down
3 changes: 1 addition & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
env_list =
compatibility
coverage
devdep{,-parallel}
py{39,310,311,312}{,-compatibility,-coverage,-jsonschema}{,-parallel}
py{39,310,311,312}{,-compatibility,-coverage,-jsonschema}{,-devdeps}{,-parallel}
asdf{-standard,-transform-schemas,-unit-schemas,-wcs-schemas,-coordinates-schemas,-astropy}
gwcs
jwst
Expand Down

0 comments on commit 8e7fe6c

Please sign in to comment.