Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
Thank you for making this fix. I don't have time right now, but I'll go through it soon when I have. Just quickly, passing a vector to |
Ah, I agree. Code itself is correct, but my description in this PR is wrong, as is the changelog entry. I'll fix it. |
…/orix into sanitize_direction2color
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
hakonanes
left a comment
There was a problem hiding this comment.
Good changes! I've got a couple of suggestions and requests for improvements.
| h_laue = direction.phase.point_group.laue.name | ||
| if h_laue == self.symmetry.name: |
There was a problem hiding this comment.
I suggest to use the Laue class equality here instead of just the name. The equality check uses the symmetry hash, which includes both the name and rotations (quaternion and handedness).
direction.phase.point_group.laue == self.symmetry
| direction : orix.vector.Vector3d, optional | ||
| Sample direction. If not given, sample Z direction (out of | ||
| plane) is used. | ||
| Viewing direction the defines the IPF coloring. for the TSL |
There was a problem hiding this comment.
Do we need to mention fibers here? The sample direction gives the crystal direction which colors the orientation. I think this is a simpler explanation. And the old "If not given, ..." description should be good still.
| Sample direction. If not given, sample Z direction (out of | ||
| plane) is used. | ||
| Viewing direction the defines the IPF coloring. for the TSL | ||
| colormap, this defines the fiber of orientations that will be |
There was a problem hiding this comment.
Could you:
- Move the parameter description to the class docstring
- Remove this docstring
Otherwise it won't show in our API reference.
This is a remnant of my limited documentation skills some years ago...
There was a problem hiding this comment.
I'm seeing now that the orientation color key inheritance is poorly implemented. If it's fine with you, I'd like to make a few updates to your branch?
| if direction is not None: | ||
| if isinstance(direction, Miller): | ||
| raise ValueError( | ||
| "The Viewing direction must a real space vector (Vector3d), not a cystal vector (Miller)" |
There was a problem hiding this comment.
I suggest trying to keep wording simpler:
| "The Viewing direction must a real space vector (Vector3d), not a cystal vector (Miller)" | |
| "The sample direction must be a sample vector, not a crystal vector" |
| rgb = rgb_key.direction2color(direction=v) | ||
| rgb = rgb_key.direction2color(direction=m1) | ||
| with pytest.raises(ValueError, match="'direction' has a Laue group"): | ||
| rgb = rgb_key.direction2color(direction=m2) |
There was a problem hiding this comment.
| rgb = rgb_key.direction2color(direction=v) | |
| rgb = rgb_key.direction2color(direction=m1) | |
| with pytest.raises(ValueError, match="'direction' has a Laue group"): | |
| rgb = rgb_key.direction2color(direction=m2) | |
| rgb1 = rgb_key.direction2color(direction=v) | |
| rgb2 = rgb_key.direction2color(direction=m1) | |
| assert np.allclose(rgb1, rgb2) | |
| with pytest.raises(ValueError, match="'direction' has a Laue group"): | |
| rgb_key.direction2color(direction=m2) |
| ) | ||
| if not isinstance(direction, Vector3d): | ||
| try: | ||
| direction = Vector3d(np.asanyarray(direction)) |
There was a problem hiding this comment.
Since we allow this, we need to update the signature type hints. I suggest the following:
def __init__(
self, symmetry: Symmetry, direction: Vector3d | list | tuple | None = None
) -> None:| except: | ||
| raise ValueError("'direction' cannot be interpreted as a Vector3d") |
There was a problem hiding this comment.
This error catching should be narrowed, and the thrown error communicated to the user:
| except: | |
| raise ValueError("'direction' cannot be interpreted as a Vector3d") | |
| except DimensionError as err: | |
| raise ValueError("'direction' cannot be interpreted as a Vector3d") from err |
| except: | ||
| raise ValueError("'direction' cannot be interpreted as a Vector3d") | ||
| if direction.size != 1: | ||
| raise ValueError("'direction' only accepts a single vector as an input") |
There was a problem hiding this comment.
| raise ValueError("'direction' only accepts a single vector as an input") | |
| raise ValueError("Only one sample direction can be given") |
| - ``IPFColorKeyTSL`` will now only accept a single ``Vector3D`` as the `direction` setting | ||
| during creation. |
There was a problem hiding this comment.
| - ``IPFColorKeyTSL`` will now only accept a single ``Vector3D`` as the `direction` setting | |
| during creation. | |
| - ``IPFColorKeyTSL`` now only accepts a single ``Vector3d`` as the ``direction``. |
|
Also, how about merging to main and making a patch release 0.14.3 right away? It is a bug after all. |
Description of the change
This should solve #638:
IPFColorKeyTSLmust now be a sample vector (Milleris not allowed)direction2colornow accepts both crystal and sample vectors, as long as the crystals are of the same Laue class as the color key.Progress of the PR
Minimal example of the bug fix or new feature
These operations are allowed:
While these are not, and also throw informative errors
For reviewers
__init__.py.section in
CHANGELOG.rst.__credits__inorix/__init__.pyand in.zenodo.json.