Skip to content

Commit

Permalink
Merge pull request #22 from machineagency/pipette_update
Browse files Browse the repository at this point in the history
Pipette update
  • Loading branch information
MariaPoliti authored Nov 8, 2023
2 parents 1d6f8f1 + c338f38 commit c335ccb
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 135 deletions.
8 changes: 1 addition & 7 deletions science_jubilee/Machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,7 @@ def position(self):
def load_deck(self, deck_filename: str, path :str = os.path.join(os.path.dirname(__file__), 'decks', 'deck_definition')):
# do thing
#make sure filename has json
if deck_filename[-4:] != 'json':
deck_filename = deck_filename + '.json'

config_path = os.path.join(path, deck_filename)
with open(config_path, "r") as f:
deck_config = json.load(f)
deck = Deck(deck_config)
deck = Deck(deck_filename, path=path)
self.deck = deck
return deck

Expand Down
2 changes: 1 addition & 1 deletion science_jubilee/decks/Deck.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Deck(SlotSet):
def __init__(self, deck_filename, path :str = os.path.join(os.path.dirname(__file__), 'deck_definition')):

# load in the deck configuration file
if deck_filename[-4] != 'json':
if deck_filename[-4:] != 'json':
deck_filename = deck_filename + '.json'

config_path = os.path.join(path, f"{deck_filename}" )
Expand Down
58 changes: 0 additions & 58 deletions science_jubilee/decks/configs/lab_automation_deck.json

This file was deleted.

24 changes: 12 additions & 12 deletions science_jubilee/decks/deck_definition/lab_automation_deck.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,48 @@
"slots": {
"0": {
"offset": [
15.3,
7.7
14.9,
4.4
],
"has_labware": false,
"labware": null
},
"1": {
"offset": [
155.8,
7.9
157.0,
5.8
],
"has_labware": false,
"labware": null
},
"2": {
"offset": [
15.0,
104.6
14.3,
100.8
],
"has_labware": false,
"labware": null
},
"3": {
"offset": [
155.6,
104.7
154.9,
98.3
],
"has_labware": false,
"labware": null
},
"4": {
"offset": [
15.1,
201.3
17.1,
201.1
],
"has_labware": false,
"labware": null
},
"5": {
"offset": [
155.3,
201.4
157.0,
201.9
],
"has_labware": false,
"labware": null
Expand Down
87 changes: 82 additions & 5 deletions science_jubilee/labware/Labware.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
from dataclasses import dataclass
from itertools import chain
from typing import List, Dict, Tuple
from typing import List, Dict, Tuple, Union, Iterable, NamedTuple
import os
import json
from pathlib import Path
Expand Down Expand Up @@ -57,14 +57,26 @@ def z(self, new_z):
self._z = new_z

@property
def top(self):
def top_(self):
"""Defines the top-most point of the well"""
return self.z + self.depth

@property
def bottom(self):
def bottom_(self):
"""Defines the bottom-most point of the well"""
return self.z

def bottom(self, z: float = 0.0):
from_bottom_z = self.bottom_ +z
coord = (self.x, self.y, from_bottom_z)

return Location(coord, self)

def top(self, z: float = 0.0 ):
from_top_z = self.top_ +z
coord = (self.x, self.y, from_top_z)

return Location(coord, self)


@dataclass(repr=False)
Expand Down Expand Up @@ -111,7 +123,7 @@ def __init__(self, labware_filename: str, offset: Tuple[float] = None, order : s
path :str = os.path.join(os.path.dirname(__file__), 'labware_definition')):

# load in the labware configuration file
if labware_filename[-4] != 'json':
if labware_filename[-4:] != 'json':
labware_filename = labware_filename + '.json'

config_path = os.path.join(
Expand Down Expand Up @@ -277,4 +289,69 @@ def withWellOrder(self, order) -> list:
else:
print('Order needs to be either rows or columns')

self.wells = ordered_wells
self.wells = ordered_wells

## Adapted from Opentrons API opentrons.types##
class Point(NamedTuple):
x: float = 0.0
y: float = 0.0
z: float = 0.0

def add(self, other):
if not isinstance(other, Point):
return NotImplemented
return Point(self.x + other.x, self.y + other.y, self.z + other.z)

def substract(self, other):
if not isinstance(other, Point):
return NotImplemented
return Point(self.x - other.x, self.y - other.y, self.z - other.z)

def multiply(self, other: Union[int, float]):
if not isinstance(other, (float, int)):
return NotImplemented
return Point(self.x * other, self.y * other, self.z * other)

def absolute(self):
return Point(abs(self.x), abs(self.y), abs(self.z))

def __repr__(self) -> str:
display= "x:{}, y: {}, z:{}".format(self.x, self.y, self.z)
return display


class Location:
"""A location to target as a motion.
The location contains a :py:class:`.Point` and possibly an associated
:py:class:`Labware` or :py:class:`Well` instance.
"""

def __init__(self, point: Point, labware: Union[Well, Labware]):
self._point = point
self._labware = labware
# todo(mm, 2021-10-01): Figure out how to get .point and .labware to show up
# in the rendered docs, and then update the class docstring to use cross-references.

@property
def point(self) -> Point:
return self._point

@property
def labware(self):
return self._labware

def __iter__(self) -> Iterable[Union[Point, Well, Labware]]:
"""Iterable interface to support unpacking. Like a tuple."""
return iter(( self._point, self._labware))

def __eq__(self, other: object) -> bool:
return (
isinstance(other, Location)
and other._point == self._point
and other._labware == self._labware
)

def __repr__(self) -> str:
return f"Location(point={repr(self._point)}, labware={self._labware})"
Loading

0 comments on commit c335ccb

Please sign in to comment.