@opentrons/shared-data 0.0.1-alpha.20 → 0.0.1-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/package.json +1 -1
  2. package/js/__tests__/__snapshots__/pipettes.test.ts.snap +0 -5969
  3. package/js/__tests__/deckSchemas.test.ts +0 -87
  4. package/js/__tests__/errors.test.js +0 -21
  5. package/js/__tests__/getAreSlotsAdjacent.test.ts +0 -128
  6. package/js/__tests__/getWellNamePerMultiTip.test.ts +0 -162
  7. package/js/__tests__/labwareDefQuirks.test.ts +0 -37
  8. package/js/__tests__/labwareDefSchemaV1.test.ts +0 -82
  9. package/js/__tests__/labwareDefSchemaV2.test.ts +0 -298
  10. package/js/__tests__/moduleAccessors.test.ts +0 -50
  11. package/js/__tests__/moduleSpecsSchema.test.ts +0 -77
  12. package/js/__tests__/pipetteSchemaV2.test.ts +0 -107
  13. package/js/__tests__/pipetteSpecSchemas.test.ts +0 -48
  14. package/js/__tests__/pipettes.test.ts +0 -58
  15. package/js/__tests__/protocolSchemaV4.test.ts +0 -137
  16. package/js/__tests__/protocolSchemaV5.test.ts +0 -137
  17. package/js/__tests__/protocolSchemaV6.test.ts +0 -132
  18. package/js/__tests__/protocolSchemaV7.test.ts +0 -64
  19. package/js/__tests__/protocolValidation.test.ts +0 -83
  20. package/js/__tests__/sortWells.test.ts +0 -40
  21. package/js/__tests__/splitWellsOnColumn.test.ts +0 -21
  22. package/js/__tests__/validateErrors.test.js +0 -34
  23. package/js/constants.ts +0 -338
  24. package/js/cypressUtils.ts +0 -35
  25. package/js/errors.ts +0 -33
  26. package/js/fixtures.ts +0 -161
  27. package/js/getLabware.ts +0 -154
  28. package/js/gripper.ts +0 -29
  29. package/js/helpers/__tests__/getAdapterName.test.ts +0 -31
  30. package/js/helpers/__tests__/getDeckDefFromLoadedLabware.test.ts +0 -12
  31. package/js/helpers/__tests__/getVectorDifference.test.ts +0 -25
  32. package/js/helpers/__tests__/getVectorSum.test.ts +0 -21
  33. package/js/helpers/__tests__/labwareInference.test.ts +0 -84
  34. package/js/helpers/__tests__/orderWells.test.ts +0 -87
  35. package/js/helpers/__tests__/parseProtocolData.test.ts +0 -165
  36. package/js/helpers/__tests__/volume.test.ts +0 -108
  37. package/js/helpers/__tests__/wellSets.test.ts +0 -352
  38. package/js/helpers/get96Channel384WellPlateWells.ts +0 -44
  39. package/js/helpers/getAddressableAreasInProtocol.ts +0 -59
  40. package/js/helpers/getLoadedLabwareDefinitionsByUri.ts +0 -30
  41. package/js/helpers/getModuleVizDims.ts +0 -118
  42. package/js/helpers/getOccludedSlotCountForModule.ts +0 -13
  43. package/js/helpers/getVectorDifference.ts +0 -12
  44. package/js/helpers/getVectorSum.ts +0 -12
  45. package/js/helpers/getWellNamePerMultiTip.ts +0 -86
  46. package/js/helpers/getWellTotalVolume.ts +0 -16
  47. package/js/helpers/index.ts +0 -347
  48. package/js/helpers/labwareInference.ts +0 -92
  49. package/js/helpers/orderWells.ts +0 -69
  50. package/js/helpers/parseProtocolData.ts +0 -141
  51. package/js/helpers/volume.ts +0 -35
  52. package/js/helpers/wellIsRect.ts +0 -6
  53. package/js/helpers/wellSets.ts +0 -155
  54. package/js/index.ts +0 -14
  55. package/js/labwareTools/__tests__/__snapshots__/createIrregularLabware.test.ts.snap +0 -3
  56. package/js/labwareTools/__tests__/__snapshots__/createLabware.test.ts.snap +0 -3
  57. package/js/labwareTools/__tests__/createDefaultDisplayName.test.ts +0 -111
  58. package/js/labwareTools/__tests__/createIrregularLabware.test.ts +0 -226
  59. package/js/labwareTools/__tests__/createLabware.test.ts +0 -147
  60. package/js/labwareTools/index.ts +0 -452
  61. package/js/modules.ts +0 -97
  62. package/js/pipettes.ts +0 -89
  63. package/js/protocols.ts +0 -290
  64. package/js/schema.ts +0 -80
  65. package/js/scripts/generateDeckLayersFromSVG.js +0 -46
  66. package/js/titleCase.ts +0 -30
  67. package/js/types.ts +0 -600
  68. package/python/.coveragerc +0 -4
  69. package/python/.flake8 +0 -32
  70. package/python/Config.in +0 -10
  71. package/python/Makefile +0 -134
  72. package/python/Pipfile +0 -28
  73. package/python/Pipfile.lock +0 -645
  74. package/python/buildroot.mk +0 -30
  75. package/python/mypy.ini +0 -41
  76. package/python/opentrons_shared_data/__init__.py +0 -17
  77. package/python/opentrons_shared_data/_version.py +0 -20
  78. package/python/opentrons_shared_data/command/__init__.py +0 -52
  79. package/python/opentrons_shared_data/deck/__init__.py +0 -96
  80. package/python/opentrons_shared_data/deck/dev_types.py +0 -180
  81. package/python/opentrons_shared_data/errors/__init__.py +0 -30
  82. package/python/opentrons_shared_data/errors/categories.py +0 -60
  83. package/python/opentrons_shared_data/errors/codes.py +0 -108
  84. package/python/opentrons_shared_data/errors/exceptions.py +0 -915
  85. package/python/opentrons_shared_data/gripper/__init__.py +0 -63
  86. package/python/opentrons_shared_data/gripper/constants.py +0 -6
  87. package/python/opentrons_shared_data/gripper/gripper_definition.py +0 -101
  88. package/python/opentrons_shared_data/labware/__init__.py +0 -22
  89. package/python/opentrons_shared_data/labware/constants.py +0 -7
  90. package/python/opentrons_shared_data/labware/dev_types.py +0 -140
  91. package/python/opentrons_shared_data/labware/labware_definition.py +0 -328
  92. package/python/opentrons_shared_data/load.py +0 -57
  93. package/python/opentrons_shared_data/module/__init__.py +0 -74
  94. package/python/opentrons_shared_data/module/dev_types.py +0 -141
  95. package/python/opentrons_shared_data/pipette/__init__.py +0 -107
  96. package/python/opentrons_shared_data/pipette/dev_types.py +0 -177
  97. package/python/opentrons_shared_data/pipette/file_operation_helpers.py +0 -37
  98. package/python/opentrons_shared_data/pipette/load_data.py +0 -261
  99. package/python/opentrons_shared_data/pipette/model_constants.py +0 -123
  100. package/python/opentrons_shared_data/pipette/mutable_configurations.py +0 -431
  101. package/python/opentrons_shared_data/pipette/pipette_definition.py +0 -503
  102. package/python/opentrons_shared_data/pipette/pipette_load_name_conversions.py +0 -240
  103. package/python/opentrons_shared_data/pipette/scripts/__init__.py +0 -0
  104. package/python/opentrons_shared_data/pipette/scripts/build_json_script.py +0 -469
  105. package/python/opentrons_shared_data/pipette/scripts/update_configuration_files.py +0 -450
  106. package/python/opentrons_shared_data/pipette/types.py +0 -193
  107. package/python/opentrons_shared_data/protocol/__init__.py +0 -13
  108. package/python/opentrons_shared_data/protocol/constants.py +0 -98
  109. package/python/opentrons_shared_data/protocol/dev_types.py +0 -436
  110. package/python/opentrons_shared_data/protocol/models/__init__.py +0 -48
  111. package/python/opentrons_shared_data/protocol/models/protocol_schema_v6.py +0 -145
  112. package/python/opentrons_shared_data/protocol/models/protocol_schema_v7.py +0 -95
  113. package/python/opentrons_shared_data/protocol/models/protocol_schema_v8.py +0 -110
  114. package/python/opentrons_shared_data/protocol/models/shared_models.py +0 -111
  115. package/python/opentrons_shared_data/py.typed +0 -0
  116. package/python/opentrons_shared_data/robot/__init__.py +0 -33
  117. package/python/opentrons_shared_data/robot/dev_types.py +0 -37
  118. package/python/pytest.ini +0 -2
  119. package/python/setup.cfg +0 -5
  120. package/python/setup.py +0 -179
  121. package/python/tests/__init__.py +0 -1
  122. package/python/tests/conftest.py +0 -0
  123. package/python/tests/deck/__init__.py +0 -0
  124. package/python/tests/deck/test_list_names.py +0 -12
  125. package/python/tests/deck/test_position.py +0 -113
  126. package/python/tests/deck/test_typechecks.py +0 -28
  127. package/python/tests/errors/__init__.py +0 -1
  128. package/python/tests/errors/test_error_completeness.py +0 -19
  129. package/python/tests/errors/test_exceptions.py +0 -74
  130. package/python/tests/gripper/__init__.py +0 -0
  131. package/python/tests/gripper/test_definition.py +0 -30
  132. package/python/tests/gripper/test_load.py +0 -16
  133. package/python/tests/labware/__init__.py +0 -13
  134. package/python/tests/labware/test_typechecks.py +0 -21
  135. package/python/tests/module/__init__.py +0 -20
  136. package/python/tests/module/test_load.py +0 -49
  137. package/python/tests/module/test_typechecks.py +0 -34
  138. package/python/tests/pipette/__init__.py +0 -0
  139. package/python/tests/pipette/test_load_data.py +0 -103
  140. package/python/tests/pipette/test_mutable_configurations.py +0 -266
  141. package/python/tests/pipette/test_pipette_definition.py +0 -183
  142. package/python/tests/pipette/test_pipette_load_name_conversions.py +0 -222
  143. package/python/tests/pipette/test_typechecks.py +0 -50
  144. package/python/tests/pipette/test_validate_schema.py +0 -37
  145. package/python/tests/protocol/__init__.py +0 -15
  146. package/python/tests/protocol/test_protocol_schema_v6.py +0 -107
  147. package/python/tests/protocol/test_protocol_schema_v7.py +0 -34
  148. package/python/tests/protocol/test_protocol_schema_v8.py +0 -20
  149. package/python/tests/protocol/test_typechecks.py +0 -36
  150. package/python/tests/robot/__init__.py +0 -0
  151. package/python/tests/robot/test_typechecks.py +0 -20
