-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1337 from nexusformat/link_first_reference_2
adding links to first references of the vocabulary items and support for collapsing doc strings
- Loading branch information
Showing
6 changed files
with
1,059 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet type="text/xsl" href="nxdlformat.xsl" ?> | ||
<definition xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://definition.nexusformat.org/nxdl/3.1 ../nxdl.xsd" | ||
xmlns="http://definition.nexusformat.org/nxdl/3.1" | ||
name="NXtest" | ||
extends="NXobject" | ||
type="group" | ||
category="application" | ||
> | ||
<doc>This is a dummy NXDL to test out the dataconverter.</doc> | ||
<group type="NXentry"> | ||
<field name="program_name"/> | ||
<field name="definition"> | ||
<doc>This is a dummy NXDL to test out the dataconverter.</doc> | ||
<attribute name="version"/> | ||
<enumeration> | ||
<item value="NXTEST"/> | ||
<item value="NXtest"/> | ||
</enumeration> | ||
</field> | ||
<group type="NXdata" name="NXODD_name"> | ||
<field name="float_value" type="NX_FLOAT" optional="true" units="NX_ENERGY"> | ||
<doc>A dummy entry for a float value.</doc> | ||
</field> | ||
<field name="bool_value" type="NX_BOOLEAN" optional="false" units="NX_UNITLESS"> | ||
<doc>A dummy entry for a bool value.</doc> | ||
</field> | ||
<field name="int_value" type="NX_INT" units="NX_LENGTH"> | ||
<doc>A dummy entry for an int value.</doc> | ||
</field> | ||
<field name="posint_value" type="NX_POSINT" units="NX_LENGTH"> | ||
<doc>A dummy entry for a positive int value.</doc> | ||
</field> | ||
<field name="char_value" type="NX_CHAR" units="NX_UNITLESS"> | ||
<doc>A dummy entry for a char value.</doc> | ||
</field> | ||
<field name="date_value" type="NX_DATE_TIME" units="NX_UNITLESS"> | ||
<doc>A dummy entry for a date value.</doc> | ||
</field> | ||
<field name="type"> | ||
<enumeration> | ||
<item value="1st type" /> | ||
<item value="2nd type" /> | ||
<item value="3rd type" /> | ||
<item value="4th type" /> | ||
</enumeration> | ||
</field> | ||
</group> | ||
<group type="NXnote" name="required_group"> | ||
<doc>This is a required yet empty group.</doc> | ||
</group> | ||
<group type="NXnote" name="required_group2"> | ||
<doc>This is a second required yet empty group.</doc> | ||
</group> | ||
<group type="NXdata" name="optional_parent" optional="true"> | ||
<field name="required_child" optional="false" type="NX_INT"> | ||
<doc>A dummy entry to test optional parent check for required child.</doc> | ||
</field> | ||
<field name="optional_child" optional="true" type="NX_INT"> | ||
<doc>A dummy entry to test optional parent check for required child.</doc> | ||
</field> | ||
</group> | ||
</group> | ||
</definition> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""This is a code that performs several tests on nexus tool | ||
""" | ||
|
||
import os | ||
|
||
import lxml.etree as ET | ||
|
||
from ..utils import nxdl_utils as nexus | ||
|
||
|
||
def test_get_nexus_classes_units_attributes(): | ||
"""Check the correct parsing of a separate list for: | ||
Nexus classes (base_classes) | ||
Nexus units (memberTypes) | ||
Nexus attribute type (primitiveTypes) | ||
the tested functions can be found in nexus.py file""" | ||
|
||
# Test 1 | ||
nexus_classes_list = nexus.get_nx_classes() | ||
|
||
assert "NXbeam" in nexus_classes_list | ||
|
||
# Test 2 | ||
nexus_units_list = nexus.get_nx_units() | ||
assert "NX_TEMPERATURE" in nexus_units_list | ||
|
||
# Test 3 | ||
nexus_attribute_list = nexus.get_nx_attribute_type() | ||
assert "NX_FLOAT" in nexus_attribute_list | ||
|
||
|
||
def test_get_node_at_nxdl_path(): | ||
"""Test to verify if we receive the right XML element for a given NXDL path""" | ||
local_dir = os.path.abspath(os.path.dirname(__file__)) | ||
nxdl_file_path = os.path.join(local_dir, "./NXtest.nxdl.xml") | ||
elem = ET.parse(nxdl_file_path).getroot() | ||
node = nexus.get_node_at_nxdl_path("/ENTRY/NXODD_name", elem=elem) | ||
assert node.attrib["type"] == "NXdata" | ||
assert node.attrib["name"] == "NXODD_name" | ||
|
||
node = nexus.get_node_at_nxdl_path("/ENTRY/NXODD_name/float_value", elem=elem) | ||
assert node.attrib["type"] == "NX_FLOAT" | ||
assert node.attrib["name"] == "float_value" | ||
|
||
node = nexus.get_node_at_nxdl_path( | ||
"/ENTRY/NXODD_name/AXISNAME/long_name", elem=elem | ||
) | ||
assert node.attrib["name"] == "long_name" | ||
|
||
|
||
def test_get_inherited_nodes(): | ||
"""Test to verify if we receive the right XML element list for a given NXDL path.""" | ||
local_dir = os.path.abspath(os.path.dirname(__file__)) | ||
nxdl_file_path = os.path.join(local_dir, "./NXtest.nxdl.xml") | ||
elem = ET.parse(nxdl_file_path).getroot() | ||
(_, _, elist) = nexus.get_inherited_nodes(nxdl_path="/ENTRY/NXODD_name", elem=elem) | ||
assert len(elist) == 3 |
Oops, something went wrong.