-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test application definition specifications #108
Comments
@jilavsky: |
Agreed. Needs a strategy how to test a data file that is written to an application definition. Data files that use the NXcanSAS application definition are more difficult since NXcanSAS specifies optional content within subgroups at several levels deep. Pick a simpler application definition and build an example file as a first test. The example files above would be additional tests. |
proposed algorithmEvaluation of a data file which is written to one (or more) application definition needs some special consideration. The application definition modifies the various base classes that are used to describe fields, groups, attributes, and links. We know:
So, when validating a data file, check the |
Might be best to start with a known good file (hint: create one according to a simpler app_def such as NXiqproc). With a simple test program (below), discover which of the NeXus HDF5 files in the example data directory use an application definition:
python codeimport h5py
import pathlib
import pyRestTable
from punx import utils
def find_definitions():
path = pathlib.Path(__file__).parent / "punx" / "data"
# print(f"{path}: {path.exists() = }")
table = pyRestTable.Table()
table.labels = "file group definition".split()
def get_definition(group):
if "definition" in group:
ds = group["definition"]
definition = utils.decode_byte_string(ds[()])
if isinstance(definition, list):
definition = definition[0]
return definition
for test_file in sorted(path.iterdir()):
def report_definitions(parent, nx_class):
for item in sorted(parent):
if utils.isNeXusGroup(parent[item], nx_class):
group = parent[item]
definition = get_definition(group)
table.addRow((test_file.name, group.name, definition or ""))
if nx_class == "NXentry":
report_definitions(group, "NXsubentry")
if test_file.is_file() and utils.isNeXusFile(test_file):
# print(f"{type(test_file)} {test_file.name}")
with h5py.File(test_file, "r") as root:
report_definitions(root, "NXentry")
print(table.reST(fmt="md"))
if __name__ == "__main__":
find_definitions() |
Possibly start by creating a contrived (random data, not actual) NXmonopd test data file and build tests for things that pass and do not pass. |
suitable example from the canSAS NXcanSAS examples:
The text was updated successfully, but these errors were encountered: