Conversation
|
|
||
|
|
||
| def _meshgrid2d(x, y): | ||
| def _meshgrid2d(x: np.ndarray, y: np.ndarray) -> tuple[np.ndarray, np.ndarray]: |
There was a problem hiding this comment.
We're sticking with the typing built into numpy, as using np.ndarray technically doesn't work the way we would like for typing.
Proposed:
from numpy.typing import NDArray
...
def _meshgrid2d(x: NDArray, y: NDArray) -> tuple[NDArray, NDArray]:
...| stops: np.ndarray, | ||
| offset: float, | ||
| ccw: bool = False, | ||
| ) -> np.ndarray: |
There was a problem hiding this comment.
For this section, the same comment about using numpy.typing.NDArray also applies.
|
|
||
|
|
||
| def paintgrid_init(params): | ||
| def paintgrid_init(params: dict[str, Any]) -> None: |
There was a problem hiding this comment.
Is there a more appropriate type than Any to use here? It would also be preferable for us to use a typing.TypedDict for dictionary typing, as we've done here.
| ome: int, | ||
| dpix_eta: int, | ||
| dpix_ome: int, | ||
| etaOmeMap: np.ndarray, |
There was a problem hiding this comment.
np.ndarray -> numpy.typing.NDArray
ZackAttack614
left a comment
There was a problem hiding this comment.
I'll defer to others' judgement on the specific parameter documentation, but as far as typing goes, we can improve this using typing.TypedDict and numpy.typing.NDArray where appropriate. I'm happy to advise and assist as is useful.
|
Sorry again, Zack, I accidentally closed this. I had rebased the branch to the latest version, pushed it to my fork, where is 2 commits ahead and 2 behind. So I thought I could just delete the branch and push it up as a new branch. Unsurprisingly, it killed the PR. Anyway, the NDArrays stuff I updated (38 instances). Now I am looking at the TypedDict. I'll resubmit when the PR is ready again. |
Overview
This cleans up the documentation for
hexrd.hedm.indexer.pyand adds python type hints.This update was mostly done by Claude, with some minor adjustments by me. The documentation is way better, and the type hints are very good too.
I've run several problems on both the
masterand theindexer-cleanupbranches, and all of the indexer output is identical for all of the problems, includingaccepted-orientations-ruby.dat,eta-ome-maps-ruby.npz,grains.out, andscored-orientations-ruby.npz.Comparing the log files, howevers, shows a peculiar difference. If we strip the log files of their timestamp and diff, ignoring elapsed time differences, we get:
First, comparing new branch to current a recent master (2 or 3 days ago):
And also comparing the latest master branch (today) to the recent master:
The difference does not seem to be related to the changes in
indexer.py, as the current master branch gives different results from a recent one. Also, the mean reflections per grain is calculated after the indexer is called, in thefind_orientations.create_clustering_parameters()function.Affected Workflows
This is part of the find-orientations workflow.
Documentation Changes
Only internal documentation has changed. No external documentation needs to be changed.