File: common.py

package info (click to toggle)
python-asdf 2.7.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 3,248 kB
  • sloc: python: 13,104; makefile: 125
file content (19 lines) | stat: -rw-r--r-- 570 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import asdf
from asdf.versioning import supported_versions
import numpy as np


def generate_file(path, version):
    if version not in supported_versions:
        raise ValueError("ASDF Standard version {} is not supported by version {} of the asdf library".format(version, asdf.__version__))

    af = asdf.AsdfFile({"array": np.ones((8, 16))}, version=version)
    af.write_to(path)


def assert_file_correct(path):
    __tracebackhide__ = True

    with asdf.open(str(path)) as af:
        assert af["array"].shape == (8, 16)
        assert np.all(af["array"] == 1)