moreniius 0.2.4__py3-none-any.whl → 0.2.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- moreniius/mccode/instr.py +24 -18
- moreniius/mccode/orientation.py +1 -0
- moreniius/utils.py +19 -2
- {moreniius-0.2.4.dist-info → moreniius-0.2.5.dist-info}/METADATA +7 -7
- {moreniius-0.2.4.dist-info → moreniius-0.2.5.dist-info}/RECORD +8 -8
- {moreniius-0.2.4.dist-info → moreniius-0.2.5.dist-info}/WHEEL +1 -1
- {moreniius-0.2.4.dist-info → moreniius-0.2.5.dist-info}/entry_points.txt +0 -0
- {moreniius-0.2.4.dist-info → moreniius-0.2.5.dist-info}/top_level.txt +0 -0
moreniius/mccode/instr.py
CHANGED
|
@@ -2,7 +2,7 @@ from zenlog import log
|
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
3
|
from mccode_antlr.instr import Instr
|
|
4
4
|
from mccode_antlr.common import Expr
|
|
5
|
-
from nexusformat.nexus import NXfield, NXcollection
|
|
5
|
+
from nexusformat.nexus import NXfield, NXgroup, NXcollection
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
@dataclass
|
|
@@ -15,7 +15,8 @@ class NXInstr:
|
|
|
15
15
|
"""Start the C translation to ensure McCode-oddities are handled before any C-code parsing."""
|
|
16
16
|
from mccode_antlr.common import ShapeType, DataType, Value
|
|
17
17
|
from mccode_antlr.translators.target import MCSTAS_GENERATOR
|
|
18
|
-
from mccode_antlr.translators.c import CTargetVisitor
|
|
18
|
+
from mccode_antlr.translators.c import CTargetVisitor
|
|
19
|
+
from mccode_antlr.translators.c_listener import CDeclarator
|
|
19
20
|
from mccode_antlr.translators.c_listener import evaluate_c_defined_expressions
|
|
20
21
|
config = dict(default_main=True, enable_trace=False, portable=False, include_runtime=True,
|
|
21
22
|
embed_instrument_file=False, verbose=False, output=None)
|
|
@@ -25,9 +26,9 @@ class NXInstr:
|
|
|
25
26
|
# translator.component_uservars is a dictionary of lists for each component type of `CDeclaration` objects.
|
|
26
27
|
|
|
27
28
|
# only worry about instrument level variables for the moment, and convert the CDeclarations into Expr objects
|
|
28
|
-
def c_declaration_to_expr(dec:
|
|
29
|
+
def c_declaration_to_expr(dec: CDeclarator) -> Expr:
|
|
29
30
|
expr = Expr(Value(None)) if dec.init is None else Expr.parse(dec.init)
|
|
30
|
-
expr.data_type = DataType.from_name(dec.
|
|
31
|
+
expr.data_type = DataType.from_name(dec.dtype)
|
|
31
32
|
if dec.is_pointer or dec.is_array:
|
|
32
33
|
expr.shape_type = ShapeType.vector
|
|
33
34
|
return expr
|
|
@@ -84,22 +85,27 @@ class NXInstr:
|
|
|
84
85
|
not_expr = [x for x in nx_args[0] if x != 'expression']
|
|
85
86
|
if len(not_expr) == 1:
|
|
86
87
|
not_expr_arg = nx_args[0][not_expr[0]]
|
|
87
|
-
if isinstance(not_expr_arg, NXfield):
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
# if isinstance(not_expr_arg, NXfield):
|
|
89
|
+
# # We have and want an NXfield, but it might be missing attributes specified in the nx_kwargs
|
|
90
|
+
# # Passing the keywords to the NXfield constructor versus this method is not identical,
|
|
91
|
+
# # since some keyword arguments are reserved (and only some of which are noted)
|
|
92
|
+
# # Explicit keywords, used in the constructor:
|
|
93
|
+
# # value, name, shape, dtype, group, attrs
|
|
94
|
+
# # Keywords extracted from the kwargs dict, if present (and all controlling HDF5 file attributes?):
|
|
95
|
+
# # chunks, compression, compression_opts, fillvalue, fletcher32, maxshape, scaleoffset, shuffle
|
|
96
|
+
# # For now, just assume all keywords provided here are _actually_ attributes for the NXfield
|
|
97
|
+
# # which is an extension of a dict, but can *not* use the update method, since the __setitem__
|
|
98
|
+
# # method is overridden to wrap inputs in NXattr objects :/
|
|
99
|
+
# for k, v in nx_kwargs.items():
|
|
100
|
+
# not_expr_arg.attrs[k] = v
|
|
101
|
+
# return not_expr_arg
|
|
101
102
|
|
|
102
103
|
# TODO make this return an nx_class once we're sure that nx_kwargs is parseable (no mccode_antlr.Expr)
|
|
104
|
+
if all(x in not_expr_arg for x in ('module', 'config')):
|
|
105
|
+
# This is a file-writer stream directive? So make a group
|
|
106
|
+
return NXgroup(entries={not_expr[0]: not_expr_arg}, **nx_kwargs)
|
|
107
|
+
print('!!')
|
|
108
|
+
print(not_expr_arg)
|
|
103
109
|
return nx_class(not_expr_arg, **nx_kwargs)
|
|
104
110
|
else:
|
|
105
111
|
raise RuntimeError('Not sure what I should do here')
|
moreniius/mccode/orientation.py
CHANGED
|
@@ -18,6 +18,7 @@ class NXPart:
|
|
|
18
18
|
return self.instr.make_nx(nx_class, *args, **kwargs)
|
|
19
19
|
|
|
20
20
|
def make_translation(self, norm, vec, dep):
|
|
21
|
+
# if `norm` is a link or NXlog, we should make a group not an NXfield
|
|
21
22
|
return self.make_nx(NXfield, norm, vector=vec, depends_on=dep, transformation_type='translation', units='m')
|
|
22
23
|
|
|
23
24
|
def translations(self, dep: str, name: str) -> list[tuple[str, NXfield]]:
|
moreniius/utils.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from mccode_antlr.instr import Instance
|
|
2
|
-
from nexusformat.nexus import NXevent_data
|
|
2
|
+
from nexusformat.nexus import NXevent_data, NXfield
|
|
3
3
|
|
|
4
4
|
class NotNXdict:
|
|
5
5
|
"""Wrapper class to prevent NXfield-parsing of the held dictionary"""
|
|
@@ -12,6 +12,10 @@ class NotNXdict:
|
|
|
12
12
|
def __repr__(self):
|
|
13
13
|
return f"NotNXdict<{self.value}>"
|
|
14
14
|
|
|
15
|
+
def __str__(self):
|
|
16
|
+
from json import dumps
|
|
17
|
+
return dumps(self.value)
|
|
18
|
+
|
|
15
19
|
|
|
16
20
|
def outer_transform_dependency(transformations):
|
|
17
21
|
"""For a NXtransformations group, find the most-dependent transformation name
|
|
@@ -36,7 +40,20 @@ def outer_transform_dependency(transformations):
|
|
|
36
40
|
obj = getattr(transformations, name)
|
|
37
41
|
if not hasattr(obj, 'depends_on'):
|
|
38
42
|
raise ValueError(f'{name} in {names} dependency chain missing "depends_on" attribute')
|
|
39
|
-
|
|
43
|
+
if isinstance(obj.depends_on, NXfield):
|
|
44
|
+
# obj.depends_on is an NXfield object; which has a number of properties
|
|
45
|
+
# nxgroup - the parent group
|
|
46
|
+
# dtype - string or numpy dtype
|
|
47
|
+
# shape - list or tuple of ints
|
|
48
|
+
# attrs - dict of attributes
|
|
49
|
+
# nxdata - a scalar or numpy array or string
|
|
50
|
+
# nxpath - string, where this object is in the tree
|
|
51
|
+
# nxroot - the root NXgroup object containing this object
|
|
52
|
+
# I _think_ we *always* want the data stored in this object
|
|
53
|
+
return obj.depends_on.nxdata
|
|
54
|
+
elif isinstance(obj.depends_on, str):
|
|
55
|
+
return obj.depends_on
|
|
56
|
+
raise ValueError(f"depends_on attribute of {name} is not an NXfield or str")
|
|
40
57
|
|
|
41
58
|
# depends = {name: getattr(transformations, name).depends_on for name in names}
|
|
42
59
|
depends = {name: depends_on_per(name) for name in names}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: moreniius
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Author-email: Gregory Tucker <gregory.tucker@ess.eu>
|
|
5
5
|
Classifier: License :: OSI Approved :: BSD License
|
|
6
6
|
Classifier: Development Status :: 2 - Pre-Alpha
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: zenlog
|
|
9
|
-
Requires-Dist: platformdirs
|
|
10
|
-
Requires-Dist:
|
|
11
|
-
Requires-Dist:
|
|
12
|
-
Requires-Dist:
|
|
8
|
+
Requires-Dist: zenlog>=1.1
|
|
9
|
+
Requires-Dist: platformdirs>=3.11
|
|
10
|
+
Requires-Dist: importlib_metadata; python_version < "3.8"
|
|
11
|
+
Requires-Dist: mccode-antlr[hdf5]>=0.9.2
|
|
12
|
+
Requires-Dist: nexusformat>=1.0.6
|
|
13
13
|
|
|
14
14
|
# moreniius
|
|
15
15
|
A project to contain custom components required to use `eniius` to produce `NeXus Structure` `JSON` from `mccode-antlr` simulated instruments.
|
|
@@ -3,16 +3,16 @@ moreniius/additions.py,sha256=6Hhhc4LDUsnBj27Iil-EFFzQm1xd2M45hfcVQYEjxiI,17615
|
|
|
3
3
|
moreniius/moreniius.py,sha256=cU3CrfMC1kOnHO77yq5sZfDqRuA38G5kA3RUXFNGP2U,1455
|
|
4
4
|
moreniius/nexus_structure.py,sha256=i9CxYwJl4eKP9IIYR80MI3f54Yh0RPDFviZaulE5IOc,1709
|
|
5
5
|
moreniius/nxoff.py,sha256=WHp9wYNn_4Hcx8Nzi9rpX1p8_iwI-AdgTQouSAEG8N4,3288
|
|
6
|
-
moreniius/utils.py,sha256=
|
|
6
|
+
moreniius/utils.py,sha256=R81eHjc0EWjMsP-Z8WI9sZkc_QY357z_aYziflQAUEU,9238
|
|
7
7
|
moreniius/writer.py,sha256=rZSOpSmCAiY1KS3YAWKBXZUWTJFLyrkZT-zeZfyENV8,6178
|
|
8
8
|
moreniius/mccode/__init__.py,sha256=1QiZdh90G3gp_WlVpdJB_ZGauoW0GJEQ13Nelaqa5JE,151
|
|
9
9
|
moreniius/mccode/comp.py,sha256=uR1L5nLfYPHhMKd3XnDbqf5xhkfwfPLRnttREc3jqBg,7382
|
|
10
10
|
moreniius/mccode/instance.py,sha256=4nqJ3ne6yXCEvsa3FIKUcGDYP_z7cAr46JhakDTB6qs,8055
|
|
11
|
-
moreniius/mccode/instr.py,sha256=
|
|
11
|
+
moreniius/mccode/instr.py,sha256=q0NS2hH7eWaHu4xzdcPRRx4M-9WHA2IcElgO__PXjiQ,6138
|
|
12
12
|
moreniius/mccode/mccode.py,sha256=6NEXovuG-6itzlPgPklNOiZQ-MlldKF20p4TxV8n4BA,3228
|
|
13
|
-
moreniius/mccode/orientation.py,sha256=
|
|
14
|
-
moreniius-0.2.
|
|
15
|
-
moreniius-0.2.
|
|
16
|
-
moreniius-0.2.
|
|
17
|
-
moreniius-0.2.
|
|
18
|
-
moreniius-0.2.
|
|
13
|
+
moreniius/mccode/orientation.py,sha256=khT0jTMXyXkPCoEpDg-eLKulF-J2wIqNhUi1NzFWvto,3907
|
|
14
|
+
moreniius-0.2.5.dist-info/METADATA,sha256=9d8qeZuOv6YNkojoOPY41lTdhv7tVycA2m5XM6ytqdk,620
|
|
15
|
+
moreniius-0.2.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
16
|
+
moreniius-0.2.5.dist-info/entry_points.txt,sha256=Ga3k4P4fyBt5_dJ03Oapic2Qlgqv9jufQGdxWiz_j2A,63
|
|
17
|
+
moreniius-0.2.5.dist-info/top_level.txt,sha256=RzMo23UfVhgQeuOYeS5P9I0qVbxx4Gbe6Roc29Mr02c,10
|
|
18
|
+
moreniius-0.2.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|