Пример #1
0
def test_d4c2_100():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("100_" + str(batch))
        res = s.score(filename, '100')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(aurocs,
        [0.5177063077, 0.59869942, 0.515280254692,0.5796535, 0.50947022])
Пример #2
0
def test_d4c2_100_2():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("100_multifactorial_" + str(batch))
        res = s.score(filename, '100_multifactorial')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(aurocs,
       [0.491887457, 0.495480003, 0.506360189, 0.501096420, 0.501367796])
Пример #3
0
def test_d4c2_100_2():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("100_multifactorial_" + str(batch))
        res = s.score(filename, '100_multifactorial')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(
        aurocs,
        [0.491887457, 0.495480003, 0.506360189, 0.501096420, 0.501367796])
Пример #4
0
def test_d4c2_10():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("10_" + str(batch))
        res = s.score(filename, '10')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(
        aurocs,
        [0.556444444444, 0.521537162162, 0.54, 0.518481518482, 0.449786324786])
Пример #5
0
def test_d4c2_10():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("10_" + str(batch))
        res = s.score(filename, '10')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(aurocs,
         [0.556444444444, 0.521537162162, 0.54, 0.518481518482,
            0.449786324786])
Пример #6
0
def test_d4c2_100():
    s = D4C2()
    aurocs = []
    for batch in myrange:
        filename = s.download_template("100_" + str(batch))
        res = s.score(filename, '100')
        aurocs.append(res['AUROC'])

    assert_list_almost_equal(
        aurocs,
        [0.5177063077, 0.59869942, 0.515280254692, 0.5796535, 0.50947022])
Пример #7
0
def test_d3c4_10():
    # we have templates for 10 only 
    s = D3C4()
    aurocs = []
    for batch in ['Ecoli1', 'Ecoli2', 'Yeast1']:
        filename = s.download_template('10_'+ batch)
        print filename
        aurocs.append(s.score(filename, '10')['AUPR'])

    assert_list_almost_equal(aurocs,
         [0.3294927, 0.6283442, 0.368482140], 7)
Пример #8
0
def test_rgb2hsv():
    assert_list_almost_equal(colors.rgb2hsv(0, 1, 1), (0.5, 1, 1))
    assert_list_almost_equal(colors.rgb2hsv(0, 255, 255, normalised=False),
                             (0.5, 1, 1))

    assert_list_almost_equal(hsv2rgb(0.5, 1, 1), (0, 1, 1))
    assert_list_almost_equal(colors.hsv2rgb(180, 100, 100, normalised=False),
                             (0, 1, 1))
Пример #9
0
def test_d3c4_10():
    # we have templates for 10 only
    s = D3C4()
    s.test()

    aurocs = []
    for batch in ["Ecoli1", "Ecoli2", "Yeast1"]:
        filename = s.download_template("10_" + batch)
        print(filename)
        aurocs.append(s.score(filename, "10")["AUPR"])

    assert_list_almost_equal(aurocs, [0.3294927, 0.6283442, 0.368482140], 7)

    # other code
    s._warning()
Пример #10
0
def test_rgb2hls():
    assert_list_almost_equal(colors.rgb2hls(0, 1, 1), (0.5, 0.5, 1))
    assert_list_almost_equal(colors.rgb2hls(0, 255, 255, normalised=False),
                             (0.5, 0.5, 1))

    assert_list_almost_equal(colors.hls2rgb(0.5, 0.5, 1), (0, 1, 1))
    assert_list_almost_equal(colors.hls2rgb(180, 50, 100, normalised=False),
                             (0., 1, 1))
Пример #11
0
def test_rgb2hls():
    assert_list_almost_equal(colors.rgb2hls(0,1,1) , (0.5,0.5,1))
    assert_list_almost_equal(colors.rgb2hls(0,255,255,normalised=False) ,
            (0.5,0.5,1))

    assert_list_almost_equal(colors.hls2rgb(0.5,0.5,1), (0,1,1))
    assert_list_almost_equal(colors.hls2rgb(180, 50, 100, normalised=False),
            (0.,1,1))
Пример #12
0
def test_d3c4_10():
    # we have templates for 10 only 
    s = D3C4()
    s.test()

    aurocs = []
    for batch in ['Ecoli1', 'Ecoli2', 'Yeast1']:
        filename = s.download_template('10_'+ batch)
        print(filename)
        aurocs.append(s.score(filename, '10')['AUPR'])

    assert_list_almost_equal(aurocs,
         [0.3294927, 0.6283442, 0.368482140], 7)

    # other code
    s._warning()
Пример #13
0
def test_shuffle():
    m = XMIDAS(cnodata("MD-ToyPB.csv"))

    # shuffling over signals should keep the sum over signal constan
    a1 = m.df.sum(axis=0)
    for this in ['signal', 'column']:
        m.shuffle(mode=this)
        a2 = m.df.sum(axis=0)
        assert_list_almost_equal(a1, a2)
        m.reset()

    # shuffling over index keep sum over a given experiment constant
    a1 = m.df.sum(level="experiment").sum(axis=1)
    m.shuffle(mode="index")
    a2 = m.df.sum(level="experiment").sum(axis=1)
    assert_list_almost_equal(a1, a2)
    m.reset()

    m.shuffle(mode="timeseries")

    m.reset()
    a1 = m.df.sum().sum()
    m.shuffle(mode="all")
    a2 = m.df.sum().sum()
    assert_list_almost_equal([a1], [a2])
