-
Notifications
You must be signed in to change notification settings - Fork 311
Refactor: replace np.ndarray with npt.NDArray in type hints #5346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
511aab1
44687be
6a41449
02a690c
c8af3ab
1709f67
2f935f8
c8aad3d
fb0c7a7
3a69c29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |||||||||||||||||||||||||||||||||||||||||
| from urllib.parse import urlsplit | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import numpy as np | ||||||||||||||||||||||||||||||||||||||||||
| import numpy.typing as nptype | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. npt was already in use as an alias at some files , so I thought nptype would be better choice to avoid any issues . Also can you help me add label to the pr , I don't know how to add it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you point out a spot where it's being used as an alias? I don't see it in this file or the other couple I just checked.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
it's true that we use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @neutrinoceros
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, you mean this section? Lines 1880 to 1897 in 2973f4d
ya, that's an unfortunate re-definition of npt in that function... I'd say (1) keep the import numpy.testing as nptesting
npt_func = getattr(nptesting, func.__name__)Looks like there are a couple other minor spots where we do Thanks! and FYI I'm hoping to take a detailed look this afternoon or tomorrow.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still need to update this import
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
| from more_itertools import always_iterable | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| from yt._maintenance.deprecation import ( | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -687,7 +688,7 @@ def load_amr_grids( | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| def load_particles( | ||||||||||||||||||||||||||||||||||||||||||
| data: Mapping[AnyFieldKey, np.ndarray | tuple[np.ndarray, str]], | ||||||||||||||||||||||||||||||||||||||||||
| data: Mapping[AnyFieldKey, nptype.NDArray | tuple[nptype.NDArray, str]], | ||||||||||||||||||||||||||||||||||||||||||
| length_unit=None, | ||||||||||||||||||||||||||||||||||||||||||
| bbox=None, | ||||||||||||||||||||||||||||||||||||||||||
| sim_time=None, | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -826,7 +827,7 @@ def parse_unit(unit, dimension): | |||||||||||||||||||||||||||||||||||||||||
| field_units, data, _ = process_data(data) | ||||||||||||||||||||||||||||||||||||||||||
| sfh = StreamDictFieldHandler() | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| pdata: dict[AnyFieldKey, np.ndarray | tuple[np.ndarray, str]] = {} | ||||||||||||||||||||||||||||||||||||||||||
| pdata: dict[AnyFieldKey, nptype.NDArray | tuple[nptype.NDArray, str]] = {} | ||||||||||||||||||||||||||||||||||||||||||
| for key in data.keys(): | ||||||||||||||||||||||||||||||||||||||||||
| field: FieldKey | ||||||||||||||||||||||||||||||||||||||||||
| if not isinstance(key, tuple): | ||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1816,7 +1817,7 @@ def load_hdf5_file( | |||||||||||||||||||||||||||||||||||||||||
| fn: Union[str, "os.PathLike[str]"], | ||||||||||||||||||||||||||||||||||||||||||
| root_node: str | None = "/", | ||||||||||||||||||||||||||||||||||||||||||
| fields: list[str] | None = None, | ||||||||||||||||||||||||||||||||||||||||||
| bbox: np.ndarray | None = None, | ||||||||||||||||||||||||||||||||||||||||||
| bbox: nptype.NDArray | None = None, | ||||||||||||||||||||||||||||||||||||||||||
| nchunks: int = 0, | ||||||||||||||||||||||||||||||||||||||||||
| dataset_arguments: dict | None = None, | ||||||||||||||||||||||||||||||||||||||||||
| ): | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.