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

chore(hardware): upgrade numpy #9880

Merged
merged 2 commits into from
Apr 6, 2022
Merged

chore(hardware): upgrade numpy #9880

merged 2 commits into from
Apr 6, 2022

Conversation

sfoster1
Copy link
Member

@sfoster1 sfoster1 commented Apr 5, 2022

Building on #9871 and other work by @mcous , bump the version of numpy used in hardware to 1.21.1 which matches what will be on the OT-2 and has some better typing.

Bumping numpy revealed some real issues with our code and also some real
issues with numpy's as-yet incomplete typing, such as

  • many functions particularly in numpy.linalg aren't typed, like norm
  • many arithmetic ops and functions behave quite strangely, often
    returning a np.Float[_64bit, Any] instead of a float64 equivalent
  • ndarray typing is still not quite there, but that's mostly because
    some typing peps need to be merged first

This should be a low risk set of changes.

mcous and others added 2 commits April 4, 2022 16:08
Bumping numpy revealed some real issues with our code and also some real
issues with numpy's as-yet incomplete typing, such as
- many functions particularly in numpy.linalg aren't typed, like `norm`
- many arithmetic ops and functions behave quite strangely, often
returning a `np.Float[_64bit, Any]` instead of a float64 equivalent
- ndarray typing is still not quite there, but that's mostly because
some typing peps need to be merged first

This should be a low risk set of changes.
@sfoster1 sfoster1 requested review from a team as code owners April 5, 2022 14:42
@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #9880 (0befaf2) into edge (c4e3976) will decrease coverage by 0.20%.
The diff coverage is 76.31%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #9880      +/-   ##
==========================================
- Coverage   75.20%   75.00%   -0.21%     
==========================================
  Files        2005     2007       +2     
  Lines       53156    53293     +137     
  Branches     5148     5148              
==========================================
- Hits        39976    39971       -5     
- Misses      12161    12303     +142     
  Partials     1019     1019              
Flag Coverage Δ
hardware 65.59% <76.31%> (-3.31%) ⬇️
notify-server 89.17% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
hardware/opentrons_hardware/scripts/move.py 0.00% <0.00%> (ø)
hardware/opentrons_hardware/scripts/plan_motion.py 0.00% <0.00%> (ø)
...are/hardware_control/motion_planning/move_utils.py 89.83% <75.00%> (-4.19%) ⬇️
...hardware/hardware_control/motion_planning/types.py 90.99% <83.33%> (-0.76%) ⬇️
...ware/opentrons_hardware/hardware_control/motion.py 90.90% <100.00%> (ø)
...ons_hardware/hardware_control/move_group_runner.py 90.43% <100.00%> (+0.08%) ⬆️
...e/hardware_control/motion_planning/move_manager.py 89.36% <0.00%> (-4.26%) ⬇️
...are/opentrons_hardware/scripts/gripper_currents.py 0.00% <0.00%> (ø)
hardware/opentrons_hardware/scripts/gripper.py 0.00% <0.00%> (ø)

Copy link
Contributor

@mcous mcous left a comment

Choose a reason for hiding this comment

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

Code changes look good to me! Should probably wait for an @Opentrons/embedded-sw review before merging due to my general lack of familiarity with this code, though

@@ -16,6 +16,9 @@
vectorize,
)

if TYPE_CHECKING:
Copy link
Contributor

@mcous mcous Apr 5, 2022

Choose a reason for hiding this comment

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

If we want to get rid of this annoying Codecov message, we should copy over the .coveragerc from api to ignore if TYPE_CHECKING: blocks

[report]
exclude_lines =
    @overload
    if TYPE_CHECKING:

@@ -484,5 +490,5 @@ def unit_vector_multiplication(
unit_vector: Coordinates[AxisKey, np.float64], value: np.float64
) -> Coordinates[AxisKey, np.float64]:
"""Multiply coordinates type by a float value."""
targets: np.ndarray = vectorize(unit_vector) * value
targets: "NDArray[np.float64]" = vectorize(unit_vector) * value
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we prefer from __future__ import annotations over string-types, where possible?

@sfoster1 sfoster1 merged commit 7e1ffe5 into edge Apr 6, 2022
@sfoster1 sfoster1 deleted the hardware_upgrade-numpy branch April 6, 2022 17:34
ecormany pushed a commit that referenced this pull request Apr 8, 2022
Bumping numpy revealed some real issues with our code and also some real
issues with numpy's as-yet incomplete typing, such as
- many functions particularly in numpy.linalg aren't typed, like `norm`
- many arithmetic ops and functions behave quite strangely, often
returning a `np.Float[_64bit, Any]` instead of a float64 equivalent
- ndarray typing is still not quite there, but that's mostly because
some typing peps need to be merged first

This should be a low risk set of changes.

Co-authored-by: Mike Cousins <[email protected]>
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.

3 participants