File: schema.py

package info (click to toggle)
python-asdf 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,032 kB
  • sloc: python: 24,068; makefile: 123
file content (35 lines) | stat: -rw-r--r-- 1,102 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import numpy

import asdf


class SoftwareValidateSuite:
    def setup(self):
        # software is a pretty simple tag, so validation should be fast
        s = asdf.tags.core.Software(name="foo", version="0.0.0")
        self.af = asdf.AsdfFile()
        self.af["i"] = s
        self.obj = dict(asdf.yamlutil.custom_tree_to_tagged_tree(self.af.tree, self.af)["i"])
        self.schema = asdf.schema.load_schema(
            "http://stsci.edu/schemas/asdf/core/software-1.0.0",
            resolve_references=True,
        )

    def time_validate(self):
        self.af.validate()


class NDArrayValidateSuite:
    def setup(self):
        # ndarray is more complicated and validation will be slower
        n = numpy.ndarray([1])
        self.af = asdf.AsdfFile()
        self.af["i"] = n
        self.obj = dict(asdf.yamlutil.custom_tree_to_tagged_tree(self.af.tree, self.af)["i"])
        self.schema = asdf.schema.load_schema(
            "http://stsci.edu/schemas/asdf/core/ndarray-1.0.0",
            resolve_references=True,
        )

    def time_validate(self):
        self.af.validate()