Пример #14
0
def test_rgb2yuv():
    assert_list_almost_equal(rgb2yuv(1, 1, 1), (1, 0, 0))
    assert_list_almost_equal(rgb2yuv_int(255, 255, 255), (255, 0, 0))

    assert_list_almost_equal(yuv2rgb(1, 0, 0), (1, 1, 1))
    assert_list_almost_equal(yuv2rgb_int(255, 0, 0), (255, 255, 255))
Пример #15
0
def testColors():
    # test constructors
    c = colors.Color("#FFF")
    c = colors.Color(rgb=(0, 0, 0))
    c = colors.Color(hls=(0, 0, 0))
    c = colors.Color(hsv=(0, 0, 0))
    c = colors.Color(c)
    try:
        colors.Color()
        assert False
    except:
        assert True
    try:
        colors.Color(object)
        assert False
    except:
        assert True

    # test setter/getter
    c = colors.Color("Blue")
    assert c.rgb == (0, 0, 1)
    assert c.hex == "#0000FF"
    assert_list_almost_equal(c.hsv, (0.66666666666666, 1, 1))
    assert_list_almost_equal(c.hls, (0.666666666666666, .5, 1))
    print(c)

    c.normalised = True
    c.name
    c.hsv
    c.hls
    print(c)
    assert c.rgb == (0, 0, 1)
    c.rgb = (0, 0, 1)
    c.hsv = (0, 0, 1)

    c.normalised = False

    # name can be changed and affects RGB/HEX
    c.name = "Magenta"
    assert c.rgb == colors._normalise(255, 0.0, 255)

    assert c.hex == "#FF00FF"

    # hex can be changed and affects name/HEX
    c.hex = "#F8F8FF"
    assert c.name == "Ghost White"  # non official name
    #assert c.rgb ==

    # RGB can be changed and affects name/HEX
    c.rgb = colors._normalise(248, 248, 255)
    assert c.name == "Ghost White"  # official name
    assert c.hex == "#F8F8FF"
    assert c.name == "Ghost White"  # non official but works
    assert c.hex == "#F8F8FF"
    c.saturation_hls = 0.5
    assert c.saturation_hls == 0.5

    c.lightness = 0.5
    assert c.lightness == 0.5
    c.hue = 0.5
    assert c.hue == 0.5

    c.hex = "#FF1F1F"
    assert c.name == "undefined"
    try:
        c.hex = "ZFF1F1F"
        assert False
    except:
        assert True

    c = colors.Color("red")
    assert c.red == 1
    assert c.green == 0
    assert c.blue == 0
    c.blue = 0.
    c.green = 0.
    c.red = 0
    assert c.name == "Black"
    c.value
    c.value = 0.5
    c.yiq
Пример #16
0
def test_rgb2hsv():
    assert_list_almost_equal( colors.rgb2hsv(0,1,1) , (0.5,1,1))
    assert_list_almost_equal(colors.rgb2hsv(0,255,255, normalised=False) , (0.5,1,1))

    assert_list_almost_equal(hsv2rgb(0.5,1,1) , (0,1,1))
    assert_list_almost_equal(colors.hsv2rgb(180,100,100, normalised=False), (0,1,1))
Пример #17
0
def test_rgb2yuv():
    assert_list_almost_equal(rgb2yuv(1,1,1) , (1,0,0))
    assert_list_almost_equal(rgb2yuv_int(255,255,255) , (255,0,0))

    assert_list_almost_equal(yuv2rgb(1,0,0) , (1,1,1))
    assert_list_almost_equal(yuv2rgb_int(255,0,0) , (255,255,255))
Пример #18
0
def testColors():
    # test constructors
    c = colors.Color("#FFF")
    c = colors.Color(rgb=(0,0,0))
    c = colors.Color(hls=(0,0,0))
    c = colors.Color(hsv=(0,0,0))
    c = colors.Color(c)
    try:
        colors.Color()
        assert False
    except:
        assert True
    try:
        colors.Color(object)
        assert False
    except:
        assert True

    
    # test setter/getter
    c = colors.Color("Blue")
    assert c.rgb == (0, 0 ,1)
    assert c.hex == "#0000FF"
    assert_list_almost_equal( c.hsv, (0.66666666666666,1,1))
    assert_list_almost_equal(c.hls, (0.666666666666666, .5,1))
    print(c)

    c.normalised = True
    c.name
    c.hsv
    c.hls
    print(c)
    assert c.rgb == (0,0,1)
    c.rgb = (0,0,1)
    c.hsv= (0,0,1)

    c.normalised = False

    # name can be changed and affects RGB/HEX
    c.name = "Magenta"
    assert c.rgb == colors._normalise(255, 0.0, 255)
    
    assert c.hex == "#FF00FF"

    # hex can be changed and affects name/HEX
    c.hex = "#F8F8FF"
    assert c.name == "Ghost White"   # non official name
    #assert c.rgb == 

    # RGB can be changed and affects name/HEX
    c.rgb = colors._normalise(248,248,255)
    assert c.name == "Ghost White"  # official name
    assert c.hex == "#F8F8FF"
    assert c.name == "Ghost White"  # non official but works
    assert c.hex == "#F8F8FF"
    c.saturation_hls = 0.5
    assert c.saturation_hls == 0.5

    c.lightness = 0.5
    assert c.lightness == 0.5
    c.hue = 0.5
    assert c.hue == 0.5

    c.hex = "#FF1F1F"
    assert c.name == "undefined"
    try:
        c.hex = "ZFF1F1F"
        assert False
    except:
        assert True

    c = colors.Color("red")
    assert c.red == 1
    assert c.green == 0
    assert c.blue == 0
    c.blue = 0.
    c.green=0.
    c.red = 0
    assert c.name == "Black"
    c.value
    c.value = 0.5
    c.yiq