Skip to content

Commit

Permalink
Add cornerOffset test
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura-Danielle committed Dec 1, 2018
1 parent 40ee47c commit 51b6a13
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion shared-data/definitions2/corning_6_wellPlate_16.8_mL.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"cornerOffsetFromSlot": {
"x": 0,
"y": -0.01,
"y": 0.01,
"z": 0
},
"dimensions": {
Expand Down
4 changes: 2 additions & 2 deletions shared-data/js/__tests__/fixtures/labwareExample2.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"isMagneticModuleCompatible": false
},
"cornerOffsetFromSlot": {
"x": -77.76,
"y": -35.48,
"x": 77.76,
"y": 35.48,
"z": 0
},
"dimensions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
_irregularWellName,
_generateIrregularLoadName,
_calculateWellCoord,
_calculateCornerOffset,
} from '../index.js'
import {splitWellsOnColumn, sortWells} from '../../helpers/index.js'

Expand All @@ -14,6 +15,20 @@ import exampleLabware1 from '../../__tests__/fixtures/irregularLabwareExample1.j
jest.mock('../assignId', () => jest.fn(() => 'mock-id'))

describe('test helper functions', () => {
test('cornerOffsetFromSLot outputs correctly', () => {
// If smaller than slot, positive values
// If larger than slot, negative values
const smallerDims = {overallLength: 100, overallWidth: 80, overallHeight: 10}
const largerDims = {overallLength: 200, overallWidth: 90, overallHeight: 10}
const offset = _calculateCornerOffset(smallerDims)
const offset2 = _calculateCornerOffset(largerDims)

expect(offset.x).toBeGreaterThan(0)
expect(offset.y).toBeGreaterThan(0)
expect(offset2.x).toBeLessThan(0)
expect(offset2.y).toBeLessThan(0)

})
test('Well name generated correctly', () => {
const grid = {row: 2, column: 2}
const gridStart = [{rowStart: 'A', colStart: '1', rowStride: 1, colStride: 2}, {rowStart: 'B', colStart: '1', rowStride: 3, colStride: 1}]
Expand Down
10 changes: 5 additions & 5 deletions shared-data/js/labwareTools/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ function calculateCoordinates (
}, {})
}

function calculateCornerOffset (dimensions: Dimensions): {string: number} {
export function _calculateCornerOffset (dimensions: Dimensions): Offset {
return {
x: round(dimensions.overallLength - SLOT_LENGTH_MM, 2),
y: round(dimensions.overallWidth - SLOT_WIDTH_MM, 2),
x: round(SLOT_LENGTH_MM - dimensions.overallLength, 2),
y: round(SLOT_WIDTH_MM - dimensions.overallWidth, 2),
z: 0}
}
// Generator function for labware definitions within a regular grid format
Expand All @@ -218,7 +218,7 @@ export function createRegularLabware (args: RegularLabwareProps): Schema {
otId: assignId(),
deprecated: false,
metadata: args.metadata,
cornerOffsetFromSlot: calculateCornerOffset(args.dimensions),
cornerOffsetFromSlot: _calculateCornerOffset(args.dimensions),
dimensions: args.dimensions,
parameters: args.parameters,
wells: calculateCoordinates(args.well, ordering, args.spacing, args.offset),
Expand Down Expand Up @@ -256,7 +256,7 @@ export function createIrregularLabware (args: IrregularLabwareProps): Schema {
otId: assignId(),
deprecated: false,
metadata: args.metadata,
cornerOffsetFromSlot: calculateCornerOffset(args.dimensions),
cornerOffsetFromSlot: _calculateCornerOffset(args.dimensions),
dimensions: args.dimensions,
parameters: {
...args.parameters,
Expand Down

0 comments on commit 51b6a13

Please sign in to comment.