moreniius 0.2.1__py3-none-any.whl → 0.2.2__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 +2 -1
- moreniius/mccode/orientation.py +21 -7
- moreniius/utils.py +8 -1
- {moreniius-0.2.1.dist-info → moreniius-0.2.2.dist-info}/METADATA +1 -1
- {moreniius-0.2.1.dist-info → moreniius-0.2.2.dist-info}/RECORD +8 -8
- {moreniius-0.2.1.dist-info → moreniius-0.2.2.dist-info}/WHEEL +1 -1
- {moreniius-0.2.1.dist-info → moreniius-0.2.2.dist-info}/entry_points.txt +0 -0
- {moreniius-0.2.1.dist-info → moreniius-0.2.2.dist-info}/top_level.txt +0 -0
moreniius/mccode/instr.py
CHANGED
|
@@ -83,7 +83,8 @@ class NXInstr:
|
|
|
83
83
|
'expression' in nx_args[0]:
|
|
84
84
|
not_expr = [x for x in nx_args[0] if x != 'expression']
|
|
85
85
|
if len(not_expr) == 1:
|
|
86
|
-
return
|
|
86
|
+
# TODO make this return an nx_class once we're sure that nx_kwargs is parseable (no mccode_antlr.Expr)
|
|
87
|
+
return nx_class(nx_args[0][not_expr[0]], **nx_kwargs)
|
|
87
88
|
else:
|
|
88
89
|
raise RuntimeError('Not sure what I should do here')
|
|
89
90
|
return nx_class(*nx_args, **nx_kwargs)
|
moreniius/mccode/orientation.py
CHANGED
|
@@ -17,14 +17,28 @@ class NXPart:
|
|
|
17
17
|
def make_nx(self, nx_class, *args, **kwargs):
|
|
18
18
|
return self.instr.make_nx(nx_class, *args, **kwargs)
|
|
19
19
|
|
|
20
|
-
def
|
|
20
|
+
def make_translation(self, norm, vec, dep):
|
|
21
|
+
return self.make_nx(NXfield, norm, vector=vec, depends_on=dep, transformation_type='translation', units='m')
|
|
22
|
+
|
|
23
|
+
def translations(self, dep: str, name: str) -> list[tuple[str, NXfield]]:
|
|
21
24
|
from mccode_antlr.instr import RotationPart
|
|
25
|
+
from mccode_antlr.common import Expr, Value
|
|
22
26
|
if isinstance(self.o, RotationPart):
|
|
23
27
|
raise RuntimeError('Part is a rotation!')
|
|
24
28
|
pos = self.o.position()
|
|
29
|
+
if any(isinstance(c, (Expr, Value)) for c in (pos.x, pos.y, pos.z)):
|
|
30
|
+
translations = []
|
|
31
|
+
print(f'{pos.x=} {pos.y=} {pos.z=}')
|
|
32
|
+
for n, c, v in (('x', pos.x, [1, 0, 0]), ('y', pos.y, [0, 1, 0]), ('z', pos.z, [0, 0, 1])):
|
|
33
|
+
if c != Expr.parse('0'):
|
|
34
|
+
next_name = f'{name}_{n}'
|
|
35
|
+
translations.append((next_name, self.make_translation(c, v, dep)))
|
|
36
|
+
dep = next_name
|
|
37
|
+
return translations
|
|
38
|
+
# vector is all constants, hopefully
|
|
25
39
|
norm = pos.length()
|
|
26
|
-
vec = pos if norm.is_zero else pos
|
|
27
|
-
return self.
|
|
40
|
+
vec = pos if norm.is_zero else pos/norm
|
|
41
|
+
return [(name, self.make_translation(norm, vec, dep))]
|
|
28
42
|
|
|
29
43
|
def rotation(self, dep: str) -> NXfield:
|
|
30
44
|
from mccode_antlr.instr import TranslationPart
|
|
@@ -43,11 +57,11 @@ class NXPart:
|
|
|
43
57
|
|
|
44
58
|
def transformations(self, name: str, dep: str | None = None) -> list[tuple[str, NXfield]]:
|
|
45
59
|
if self.o.is_translation and self.o.is_rotation:
|
|
46
|
-
|
|
47
|
-
rot = self.rotation(
|
|
48
|
-
return [
|
|
60
|
+
ops = self.translations(dep, name)
|
|
61
|
+
rot = self.rotation(ops[-1][0])
|
|
62
|
+
return [*ops, (f'{name}_r', rot)]
|
|
49
63
|
elif self.o.is_translation:
|
|
50
|
-
return
|
|
64
|
+
return self.translations(dep, name)
|
|
51
65
|
elif self.o.is_rotation:
|
|
52
66
|
return [(name, self.rotation(dep))]
|
|
53
67
|
else:
|
moreniius/utils.py
CHANGED
|
@@ -32,7 +32,14 @@ def outer_transform_dependency(transformations):
|
|
|
32
32
|
names = list(transformations)
|
|
33
33
|
if len(names) == 1:
|
|
34
34
|
return names[0]
|
|
35
|
-
|
|
35
|
+
def depends_on_per(name):
|
|
36
|
+
obj = getattr(transformations, name)
|
|
37
|
+
if not hasattr(obj, 'depends_on'):
|
|
38
|
+
raise ValueError(f'{name} in {names} dependency chain missing "depends_on" attribute')
|
|
39
|
+
return obj.depends_on
|
|
40
|
+
|
|
41
|
+
# depends = {name: getattr(transformations, name).depends_on for name in names}
|
|
42
|
+
depends = {name: depends_on_per(name) for name in names}
|
|
36
43
|
externals = [v for k, v in depends.items() if v not in depends]
|
|
37
44
|
if len(externals) != 1:
|
|
38
45
|
raise RuntimeError(f"Dependency chain {depends} should have one absolute dependency, found {externals} instead")
|
|
@@ -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=3ix8lLQwzwdx_nm-YEoD17z7s4h4CGda5lzVdD8M8lA,8386
|
|
7
7
|
moreniius/writer.py,sha256=DOwzpDqoXiDXdtV-hRZVtF5lNBBoYy0UO5_bq89d1lc,6325
|
|
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=8Thl4RuMi2X4ruNtI8-l8S_2OHtW_38F2Pv_FisuImc,4505
|
|
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=kfOTiHgG68huQdh_ojd2NXxyAxFQoCn6FavwSOulh5E,3923
|
|
14
|
+
moreniius-0.2.2.dist-info/METADATA,sha256=3UH0RNB71wN-kUvb57Bdj9GLU1pKmudBgJ0iWExHoAo,625
|
|
15
|
+
moreniius-0.2.2.dist-info/WHEEL,sha256=uCRv0ZEik_232NlR4YDw4Pv3Ajt5bKvMH13NUU7hFuI,91
|
|
16
|
+
moreniius-0.2.2.dist-info/entry_points.txt,sha256=Ga3k4P4fyBt5_dJ03Oapic2Qlgqv9jufQGdxWiz_j2A,63
|
|
17
|
+
moreniius-0.2.2.dist-info/top_level.txt,sha256=RzMo23UfVhgQeuOYeS5P9I0qVbxx4Gbe6Roc29Mr02c,10
|
|
18
|
+
moreniius-0.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|