@@ -1,103 +0,0 @@
1
- import pytest
2
- from typing import Dict, Any, cast
3
- from opentrons_shared_data.pipette import (
4
- load_data,
5
- pipette_load_name_conversions,
6
- dev_types,
7
- )
8
- from opentrons_shared_data.pipette.types import (
9
- PipetteChannelType,
10
- PipetteModelType,
11
- PipetteVersionType,
12
- PipetteTipType,
13
- Quirks,
14
- LiquidClasses,
15
- )
16
-
17
-
18
- def test_load_pipette_definition() -> None:
19
- pipette_config_one = load_data.load_definition(
20
- PipetteModelType.p50,
21
- PipetteChannelType.SINGLE_CHANNEL,
22
- PipetteVersionType(major=3, minor=3),
23
- )
24
-
25
- assert pipette_config_one.channels == 1
26
- assert pipette_config_one.pipette_type.value == "p50"
27
- assert pipette_config_one.nozzle_offset == [-8.0, -22.0, -259.15]
28
-
29
- assert (
30
- pipette_config_one.liquid_properties[LiquidClasses.default]
31
- .supported_tips[PipetteTipType.t50]
32
- .default_aspirate_flowrate.default
33
- == 8.0
34
- )
35
-
36
- assert pipette_config_one.quirks == []
37
- pipette_config_two = load_data.load_definition(
38
- PipetteModelType.p50,
39
- PipetteChannelType.SINGLE_CHANNEL,
40
- PipetteVersionType(major=1, minor=0),
41
- )
42
-
43
- assert pipette_config_two.channels == 1
44
- assert pipette_config_two.pipette_type.value == "p50"
45
- assert pipette_config_two.nozzle_offset == [0.0, 0.0, 25.0]
46
- assert (
47
- pipette_config_two.liquid_properties[LiquidClasses.default]
48
- .supported_tips[PipetteTipType.t200]
49
- .default_aspirate_flowrate.default
50
- == 25.0
51
- )
52
- assert pipette_config_two.quirks == [Quirks.dropTipShake]
53
-
54
-
55
- @pytest.mark.parametrize(
56
- argnames=["key_spot_check", "value_spot_check"],
57
- argvalues=[
58
- ["P1KSV10", "p1000_single_v1.0"],
59
- ["P1KHV33", "p1000_96_v3.3"],
60
- ["P20MV21", "p20_multi_v2.1"],
61
- ["P300MV10", "p300_multi_v1.0"],
62
- ["P3HMV14", "p300_multi_v1.4"],
63
- ],
64
- )
65
- def test_build_serial_number_lookup(key_spot_check: str, value_spot_check: str) -> None:
66
- lookup_table = load_data.load_serial_lookup_table()
67
- assert lookup_table[key_spot_check] == value_spot_check
68
-
69
-
70
- @pytest.mark.parametrize(
71
- argnames=["pipette_model", "v1_configuration_changes"],
72
- argvalues=[
73
- ["p300_multi_v1.4", {"max_volume": 200, "min_volume": 10}],
74
- ["p1000_96_v3.3", {"tip_length": 40, "min_volume": 300}],
75
- ],
76
- )
77
- def test_update_pipette_configuration(
78
- pipette_model: str, v1_configuration_changes: Dict[str, Any]
79
- ) -> None:
80
-
81
- liquid_class = LiquidClasses.default
82
- model_name = pipette_load_name_conversions.convert_pipette_model(
83
- cast(dev_types.PipetteModel, pipette_model)
84
- )
85
- base_configurations = load_data.load_definition(
86
- model_name.pipette_type, model_name.pipette_channels, model_name.pipette_version
87
- )
88
-
89
- updated_configurations = load_data.update_pipette_configuration(
90
- base_configurations, v1_configuration_changes, liquid_class
91
- )
92
-
93
- updated_configurations_dict = updated_configurations.dict()
94
- for k, v in v1_configuration_changes.items():
95
- if k == "tip_length":
96
- for i in updated_configurations_dict["liquid_properties"][liquid_class][
97
- "supported_tips"
98
- ].values():
99
- assert i["default_tip_length"] == v
100
- else:
101
- assert (
102
- updated_configurations_dict["liquid_properties"][liquid_class][k] == v
103
- )
@@ -1,266 +0,0 @@
1
- import json
2
- import os
3
- from pathlib import Path
4
- from typing import Dict, Any, cast, Union, Generator
5
-
6
- import pytest
7
-
8
- from opentrons_shared_data.pipette import (
9
- mutable_configurations,
10
- types,
11
- pipette_definition,
12
- pipette_load_name_conversions as pip_conversions,
13
- load_data,
14
- dev_types,
15
- )
16
-
17
-
18
- TEST_SERIAL_NUMBER = "P50MV1520200304"
19
- TestOverrideType = Dict[str, Union[float, int, bool]]
20
-
21
-
22
- @pytest.fixture
23
- def TMPFILE_DATA() -> Dict[str, Any]:
24
- return {
25
- "dropTipShake": True,
26
- "doubleDropTip": True,
27
- "model": "p50_multi_v1.5",
28
- "quirks": {"pickUpPresses": True, "dropTipShake": True, "doubleDropTip": True},
29
- "pickUpSpeed": {
30
- "value": 5.0,
31
- "min": 1,
32
- "max": 100,
33
- "units": "mm/s",
34
- "type": "float",
35
- "default": 30,
36
- },
37
- }
38
-
39
-
40
- @pytest.fixture
41
- def override_configuration_path(tmp_path: Path) -> Generator[Path, None, None]:
42
- os.environ["OT_API_CONFIG_DIR"] = str(tmp_path)
43
-
44
- tmp_path.mkdir(parents=True, exist_ok=True)
45
- with_pip_path = tmp_path / Path("pipettes")
46
- with_pip_path.mkdir(parents=True, exist_ok=True)
47
- yield with_pip_path
48
-
49
- del os.environ["OT_API_CONFIG_DIR"]
50
-
51
-
52
- @pytest.fixture
53
- def overrides_fixture(
54
- override_configuration_path: Path, TMPFILE_DATA: Dict[str, Any]
55
- ) -> types.MutableConfig:
56
- with open(override_configuration_path / f"{TEST_SERIAL_NUMBER}.json", "w") as f:
57
- json.dump(TMPFILE_DATA, f)
58
- return types.MutableConfig.build(**TMPFILE_DATA["pickUpSpeed"], name="pickUpSpeed")
59
-
60
-
61
- def test_list_mutable_configs_unknown_pipette_id(
62
- override_configuration_path: Path,
63
- ) -> None:
64
- """Test unknown pipette id mutable configs.
65
-
66
- Test that a user receives a list of all possible mutable configurations
67
- with the default value equal to the regular value.
68
- """
69
-
70
- found_configurations = mutable_configurations.list_mutable_configs(
71
- TEST_SERIAL_NUMBER, override_configuration_path
72
- )
73
- for c in found_configurations:
74
- if isinstance(c, str):
75
- # model string, ignore
76
- continue
77
- if isinstance(c, types.QuirkConfig):
78
- assert isinstance(c.value, bool)
79
- else:
80
- assert c.default == c.value
81
-
82
-
83
- def test_list_mutable_configs_known_pipette_id(
84
- overrides_fixture: types.MutableConfig, override_configuration_path: Path
85
- ) -> None:
86
- """Test known pipette id mutable configs.
87
-
88
- Test that a user receives a list of all possible mutable configurations
89
- with the expected overrides also listed.
90
- """
91
- found_configurations = mutable_configurations.list_mutable_configs(
92
- TEST_SERIAL_NUMBER, override_configuration_path
93
- )
94
-
95
- for c in found_configurations:
96
- if isinstance(c, str):
97
- # model string, ignore
98
- continue
99
- if overrides_fixture.name == c.name:
100
- assert c.value == overrides_fixture.value
101
- elif isinstance(c, types.QuirkConfig):
102
- assert isinstance(c.value, bool)
103
- else:
104
- assert c.default == c.value
105
-
106
-
107
- @pytest.mark.parametrize(
108
- argnames=["overrides_dict", "saved_dict"],
109
- argvalues=[
110
- [
111
- {"pickUpCurrent": 0.5, "dropTipSpeed": 5, "dropTipShake": False},
112
- {
113
- "quirks": {"dropTipShake": False},
114
- "pickUpCurrent": {
115
- "value": 0.5,
116
- "default": 0.8,
117
- "units": "amps",
118
- "type": "float",
119
- "min": 0.1,
120
- "max": 2.0,
121
- },
122
- "model": "p50_multi_v1.5",
123
- "dropTipSpeed": {
124
- "value": 5,
125
- "default": 5.0,
126
- "units": "mm/s",
127
- "type": "float",
128
- "min": 0.01,
129
- "max": 30,
130
- },
131
- },
132
- ]
133
- ],
134
- )
135
- def test_save_new_overrides_new_file(
136
- override_configuration_path: Path,
137
- overrides_dict: TestOverrideType,
138
- saved_dict: Dict[str, Any],
139
- ) -> None:
140
- mutable_configurations.save_overrides(
141
- TEST_SERIAL_NUMBER, overrides_dict, override_configuration_path
142
- )
143
- with open(override_configuration_path / f"{TEST_SERIAL_NUMBER}.json") as f:
144
- new_file = json.load(f)
145
- assert saved_dict == new_file
146
-
147
-
148
- @pytest.mark.parametrize(
149
- argnames=["overrides_dict"],
150
- argvalues=[
151
- [{"pickUpCurrent": 1, "pickUpSpeed": 10, "dropTipShake": False}],
152
- [{"pickUpCurrent": 2}],
153
- ],
154
- )
155
- def test_save_new_overrides_update_file(
156
- override_configuration_path: Path,
157
- overrides_fixture: types.MutableConfig,
158
- overrides_dict: TestOverrideType,
159
- TMPFILE_DATA: Dict[str, Any],
160
- ) -> None:
161
- mutable_configurations.save_overrides(
162
- TEST_SERIAL_NUMBER, overrides_dict, override_configuration_path
163
- )
164
- with open(override_configuration_path / f"{TEST_SERIAL_NUMBER}.json") as f:
165
- new_file = json.load(f)
166
-
167
- for k, v in overrides_dict.items():
168
- if isinstance(v, bool):
169
- TMPFILE_DATA["quirks"][k] = v
170
- elif TMPFILE_DATA.get(k):
171
- TMPFILE_DATA[k]["value"] = v
172
-
173
- TMPFILE_DATA["pickUpCurrent"] = {
174
- "default": 0.8,
175
- "max": 2.0,
176
- "min": 0.1,
177
- "type": "float",
178
- "units": "amps",
179
- "value": overrides_dict["pickUpCurrent"],
180
- }
181
-
182
- del TMPFILE_DATA["quirks"]["pickUpPresses"]
183
- assert TMPFILE_DATA == new_file
184
-
185
-
186
- @pytest.mark.parametrize(
187
- argnames=["overrides_dict"],
188
- argvalues=[
189
- [{"pickUpCurrent": 1231.213, "dropTipSpeed": 121, "dropTipShake": False}],
190
- [{"quirk123": True}],
191
- ],
192
- )
193
- def test_save_invalid_overrides(
194
- overrides_fixture: types.MutableConfig,
195
- override_configuration_path: Path,
196
- overrides_dict: TestOverrideType,
197
- TMPFILE_DATA: Dict[str, Any],
198
- ) -> None:
199
- with pytest.raises(ValueError):
200
- mutable_configurations.save_overrides(
201
- TEST_SERIAL_NUMBER, overrides_dict, override_configuration_path
202
- )
203
- with open(override_configuration_path / f"{TEST_SERIAL_NUMBER}.json") as f:
204
- new_file = json.load(f)
205
- assert TMPFILE_DATA == new_file
206
-
207
-
208
- @pytest.mark.parametrize(
209
- argnames=["pipette_model", "serial_number"],
210
- argvalues=[
211
- [
212
- pip_conversions.convert_pipette_model(
213
- cast(dev_types.PipetteModel, "p1000_96_v3.3")
214
- ),
215
- "P1KHV3320230629",
216
- ],
217
- [
218
- pip_conversions.convert_pipette_model(
219
- cast(dev_types.PipetteModel, "p50_multi_v1.5")
220
- ),
221
- TEST_SERIAL_NUMBER,
222
- ],
223
- ],
224
- )
225
- def test_load_with_overrides(
226
- overrides_fixture: types.MutableConfig,
227
- pipette_model: pipette_definition.PipetteModelVersionType,
228
- serial_number: str,
229
- override_configuration_path: Path,
230
- ) -> None:
231
- """Test that you can load configurations both with pre-existing overrides and non-pre-existing overrides."""
232
- updated_configurations = mutable_configurations.load_with_mutable_configurations(
233
- pipette_model, override_configuration_path, serial_number
234
- )
235
-
236
- loaded_base_configurations = load_data.load_definition(
237
- pipette_model.pipette_type,
238
- pipette_model.pipette_channels,
239
- pipette_model.pipette_version,
240
- )
241
-
242
- if serial_number == TEST_SERIAL_NUMBER:
243
- dict_loaded_configs = loaded_base_configurations.dict(by_alias=True)
244
- dict_loaded_configs["pickUpTipConfigurations"]["pressFit"]["speed"] = 5.0
245
- updated_configurations_dict = updated_configurations.dict(by_alias=True)
246
- assert set(dict_loaded_configs.pop("quirks")) == set(
247
- updated_configurations_dict.pop("quirks")
248
- )
249
- assert updated_configurations_dict == dict_loaded_configs
250
- else:
251
- assert updated_configurations == loaded_base_configurations
252
-
253
-
254
- def test_build_mutable_config_using_old_units() -> None:
255
- """Test that MutableConfigs can build with old units."""
256
- old_units_config = {
257
- "value": 5,
258
- "default": 5.0,
259
- "units": "mm/s",
260
- "type": "float",
261
- "min": 0.01,
262
- "max": 30,
263
- }
264
- assert (
265
- types.MutableConfig.build(**old_units_config, name="dropTipSpeed") is not None # type: ignore
266
- )
@@ -1,183 +0,0 @@
1
- import pytest
2
- from typing import cast, List
3
- from opentrons_shared_data.pipette.types import (
4
- PipetteChannelType,
5
- PipetteModelType,
6
- PipetteVersionType,
7
- PipetteModelMajorVersionType,
8
- PipetteModelMinorVersionType,
9
- LiquidClasses,
10
- )
11
- from opentrons_shared_data.pipette.pipette_definition import (
12
- liquid_class_for_volume_between_default_and_defaultlowvolume,
13
- PipetteLiquidPropertiesDefinition,
14
- SupportedTipsDefinition,
15
- )
16
-
17
-
18
- def get_liquid_definition_for(
19
- liquid_class: LiquidClasses,
20
- ) -> PipetteLiquidPropertiesDefinition:
21
- if liquid_class == LiquidClasses.lowVolumeDefault:
22
- return PipetteLiquidPropertiesDefinition.parse_obj(
23
- {
24
- "supportedTips": {
25
- "t50": SupportedTipsDefinition.parse_obj(
26
- {
27
- "defaultAspirateFlowRate": {
28
- "default": 5,
29
- "valuesByApiLevel": {"2.0": 5},
30
- },
31
- "defaultDispenseFlowRate": {
32
- "default": 5,
33
- "valuesByApiLevel": {"2.0": 5},
34
- },
35
- "defaultBlowOutFlowRate": {
36
- "default": 10,
37
- "valuesByApiLevel": {"2.0": 10},
38
- },
39
- "defaultFlowAcceleration": 100,
40
- "defaultTipLength": 100,
41
- "defaultReturnTipHeight": 0.5,
42
- "defaultPushOutVolume": 5,
43
- "aspirate": {"default": {"1": [[1, 2, 3]]}},
44
- "dispense": {"default": {"1": [[1, 2, 3]]}},
45
- }
46
- )
47
- },
48
- "defaultTipOverlapDictionary": {},
49
- "maxVolume": 30,
50
- "minVolume": 1,
51
- "defaultTipracks": [],
52
- }
53
- )
54
- else:
55
- return PipetteLiquidPropertiesDefinition.parse_obj(
56
- {
57
- "supportedTips": {
58
- "t50": SupportedTipsDefinition.parse_obj(
59
- {
60
- "defaultAspirateFlowRate": {
61
- "default": 5,
62
- "valuesByApiLevel": {"2.0": 5},
63
- },
64
- "defaultDispenseFlowRate": {
65
- "default": 5,
66
- "valuesByApiLevel": {"2.0": 5},
67
- },
68
- "defaultBlowOutFlowRate": {
69
- "default": 10,
70
- "valuesByApiLevel": {"2.0": 10},
71
- },
72
- "defaultFlowAcceleration": 100,
73
- "defaultTipLength": 100,
74
- "defaultReturnTipHeight": 0.5,
75
- "defaultPushOutVolume": 5,
76
- "aspirate": {"default": {"1": [[1, 2, 3]]}},
77
- "dispense": {"default": {"1": [[1, 2, 3]]}},
78
- }
79
- )
80
- },
81
- "defaultTipOverlapDictionary": {},
82
- "maxVolume": 100,
83
- "minVolume": 5,
84
- "defaultTipracks": [],
85
- }
86
- )
87
-
88
-
89
- @pytest.mark.parametrize(
90
- argnames=["model", "expected_enum"],
91
- argvalues=[["p50", PipetteModelType.p50], ["p1000", PipetteModelType.p1000]],
92
- )
93
- def test_model_enum(model: str, expected_enum: PipetteModelType) -> None:
94
- assert expected_enum == PipetteModelType(model)
95
-
96
-
97
- @pytest.mark.parametrize(argnames="channels", argvalues=[1, 8, 96])
98
- def test_channel_enum(channels: int) -> None:
99
- channel_type = PipetteChannelType(channels)
100
- assert channels == channel_type
101
-
102
-
103
- def test_incorrect_values() -> None:
104
- with pytest.raises(ValueError):
105
- PipetteModelType("p100")
106
-
107
- with pytest.raises(ValueError):
108
- PipetteChannelType(99)
109
-
110
-
111
- @pytest.mark.parametrize(
112
- argnames=["major", "minor"],
113
- argvalues=[[1, 0], [1, 3], [3, 9]],
114
- )
115
- def test_version_enum(major: int, minor: int) -> None:
116
- version_type = PipetteVersionType(
117
- cast(PipetteModelMajorVersionType, major),
118
- cast(PipetteModelMinorVersionType, minor),
119
- )
120
- assert version_type.as_tuple == (major, minor)
121
-
122
-
123
- @pytest.mark.parametrize(
124
- argnames=[
125
- "all_liquid_classes",
126
- "volume",
127
- "current_liquid_class",
128
- "expected_liquid_class",
129
- ],
130
- argvalues=[
131
- [
132
- [LiquidClasses.default],
133
- 1,
134
- LiquidClasses.lowVolumeDefault,
135
- LiquidClasses.default,
136
- ],
137
- [
138
- [LiquidClasses.lowVolumeDefault, LiquidClasses.default],
139
- 1,
140
- LiquidClasses.lowVolumeDefault,
141
- LiquidClasses.lowVolumeDefault,
142
- ],
143
- [
144
- [LiquidClasses.lowVolumeDefault, LiquidClasses.default],
145
- 1,
146
- LiquidClasses.default,
147
- LiquidClasses.lowVolumeDefault,
148
- ],
149
- [
150
- [LiquidClasses.lowVolumeDefault, LiquidClasses.default],
151
- 5,
152
- LiquidClasses.default,
153
- LiquidClasses.default,
154
- ],
155
- [
156
- [LiquidClasses.lowVolumeDefault, LiquidClasses.default],
157
- 5,
158
- LiquidClasses.lowVolumeDefault,
159
- LiquidClasses.default,
160
- ],
161
- [
162
- [LiquidClasses.lowVolumeDefault, LiquidClasses.default],
163
- 100,
164
- LiquidClasses.lowVolumeDefault,
165
- LiquidClasses.default,
166
- ],
167
- ],
168
- )
169
- def test_liquid_class_for_volume_between_default_and_defaultlowvolume(
170
- all_liquid_classes: List[LiquidClasses],
171
- volume: float,
172
- current_liquid_class: LiquidClasses,
173
- expected_liquid_class: LiquidClasses,
174
- ) -> None:
175
- available_liquid_classes = {
176
- lc: get_liquid_definition_for(lc) for lc in all_liquid_classes
177
- }
178
- assert (
179
- liquid_class_for_volume_between_default_and_defaultlowvolume(
180
- volume, current_liquid_class, available_liquid_classes
181
- )
182
- == expected_liquid_class
183
- )