Skip to content

Commit a3ffb06

Browse files
committed
updating docstrings and fixing casting for from_path_ends
1 parent 247b947 commit a3ffb06

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
@@ -277,8 +277,9 @@ def from_scipy_rotation(
277277
def from_path_ends(
278278
cls, points: Misorientation, closed: bool = False, steps: int = 100
279279
) -> Misorientation:
280-
"""Return misorientations tracing the shortest path between
281-
two or more consecutive points.
280+
"""Return misorientations tracing the shortest path (ignoring
281+
symmetry) between two or more consecutive points.
282+
282283
Parameters
283284
----------
284285
points
@@ -290,21 +291,28 @@ def from_path_ends(
290291
steps
291292
Number of misorientations to return along the path
292293
between each pair of waypoints. The default is 100.
294+
293295
Returns
294296
-------
295297
path
296298
misorientations that map a path between the given waypoints.
299+
300+
Note
301+
-------
302+
This function traces a path between points in SO(3), in which there
303+
is one and only one direct path between every point. The equivalent
304+
is not well-defined for misorientations, which define multiple
305+
symmetrically-equivalent points in SO(3) with non-equivalent paths
306+
between them.
297307
"""
298-
# Confirm `points` are (mis)orientations.
299-
if not isinstance(points, Misorientation):
308+
# Confirm `points` are misorientations.
309+
if type(points) is not cls:
300310
raise TypeError(
301311
f"Points must be a Misorientation, not of type {type(points)}"
302312
)
303313
# Create a path through Quaternion space, then reapply the symmetry.
304-
out = super().from_path_ends(points=points, closed=closed, steps=steps)
305-
path = cls(out.data)
306-
path._symmetry = points._symmetry
307-
return path
314+
out = Rotation.from_path_ends(points=points, closed=closed, steps=steps)
315+
return cls(out.data, symmetry=points.symmetry)
308316

309317
@classmethod
310318
def random(

orix/quaternion/orientation.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ def from_scipy_rotation(
356356
def from_path_ends(
357357
cls, points: Orientation, closed: bool = False, steps: int = 100
358358
) -> Misorientation:
359-
"""Return orientations tracing the shortest path between
360-
two or more consecutive points.
359+
"""Return orientations tracing the shortest path (ignoring
360+
symmetry) between two or more consecutive points.
361+
361362
Parameters
362363
----------
363364
points
@@ -369,21 +370,26 @@ def from_path_ends(
369370
steps
370371
Number of orientations to return along the path
371372
between each pair of waypoints. The default is 100.
373+
372374
Returns
373375
-------
374376
path
375377
orientations that map a path between the given waypoints.
378+
379+
Note
380+
-------
381+
This function traces a path between points in SO(3), in which there
382+
is one and only one direct path between every point. The equivalent
383+
is not well-defined for orientations, which define multiple
384+
symmetrically-equivalent points in SO(3) with non-equivalent paths
385+
between them.
376386
"""
377-
# Confirm `points` are orientations.
378-
if not isinstance(points, Orientation):
387+
if type(points) is not cls:
379388
raise TypeError(
380389
f"Points must be an Orientation instance, not of type {type(points)}"
381390
)
382-
# Create a path through Quaternion space, then reapply the symmetry.
383-
out = super().from_path_ends(points=points, closed=closed, steps=steps)
384-
path = cls(out.data)
385-
path._symmetry = points._symmetry
386-
return path
391+
out = Rotation.from_path_ends(points=points, closed=closed, steps=steps)
392+
return cls(out.data, symmetry=points.symmetry)
387393

388394
@classmethod
389395
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)