Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

348 replaced point 3d and point 2d to support arithmetic, using numpy arrays#623

Merged
d-perl merged 26 commits into
mainfrom
348_replace_point_3d_to_support_arithmetic
Jun 2, 2023
Merged

348 replaced point 3d and point 2d to support arithmetic, using numpy arrays#623
d-perl merged 26 commits into
mainfrom
348_replace_point_3d_to_support_arithmetic

Conversation

@olliesilvester

@olliesilvester olliesilvester commented Apr 20, 2023

Copy link
Copy Markdown
Contributor

Fixes #348

Link to dodal PR: #37

To test:

  1. Check np.array() calls are suitable
  2. Confirm all unit tests pass

@codecov

codecov Bot commented Apr 21, 2023

Copy link
Copy Markdown

Codecov Report

Merging #623 (dfa5e68) into main (69a1dd7) will decrease coverage by 0.04%.
The diff coverage is 91.66%.

@@            Coverage Diff             @@
##             main     #623      +/-   ##
==========================================
- Coverage   91.59%   91.56%   -0.04%     
==========================================
  Files          35       34       -1     
  Lines        1665     1659       -6     
==========================================
- Hits         1525     1519       -6     
  Misses        140      140              
Impacted Files Coverage Δ
src/artemis/experiment_plans/full_grid_scan.py 69.84% <0.00%> (-0.48%) ⬇️
src/artemis/parameters/internal_parameters.py 98.64% <ø> (+0.87%) ⬆️
...plan_specific/grid_scan_with_edge_detect_params.py 64.86% <33.33%> (ø)
...emis/external_interaction/ispyb/ispyb_dataclass.py 98.18% <95.45%> (-1.82%) ⬇️
...rc/artemis/experiment_plans/fast_grid_scan_plan.py 86.98% <100.00%> (ø)
...rtemis/experiment_plans/oav_grid_detection_plan.py 100.00% <100.00%> (ø)
...ernal_interaction/callbacks/fgs/zocalo_callback.py 98.46% <100.00%> (ø)
...temis/external_interaction/ispyb/store_in_ispyb.py 96.92% <100.00%> (ø)
.../external_interaction/zocalo/zocalo_interaction.py 97.14% <100.00%> (ø)
...is/parameters/plan_specific/fgs_internal_params.py 100.00% <100.00%> (ø)
... and 1 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@olliesilvester
olliesilvester marked this pull request as ready for review April 21, 2023 10:05
@olliesilvester olliesilvester changed the title Replaced point 3d and point 2d to support arithmetic, using numpy arrays 348 replaced point 3d and point 2d to support arithmetic, using numpy arrays Apr 21, 2023

@d-perl d-perl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a good start, but I think we can simplify it more, and probably get rid of all of utils.py in the end.

If we need to check the length at some point, we could do something like

assert 2 <= len(point) <= 3

but for the parameters, they are validated by the json schema already so we are always sure they are length 3

100
)
expected_centre_motor_coords = (
dummy_params.experiment_params.grid_position_to_motor_position(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so part of the reason for this whole refactor is so that we could do something tidier like

expected_centre_grid_coords - [0.5, 0.5, 0.5]

mock_zocalo_functions(callbacks)
callbacks.ispyb_handler.ispyb_ids = (0, 0, 100)
expected_centre_grid_coords = Point3D(1, 2, 3)
expected_centre_grid_coords = create_point(1, 2, 3)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so this would just be expected_centre_grid_coords = ndarray([1,2,3])

assert found_centre == expected_centre_motor_coords
np.testing.assert_array_equal(found_centre, expected_centre_motor_coords)

expected_bbox_size = list(map(operator.sub, [8, 8, 7], [2, 2, 2]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

while we're numpyifying stuff, this could be ... = ndarray([8, 8, 7]) - ndarray([2, 2, 2]), and in the real code where this happens

# gets stored as 2x2D coords - (x, y) and (x, z). Values in pixels
"upper_left": Point3D(x=0, y=0, z=0),
"position": Point3D(x=0, y=0, z=0),
"upper_left": create_point(0, 0, 0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this would just be something like "upper_left": [0,0,0]

@olliesilvester
olliesilvester requested a review from d-perl May 3, 2023 16:01

@d-perl d-perl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

looks great, sorry I left this so long that there are all these merge conflicts

@d-perl
d-perl merged commit ee2610e into main Jun 2, 2023
@d-perl
d-perl deleted the 348_replace_point_3d_to_support_arithmetic branch June 2, 2023 12:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace Point3D with something which supports arithmetic

2 participants