def testMetadataException(self): """ Check whether metadata set methods are blocked on a v1 (pre-5.1) table """ ofile = self.uploadHdf5("service-reference-dev_4_4_5.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) expected = 'Tables metadata is only supported for OMERO.tables >= 2' with pytest.raises(omero.ApiUsageException) as exc: table.setMetadata('a', rint(1)) with pytest.raises(omero.ApiUsageException) as exc: table.setAllMetadata({'a': rint(1)}) assert exc.value.message == expected
def testAllColumns_4_4_5(self): """ Check whether a table created under 4.4.5 or older is still usable with a newer server """ ofile = self.uploadHdf5("service-reference-dev_4_4_5.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) assert table expectedTypes = [ omero.grid.FileColumn, omero.grid.ImageColumn, omero.grid.RoiColumn, omero.grid.WellColumn, omero.grid.PlateColumn, omero.grid.BoolColumn, omero.grid.DoubleColumn, omero.grid.LongColumn, omero.grid.StringColumn, omero.grid.MaskColumn ] # omero.grid.FloatArrayColumn, # omero.grid.DoubleArrayColumn, # omero.grid.LongArrayColumn, expectedNames = [ 'filecol', 'imagecol', 'roicol', 'wellcol', 'platecol', 'boolcol', 'doublecol', 'longcol', 'stringcol', 'mask' ] # 'longarr' # 'floatarr' # 'doublearr' headers = table.getHeaders() assert [type(x) for x in headers] == expectedTypes assert [x.name for x in headers] == expectedNames assert table.getNumberOfRows() == 2 data = table.readCoordinates([0, 1]) testf = data.columns[0].values assert 10 == testf[0] assert 20 == testf[1] testi = data.columns[1].values assert 30 == testi[0] assert 40 == testi[1] testr = data.columns[2].values assert 50 == testr[0] assert 60 == testr[1] testw = data.columns[3].values assert 70 == testw[0] assert 80 == testw[1] testp = data.columns[4].values assert 90 == testp[0] assert 100 == testp[1] testb = data.columns[5].values assert testb[0] assert not testb[1] testd = data.columns[6].values assert 0.25 == testd[0] assert 0.5 == testd[1] testl = data.columns[7].values assert -1 == testl[0] assert -2 == testl[1] tests = data.columns[8].values assert "abc" == tests[0] assert "de" == tests[1] testm = data.columns[9] self.checkMaskCol(testm) # testla = data.columns[10].values # assert [-2, -1] == testla[0] # assert [1, 2] == testla[1] # testda = data.columns[11].values # assert [-0.25, -0.5] == testda[0] # assert [0.125, 0.0625] == testda[1] # Now try an update updatel = omero.grid.LongColumn('longcol', '', [12345]) updateData = omero.grid.Data(rowNumbers=[1], columns=[updatel]) table.update(updateData) assert table.getNumberOfRows() == 2 data2 = table.readCoordinates([0, 1]) for n in [0, 1, 2, 3, 4, 5, 6, 8]: assert data.columns[n].values == data2.columns[n].values self.checkMaskCol(data2.columns[9]) testl2 = data2.columns[7].values assert -1 == testl2[0] assert 12345 == testl2[1]
def testAllColumnsAndMetadata_5_3_4(self): """ Check whether a table created under 5.3.4-5.5.1 prior to the Python 3 work is still usable with a newer server """ ofile = self.uploadHdf5("service-reference-dev_5_3_4.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) assert table metadata = table.getAllMetadata() assert metadata['__version'] == rstring('2') assert isinstance(metadata['double'], RFloatI) assert abs(metadata['double'].val - 0.1) < 1e-8 # WARNING: On the OMERO-server 5.3.4 Docker image this returns an # RLongI not an RIntI! Maybe pytables already made the decision to # treat int and longs the same? # assert isinstance(metadata['int'], RIntI) assert isinstance(metadata['int'], RLongI) assert metadata['int'].val == 1 assert isinstance(metadata['long'], RLongI) assert metadata['long'].val == 1 assert isinstance(metadata['string'], RStringI) assert metadata['string'].val == 'a' expectedTypes = [ omero.grid.FileColumn, omero.grid.ImageColumn, omero.grid.RoiColumn, omero.grid.WellColumn, omero.grid.PlateColumn, omero.grid.BoolColumn, omero.grid.DoubleColumn, omero.grid.LongColumn, omero.grid.StringColumn, omero.grid.MaskColumn, omero.grid.LongArrayColumn, omero.grid.FloatArrayColumn, omero.grid.DoubleArrayColumn, ] expectedNames = [ 'filecol', 'imagecol', 'roicol', 'wellcol', 'platecol', 'boolcol', 'doublecol', 'longcol', 'stringcol', 'mask', 'longarr', 'floatarr', 'doublearr', ] headers = table.getHeaders() assert [type(x) for x in headers] == expectedTypes assert [x.name for x in headers] == expectedNames assert table.getNumberOfRows() == 2 data = table.readCoordinates([0, 1]) testf = data.columns[0].values assert 10 == testf[0] assert 20 == testf[1] testi = data.columns[1].values assert 30 == testi[0] assert 40 == testi[1] testr = data.columns[2].values assert 50 == testr[0] assert 60 == testr[1] testw = data.columns[3].values assert 70 == testw[0] assert 80 == testw[1] testp = data.columns[4].values assert 90 == testp[0] assert 100 == testp[1] testb = data.columns[5].values assert testb[0] assert not testb[1] testd = data.columns[6].values assert 0.25 == testd[0] assert 0.5 == testd[1] testl = data.columns[7].values assert -1 == testl[0] assert -2 == testl[1] tests = data.columns[8].values assert "abc" == tests[0] assert "de" == tests[1] testm = data.columns[9] self.checkMaskCol(testm) testla = data.columns[10].values assert [-2, -1] == testla[0] assert [1, 2] == testla[1] testfa = data.columns[11].values assert [-0.25, -0.5] == testfa[0] assert [0.125, 0.0625] == testfa[1] testda = data.columns[12].values assert [-0.25, -0.5] == testda[0] assert [0.125, 0.0625] == testda[1] # Now try an update updatel = omero.grid.LongColumn('longcol', '', [12345]) updateData = omero.grid.Data(rowNumbers=[1], columns=[updatel]) table.update(updateData) assert table.getNumberOfRows() == 2 data2 = table.readCoordinates([0, 1]) for n in [0, 1, 2, 3, 4, 5, 6, 8, 10, 11, 12]: assert data.columns[n].values == data2.columns[n].values self.checkMaskCol(data2.columns[9]) testl2 = data2.columns[7].values assert -1 == testl2[0] assert 12345 == testl2[1] table.close()
def testAllColumns_4_4_5(self): """ Check whether a table created under 4.4.5 or older is still usable with a newer server """ ofile = self.uploadHdf5("service-reference-dev_4_4_5.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) assert table expectedTypes = [ omero.grid.FileColumn, omero.grid.ImageColumn, omero.grid.RoiColumn, omero.grid.WellColumn, omero.grid.PlateColumn, omero.grid.BoolColumn, omero.grid.DoubleColumn, omero.grid.LongColumn, omero.grid.StringColumn, omero.grid.MaskColumn ] #omero.grid.FloatArrayColumn, #omero.grid.DoubleArrayColumn, #omero.grid.LongArrayColumn, expectedNames = [ 'filecol', 'imagecol', 'roicol', 'wellcol', 'platecol', 'boolcol', 'doublecol', 'longcol', 'stringcol', 'mask' ] #'longarr' #'floatarr' #'doublearr' headers = table.getHeaders() assert [type(x) for x in headers] == expectedTypes assert [x.name for x in headers] == expectedNames assert table.getNumberOfRows() == 2 data = table.readCoordinates([0,1]) testf = data.columns[0].values assert 10 == testf[0] assert 20 == testf[1] testi = data.columns[1].values assert 30 == testi[0] assert 40 == testi[1] testr = data.columns[2].values assert 50 == testr[0] assert 60 == testr[1] testw = data.columns[3].values assert 70 == testw[0] assert 80 == testw[1] testp = data.columns[4].values assert 90 == testp[0] assert 100 == testp[1] testb = data.columns[5].values assert testb[0] assert not testb[1] testd = data.columns[6].values assert 0.25 == testd[0] assert 0.5 == testd[1] testl = data.columns[7].values assert -1 == testl[0] assert -2 == testl[1] tests = data.columns[8].values assert "abc" == tests[0] assert "de" == tests[1] testm = data.columns[9] self.checkMaskCol(testm) #testla = data.columns[10].values #assert [-2, -1] == testla[0] #assert [1, 2] == testla[1] #testda = data.columns[11].values #assert [-0.25, -0.5] == testda[0] #assert [0.125, 0.0625] == testda[1] # Now try an update updatel = omero.grid.LongColumn('longcol', '', [12345]) updateData = omero.grid.Data(rowNumbers = [1], columns = [updatel]) table.update(updateData) assert table.getNumberOfRows() == 2 data2 = table.readCoordinates([0,1]) for n in [0, 1, 2, 3, 4, 5, 6, 8]: assert data.columns[n].values == data2.columns[n].values self.checkMaskCol(data2.columns[9]) testl2 = data2.columns[7].values assert -1 == testl2[0] assert 12345 == testl2[1]
def testAllColumns_4_4_5(self): """ Check whether a table created under 4.4.5 or older is still usable with a newer server """ ofile = self.uploadHdf5("service-reference-dev_4_4_5.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) self.assert_(table) expectedTypes = [ omero.grid.FileColumn, omero.grid.ImageColumn, omero.grid.RoiColumn, omero.grid.WellColumn, omero.grid.PlateColumn, omero.grid.BoolColumn, omero.grid.DoubleColumn, omero.grid.LongColumn, omero.grid.StringColumn, omero.grid.MaskColumn ] #omero.grid.FloatArrayColumn, #omero.grid.DoubleArrayColumn, #omero.grid.LongArrayColumn, expectedNames = [ 'filecol', 'imagecol', 'roicol', 'wellcol', 'platecol', 'boolcol', 'doublecol', 'longcol', 'stringcol', 'mask' ] #'longarr' #'floatarr' #'doublearr' headers = table.getHeaders() self.assertEquals([type(x) for x in headers], expectedTypes) self.assertEquals([x.name for x in headers], expectedNames) self.assertEquals(table.getNumberOfRows(), 2) data = table.readCoordinates([0,1]) testf = data.columns[0].values self.assertEquals(10, testf[0]) self.assertEquals(20, testf[1]) testi = data.columns[1].values self.assertEquals(30, testi[0]) self.assertEquals(40, testi[1]) testr = data.columns[2].values self.assertEquals(50, testr[0]) self.assertEquals(60, testr[1]) testw = data.columns[3].values self.assertEquals(70, testw[0]) self.assertEquals(80, testw[1]) testp = data.columns[4].values self.assertEquals(90, testp[0]) self.assertEquals(100, testp[1]) testb = data.columns[5].values self.assertEquals(True, testb[0]) self.assertEquals(False, testb[1]) testd = data.columns[6].values self.assertEquals(0.25, testd[0]) self.assertEquals(0.5, testd[1]) testl = data.columns[7].values self.assertEquals(-1, testl[0]) self.assertEquals(-2, testl[1]) tests = data.columns[8].values self.assertEquals("abc", tests[0]) self.assertEquals("de", tests[1]) testm = data.columns[9] self.checkMaskCol(testm) #testla = data.columns[10].values #self.assertEquals([-2, -1], testla[0]) #self.assertEquals([1, 2], testla[1]) #testda = data.columns[11].values #self.assertEquals([-0.25, -0.5], testda[0]) #self.assertEquals([0.125, 0.0625], testda[1]) # Now try an update updatel = omero.grid.LongColumn('longcol', '', [12345]) updateData = omero.grid.Data(rowNumbers = [1], columns = [updatel]) table.update(updateData) self.assertEquals(table.getNumberOfRows(), 2) data2 = table.readCoordinates([0,1]) for n in [0, 1, 2, 3, 4, 5, 6, 8]: self.assertEquals(data.columns[n].values, data2.columns[n].values) self.checkMaskCol(data2.columns[9]) testl2 = data2.columns[7].values self.assertEquals(-1, testl2[0]) self.assertEquals(12345, testl2[1])
def testAllColumns_4_4_5(self): """ Check whether a table created under 4.4.5 or older is still usable with a newer server """ ofile = self.uploadHdf5("service-reference-dev_4_4_5.h5.bz2") grid = self.client.sf.sharedResources() table = grid.openTable(ofile) self.assert_(table) expectedTypes = [ omero.grid.FileColumn, omero.grid.ImageColumn, omero.grid.RoiColumn, omero.grid.WellColumn, omero.grid.PlateColumn, omero.grid.BoolColumn, omero.grid.DoubleColumn, omero.grid.LongColumn, omero.grid.StringColumn, omero.grid.MaskColumn ] #omero.grid.FloatArrayColumn, #omero.grid.DoubleArrayColumn, #omero.grid.LongArrayColumn, expectedNames = [ 'filecol', 'imagecol', 'roicol', 'wellcol', 'platecol', 'boolcol', 'doublecol', 'longcol', 'stringcol', 'mask' ] #'longarr' #'floatarr' #'doublearr' headers = table.getHeaders() self.assertEquals([type(x) for x in headers], expectedTypes) self.assertEquals([x.name for x in headers], expectedNames) self.assertEquals(table.getNumberOfRows(), 2) data = table.readCoordinates([0, 1]) testf = data.columns[0].values self.assertEquals(10, testf[0]) self.assertEquals(20, testf[1]) testi = data.columns[1].values self.assertEquals(30, testi[0]) self.assertEquals(40, testi[1]) testr = data.columns[2].values self.assertEquals(50, testr[0]) self.assertEquals(60, testr[1]) testw = data.columns[3].values self.assertEquals(70, testw[0]) self.assertEquals(80, testw[1]) testp = data.columns[4].values self.assertEquals(90, testp[0]) self.assertEquals(100, testp[1]) testb = data.columns[5].values self.assertEquals(True, testb[0]) self.assertEquals(False, testb[1]) testd = data.columns[6].values self.assertEquals(0.25, testd[0]) self.assertEquals(0.5, testd[1]) testl = data.columns[7].values self.assertEquals(-1, testl[0]) self.assertEquals(-2, testl[1]) tests = data.columns[8].values self.assertEquals("abc", tests[0]) self.assertEquals("de", tests[1]) testm = data.columns[9] self.checkMaskCol(testm) #testla = data.columns[10].values #self.assertEquals([-2, -1], testla[0]) #self.assertEquals([1, 2], testla[1]) #testda = data.columns[11].values #self.assertEquals([-0.25, -0.5], testda[0]) #self.assertEquals([0.125, 0.0625], testda[1]) # Now try an update updatel = omero.grid.LongColumn('longcol', '', [12345]) updateData = omero.grid.Data(rowNumbers=[1], columns=[updatel]) table.update(updateData) self.assertEquals(table.getNumberOfRows(), 2) data2 = table.readCoordinates([0, 1]) for n in [0, 1, 2, 3, 4, 5, 6, 8]: self.assertEquals(data.columns[n].values, data2.columns[n].values) self.checkMaskCol(data2.columns[9]) testl2 = data2.columns[7].values self.assertEquals(-1, testl2[0]) self.assertEquals(12345, testl2[1])