Skip to content

Indexer cleanup#909

Open
donald-e-boyce wants to merge 6 commits intoHEXRD:masterfrom
donald-e-boyce:indexer-cleanup
Open

Indexer cleanup#909
donald-e-boyce wants to merge 6 commits intoHEXRD:masterfrom
donald-e-boyce:indexer-cleanup

Conversation

@donald-e-boyce
Copy link
Copy Markdown
Collaborator

Overview

See #908, unintentionally closed. This cleans up documentation and typing in indexer.py. The latest changes the ParamMP variable to a TypedDict.

@donald-e-boyce donald-e-boyce added the documentation Improvements or additions to documentation label Mar 26, 2026
Copy link
Copy Markdown
Collaborator

@ZackAttack614 ZackAttack614 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely better! I'll propose that we add in typing for the elements of numpy arrays, as well. We've done that in most places, e.g. here. That allows us to statically analyze the script and know whether the data type is an int, float64, bool, or str - all of which are matrix element types we've worked with in the HEXRD ecosystem.

@donald-e-boyce
Copy link
Copy Markdown
Collaborator Author

donald-e-boyce commented Mar 31, 2026

So, in your file, what is the difference between np.integer and np.signedinteger? And is np.floatingpreferred for any float that is not explicitly something more specific? In other words, is np.floating, np.integer, and np.bool enough? And why are there numpy types for non-NDArrays? e.g. tTheta: np.floating -- couldn't that just be float?

class HKLData(TypedDict):
    hklID: int
    hkl: NDArray[np.integer]
    tTheta: np.floating
    dSpacings: np.floating
    tThetaLo: np.floating
    tThetaHi: np.floating
    latPlnNrmls: NDArray[np.floating]
    symHKLs: NDArray[np.signedinteger]
    centrosym: bool

@donald-e-boyce
Copy link
Copy Markdown
Collaborator Author

So, technically, it looks like it's wrong to use numpy datatypes for regular floats and ints.

In [2]: x = 10.0

In [3]: isinstance(x, np.floating)
Out[3]: False

@donald-e-boyce
Copy link
Copy Markdown
Collaborator Author

donald-e-boyce commented Apr 1, 2026

OH, I see. It's a typedict. I thought they were type hints.
never mind

@donald-e-boyce
Copy link
Copy Markdown
Collaborator Author

OK, I added the numpy scalar types and pushed everything up. Should be good now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants