Skip to content

Commit 0e3392c

Browse files
committed
updating docstrings and fixing casting for from_path_ends
1 parent 072fa07 commit 0e3392c

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed

orix/quaternion/misorientation.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ def from_scipy_rotation(
270270
def from_path_ends(
271271
cls, points: Misorientation, closed: bool = False, steps: int = 100
272272
) -> Misorientation:
273-
"""Return misorientations tracing the shortest path between
274-
two or more consecutive points.
273+
"""Return misorientations tracing the shortest path (ignoring
274+
symmetry) between two or more consecutive points.
275+
275276
Parameters
276277
----------
277278
points
@@ -283,21 +284,28 @@ def from_path_ends(
283284
steps
284285
Number of misorientations to return along the path
285286
between each pair of waypoints. The default is 100.
287+
286288
Returns
287289
-------
288290
path
289291
misorientations that map a path between the given waypoints.
292+
293+
Note
294+
-------
295+
This function traces a path between points in SO(3), in which there
296+
is one and only one direct path between every point. The equivalent
297+
is not well-defined for misorientations, which define multiple
298+
symmetrically-equivalent points in SO(3) with non-equivalent paths
299+
between them.
290300
"""
291-
# Confirm `points` are (mis)orientations.
292-
if not isinstance(points, Misorientation):
301+
# Confirm `points` are misorientations.
302+
if type(points) is not cls:
293303
raise TypeError(
294304
f"Points must be a Misorientation, not of type {type(points)}"
295305
)
296306
# Create a path through Quaternion space, then reapply the symmetry.
297-
out = super().from_path_ends(points=points, closed=closed, steps=steps)
298-
path = cls(out.data)
299-
path._symmetry = points._symmetry
300-
return path
307+
out = Rotation.from_path_ends(points=points, closed=closed, steps=steps)
308+
return cls(out.data, symmetry=points.symmetry)
301309

302310
@classmethod
303311
def random(

orix/quaternion/orientation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ def from_scipy_rotation(
351351
def from_path_ends(
352352
cls, points: Orientation, closed: bool = False, steps: int = 100
353353
) -> Misorientation:
354-
"""Return orientations tracing the shortest path between
355-
two or more consecutive points.
354+
"""Return orientations tracing the shortest path (ignoring
355+
symmetry) between two or more consecutive points.
356+
356357
Parameters
357358
----------
358359
points
@@ -364,21 +365,26 @@ def from_path_ends(
364365
steps
365366
Number of orientations to return along the path
366367
between each pair of waypoints. The default is 100.
368+
367369
Returns
368370
-------
369371
path
370372
orientations that map a path between the given waypoints.
373+
374+
Note
375+
-------
376+
This function traces a path between points in SO(3), in which there
377+
is one and only one direct path between every point. The equivalent
378+
is not well-defined for orientations, which define multiple
379+
symmetrically-equivalent points in SO(3) with non-equivalent paths
380+
between them.
371381
"""
372-
# Confirm `points` are orientations.
373-
if not isinstance(points, Orientation):
382+
if type(points) is not cls:
374383
raise TypeError(
375384
f"Points must be an Orientation instance, not of type {type(points)}"
376385
)
377-
# Create a path through Quaternion space, then reapply the symmetry.
378-
out = super().from_path_ends(points=points, closed=closed, steps=steps)
379-
path = cls(out.data)
380-
path._symmetry = points._symmetry
381-
return path
386+
out = Rotation.from_path_ends(points=points, closed=closed, steps=steps)
387+
return cls(out.data, symmetry=points.symmetry)
382388

383389
@classmethod
384390
def random(

orix/tests/test_quaternion/test_orientation.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,10 @@ def test_from_path_ends():
347347
a = Misorientation.from_path_ends(q)
348348
with pytest.raises(TypeError, match="Points must be a Misorientation"):
349349
b = Misorientation.from_path_ends(r)
350-
c = Misorientation.from_path_ends(o)
351-
assert isinstance(c, Misorientation)
350+
with pytest.raises(TypeError, match="Points must be a Misorientation"):
351+
c = Misorientation.from_path_ends(o)
352352
d = Misorientation.from_path_ends(m)
353353
assert isinstance(d, Misorientation)
354-
assert c.symmetry[1] == o.symmetry
355354
assert d.symmetry == m.symmetry
356355

357356
# Orientation sanity checks

0 commit comments

Comments
 (0)