Exemplo n.º 1
0
    def _testCreateAllColumnsAndMetadata(self):

        grid = self.client.sf.sharedResources()
        repoMap = grid.repositories()
        repoObj = repoMap.descriptions[0]
        table = grid.newTable(repoObj.id.val, "/test")
        assert table

        # Supported metadata types
        # https://github.com/ome/omero-py/blob/v5.5.1/src/omero/hdfstorageV2.py#L466
        metadata = {
            'string': rstring('a'),
            'int': rint(1),
            'long': rlong(1),
            'double': rfloat(0.1),
        }

        fcol = columns.FileColumnI('filecol', 'file col')
        fcol.values = [10, 20]
        icol = columns.ImageColumnI('imagecol', 'image col')
        icol.values = [30, 40]
        rcol = columns.RoiColumnI('roicol', 'roi col')
        rcol.values = [50, 60]
        wcol = columns.WellColumnI('wellcol', 'well col')
        wcol.values = [70, 80]
        pcol = columns.PlateColumnI('platecol', 'plate col')
        pcol.values = [90, 100]

        bcol = columns.BoolColumnI('boolcol', 'bool col')
        bcol.values = [True, False]
        dcol = columns.DoubleColumnI('doublecol', 'double col')
        dcol.values = [0.25, 0.5]
        lcol = columns.LongColumnI('longcol', 'long col')
        lcol.values = [-1, -2]

        scol = columns.StringColumnI('stringcol', 'string col', 3)
        scol.values = ["abc", "de"]

        larr = columns.LongArrayColumnI('longarr', 'longarr col', 2)
        larr.values = [[-2, -1], [1, 2]]
        farr = columns.FloatArrayColumnI('floatarr', 'floatarr col', 2)
        farr.values = [[-0.25, -0.5], [0.125, 0.0625]]
        darr = columns.DoubleArrayColumnI('doublearr', 'doublearr col', 2)
        darr.values = [[-0.25, -0.5], [0.125, 0.0625]]

        dscol = columns.DatasetColumnI('datasetcol', 'dataset col')
        dscol.values = [110, 120]

        mask = self.createMaskCol()

        cols = [
            fcol, icol, rcol, wcol, pcol, bcol, dcol, lcol, scol, mask, larr,
            farr, darr, dscol
        ]

        table.initialize(cols)
        table.setAllMetadata(metadata)

        table.addData(cols)
        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]

        testds = data.columns[13].values
        assert 110 == testds[0]
        assert 120 == testds[1]

        ofile = table.getOriginalFile()
        print("Created OriginalFile:", ofile.getId().val)

        return table
    def testCreateAllColumns_4_4_5(self):
        """
        Call this method to create the reference HDF5 table under a 4.4.5
        or older server. The OriginalFile ID of the table will be printed,
        and can be used to find the file under ${omero.data.dir}/Files/.

        To run manually goto ``components/tools/OmeroPy``, and run:
        ``py.test test/integration/tablestest/test_backwards_compatibility.py\
        -s -k testCreateAllColumns_4_4_5``
        """
        grid = self.client.sf.sharedResources()
        repoMap = grid.repositories()
        repoObj = repoMap.descriptions[0]
        table = grid.newTable(repoObj.id.val, "/test")
        assert table

        fcol = columns.FileColumnI('filecol', 'file col')
        fcol.values = [10, 20]
        icol = columns.ImageColumnI('imagecol', 'image col')
        icol.values = [30, 40]
        rcol = columns.RoiColumnI('roicol', 'roi col')
        rcol.values = [50, 60]
        wcol = columns.WellColumnI('wellcol', 'well col')
        wcol.values = [70, 80]
        pcol = columns.PlateColumnI('platecol', 'plate col')
        pcol.values = [90, 100]

        bcol = columns.BoolColumnI('boolcol', 'bool col')
        bcol.values = [True, False]
        dcol = columns.DoubleColumnI('doublecol', 'double col')
        dcol.values = [0.25, 0.5]
        lcol = columns.LongColumnI('longcol', 'long col')
        lcol.values = [-1, -2]

        scol = columns.StringColumnI('stringcol', 'string col', 3)
        scol.values = ["abc", "de"]

        # larr = columns.LongArrayColumnI('longarr', 'longarr col', 2)
        # larr.values = [[-2, -1], [1, 2]]
        # farr = columns.FloatArrayColumnI('floatarr', 'floatarr col', 2)
        # farr.values = [[-0.25, -0.5], [0.125, 0.0625]]
        # darr = columns.DoubleArrayColumnI('doublearr', 'doublearr col', 2)
        # darr.values = [[-0.25, -0.5], [0.125, 0.0625]]

        mask = self.createMaskCol()

        cols = [fcol, icol, rcol, wcol, pcol,
                bcol, dcol, lcol, scol, mask]
        # larr, farr, darr]

        table.initialize(cols)
        table.addData(cols)
        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]

        ofile = table.getOriginalFile()
        print "Created OriginalFile:", ofile.getId().val
    def createAllColumns_4_4_5(self):
        """
        Call this method to create the reference HDF5 table under a 4.4.5
        or older server. The OriginalFile ID of the table will be printed,
        and can be used to find the file under ${omero.data.dir}/Files/.

        E.g. from the command goto ``components/tools/OmeroPy/test``, and run:
        ``python -m unittest tablestest.backwards_compatibility.BackwardsCompatibilityTest.createAllColumns_4_4_5``
        """
        grid = self.client.sf.sharedResources()
        repoMap = grid.repositories()
        repoObj = repoMap.descriptions[0]
        table = grid.newTable(repoObj.id.val, "/test")
        assert table

        fcol = omero.columns.FileColumnI('filecol', 'file col')
        fcol.values = [10, 20]
        icol = omero.columns.ImageColumnI('imagecol', 'image col')
        icol.values = [30, 40]
        rcol = omero.columns.RoiColumnI('roicol', 'roi col')
        rcol.values = [50, 60]
        wcol = omero.columns.WellColumnI('wellcol', 'well col')
        wcol.values = [70, 80]
        pcol = omero.columns.PlateColumnI('platecol', 'plate col')
        pcol.values = [90, 100]

        bcol = omero.columns.BoolColumnI('boolcol', 'bool col')
        bcol.values = [True, False]
        dcol = omero.columns.DoubleColumnI('doublecol', 'double col')
        dcol.values = [0.25, 0.5]
        lcol = omero.columns.LongColumnI('longcol', 'long col')
        lcol.values = [-1, -2]

        scol = omero.columns.StringColumnI('stringcol', 'string col', 3)
        scol.values = ["abc", "de"]

        #larr = omero.columns.LongArrayColumnI('longarr', 'longarr col', 2)
        #larr.values = [[-2, -1], [1, 2]]
        #farr = omero.columns.FloatArrayColumnI('floatarr', 'floatarr col', 2)
        #farr.values = [[-0.25, -0.5], [0.125, 0.0625]]
        #darr = omero.columns.DoubleArrayColumnI('doublearr', 'doublearr col', 2)
        #darr.values = [[-0.25, -0.5], [0.125, 0.0625]]

        mask = self.createMaskCol()

        cols = [fcol, icol, rcol, wcol, pcol,
                bcol, dcol, lcol, scol, mask]
                #larr, farr, darr]

        table.initialize(cols)
        table.addData(cols)
        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]

        ofile = table.getOriginalFile()
        print "Created OriginalFile:", ofile.getId().val
    def testCreateAllColumnsAndMetadata_5_3_4(self):
        """
        Call this method to create the reference HDF5 table under a 5.3.4
        Python 2.7 server. The OriginalFile ID of the table will be printed,
        and can be used to find the file under ${omero.data.dir}/Files/.
        Alternatively download it using
        ``omero download OriginalFile:FileID output.h5``

        To run manually goto ``components/tools/OmeroPy``, and run:
        ``pytest test/integration/tablestest/test_backwards_compatibility.py\
        -s -k testCreateAllColumnsAndMetadata_5_3_4``
        """
        grid = self.client.sf.sharedResources()
        repoMap = grid.repositories()
        repoObj = repoMap.descriptions[0]
        table = grid.newTable(repoObj.id.val, "/test")
        assert table

        # Supported metadata types
        # https://github.com/ome/omero-py/blob/v5.5.1/src/omero/hdfstorageV2.py#L466
        metadata = {
            'string': rstring('a'),
            'int': rint(1),
            'long': rlong(1),
            'double': rfloat(0.1),
        }

        fcol = columns.FileColumnI('filecol', 'file col')
        fcol.values = [10, 20]
        icol = columns.ImageColumnI('imagecol', 'image col')
        icol.values = [30, 40]
        rcol = columns.RoiColumnI('roicol', 'roi col')
        rcol.values = [50, 60]
        wcol = columns.WellColumnI('wellcol', 'well col')
        wcol.values = [70, 80]
        pcol = columns.PlateColumnI('platecol', 'plate col')
        pcol.values = [90, 100]

        bcol = columns.BoolColumnI('boolcol', 'bool col')
        bcol.values = [True, False]
        dcol = columns.DoubleColumnI('doublecol', 'double col')
        dcol.values = [0.25, 0.5]
        lcol = columns.LongColumnI('longcol', 'long col')
        lcol.values = [-1, -2]

        scol = columns.StringColumnI('stringcol', 'string col', 3)
        scol.values = ["abc", "de"]

        larr = columns.LongArrayColumnI('longarr', 'longarr col', 2)
        larr.values = [[-2, -1], [1, 2]]
        farr = columns.FloatArrayColumnI('floatarr', 'floatarr col', 2)
        farr.values = [[-0.25, -0.5], [0.125, 0.0625]]
        darr = columns.DoubleArrayColumnI('doublearr', 'doublearr col', 2)
        darr.values = [[-0.25, -0.5], [0.125, 0.0625]]

        # DatasetColumn is broken!

        mask = self.createMaskCol()

        cols = [
            fcol, icol, rcol, wcol, pcol, bcol, dcol, lcol, scol, mask, larr,
            farr, darr
        ]

        table.initialize(cols)
        table.setAllMetadata(metadata)

        table.addData(cols)
        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]

        ofile = table.getOriginalFile()
        print("Created OriginalFile:", ofile.getId().val)

        table.close()
