Skip to content
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

Fix remaining numpy mypy issues #521

Merged
merged 6 commits into from
Feb 28, 2022
Merged

Conversation

uri-granta
Copy link
Collaborator

@uri-granta uri-granta commented Feb 28, 2022

This fixes the remaining issues exposed by the numpy stubs introduce in 1.21 and adds a workflow to test this.

@uri-granta uri-granta requested review from hstojic and removed request for hstojic February 28, 2022 11:14
@uri-granta uri-granta marked this pull request as draft February 28, 2022 11:26
@@ -41,7 +42,7 @@
],
)
def test_split_acquisition_function(
f: AcquisitionFunction, x: np.ndarray, split_size: int, expected_batches: int
f: AcquisitionFunction, x: np.ndarray[Any, Any], split_size: int, expected_batches: int
Copy link
Collaborator

Choose a reason for hiding this comment

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

so here we explicitly state the type of objects in arrays, similar as with tuple, List etc?

Copy link
Collaborator Author

@uri-granta uri-granta Feb 28, 2022

Choose a reason for hiding this comment

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

Yes: the parameters refer to shape and dtype (though shape isn't properly supported at the moment, and we currently don't handle dtypes well enough to use that part). There's a cleaner shorthand in numpy.typing called npt.NDArray but that doens't work with older versions of numpy.

Copy link
Collaborator

@hstojic hstojic left a comment

Choose a reason for hiding this comment

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

looks good to me

@uri-granta uri-granta marked this pull request as ready for review February 28, 2022 11:53
@uri-granta uri-granta linked an issue Feb 28, 2022 that may be closed by this pull request
# pytest uses yield in a funny way, so we use type ignore
@pytest.fixture(name="keras_float") # type: ignore
def _keras_float() -> None:
@pytest.fixture(name="keras_float")
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we then move this fixture up to tests/conftest.py since we have it now in multiple places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 but planning to tidy up the conftests in a separate PR

@uri-granta uri-granta merged commit 947034b into develop Feb 28, 2022
@uri-granta uri-granta deleted the uri/test_with_numpy_stubs branch February 28, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpy-related type errors are hidden by the absence of numpy stubs
2 participants