Exemplo n.º 5
0
    def createAllColumns_4_4_5(self):
        """
        Call this method to create the reference HDF5 table under a 4.4.5
        or older server. The OriginalFile ID of the table will be printed,
        and can be used to find the file under ${omero.data.dir}/Files/.

        E.g. from the command goto ``components/tools/OmeroPy/test``, and run:
        ``python -m unittest tablestest.backwards_compatibility.BackwardsCompatibilityTest.createAllColumns_4_4_5``
        """
        grid = self.client.sf.sharedResources()
        repoMap = grid.repositories()
        repoObj = repoMap.descriptions[0]
        table = grid.newTable(repoObj.id.val, "/test")
        self.assert_(table)

        fcol = omero.columns.FileColumnI('filecol', 'file col')
        fcol.values = [10, 20]
        icol = omero.columns.ImageColumnI('imagecol', 'image col')
        icol.values = [30, 40]
        rcol = omero.columns.RoiColumnI('roicol', 'roi col')
        rcol.values = [50, 60]
        wcol = omero.columns.WellColumnI('wellcol', 'well col')
        wcol.values = [70, 80]
        pcol = omero.columns.PlateColumnI('platecol', 'plate col')
        pcol.values = [90, 100]

        bcol = omero.columns.BoolColumnI('boolcol', 'bool col')
        bcol.values = [True, False]
        dcol = omero.columns.DoubleColumnI('doublecol', 'double col')
        dcol.values = [0.25, 0.5]
        lcol = omero.columns.LongColumnI('longcol', 'long col')
        lcol.values = [-1, -2]

        scol = omero.columns.StringColumnI('stringcol', 'string col', 3)
        scol.values = ["abc", "de"]

        #larr = omero.columns.LongArrayColumnI('longarr', 'longarr col', 2)
        #larr.values = [[-2, -1], [1, 2]]
        #farr = omero.columns.FloatArrayColumnI('floatarr', 'floatarr col', 2)
        #farr.values = [[-0.25, -0.5], [0.125, 0.0625]]
        #darr = omero.columns.DoubleArrayColumnI('doublearr', 'doublearr col', 2)
        #darr.values = [[-0.25, -0.5], [0.125, 0.0625]]

        mask = self.createMaskCol()

        cols = [fcol, icol, rcol, wcol, pcol, bcol, dcol, lcol, scol, mask]
        #larr, farr, darr]

        table.initialize(cols)
        table.addData(cols)
        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])

        ofile = table.getOriginalFile()
        print "Created OriginalFile:", ofile.getId().val