Example #1
0
    def test3(self):
        df=DataFrame()
  
        with self.assertRaises(Exception) as cm:
            df.box_plot('a', output_dir='output')

        self.assertEqual(str(cm.exception),
                         'Table must have data to print data')
Example #2
0
    def test3(self):
        df = DataFrame()

        with self.assertRaises(Exception) as cm:
            df.box_plot('a', output_dir='output')

        self.assertEqual(str(cm.exception),
                         'Table must have data to print data')
Example #3
0
    def test6(self):
        df = DataFrame()
        df['a'] = [2, 5]
        df['b'] = [2, 3]

        with self.assertRaises(KeyError) as cm:
            df.box_plot('c', output_dir='output')

        self.assertEqual(str(cm.exception), "'c'")
Example #4
0
    def test5(self):
        df = DataFrame()
        df['a'] = [2, 5]
        df['b'] = [2, 3]

        with self.assertRaises(Exception) as cm:
            df.box_plot('a', 42, output_dir='output')

        self.assertEqual(str(cm.exception), "'int' object is not iterable")
Example #5
0
    def test4(self):
        df = DataFrame()
        df['a'] = [2]
        df['b'] = [2, 3]

        with self.assertRaises(Exception) as cm:
            df.box_plot('a', output_dir='output')

        self.assertEqual(str(cm.exception), 'columns have unequal lengths')
Example #6
0
    def test6(self):
        df=DataFrame()
        df['a']=[2,5]
        df['b']=[2,3]
  
        with self.assertRaises(KeyError) as cm:
            df.box_plot('c', output_dir='output')

        self.assertEqual(str(cm.exception),"'c'")
Example #7
0
    def test5(self):
        df=DataFrame()
        df['a']=[2,5]
        df['b']=[2,3]
  
        with self.assertRaises(Exception) as cm:
            df.box_plot('a',42, output_dir='output')

        self.assertEqual(str(cm.exception),
                         "'int' object is not iterable")
Example #8
0
    def test4(self):
        df=DataFrame()
        df['a']=[2]
        df['b']=[2,3]
  
        with self.assertRaises(Exception) as cm:
            df.box_plot('a', output_dir='output')

        self.assertEqual(str(cm.exception),
                         'columns have unequal lengths')
Example #9
0
    def test1(self):
        R = {
            'd': [
                np.array([
                    9, 8, 6, 8, 10, 4, 6, 5, 7, 7, 7, 9, 6, 6, 6, 11, 6, 3, 8,
                    7, 11, 13, 8, 6, 14, 11, 13, 13, 10, 11, 12, 11, 16, 11, 9,
                    23, 12, 10, 19, 11, 10, 19, 14, 5, 10, 11, 14, 15, 11, 11
                ]),
                np.array([
                    8, 6, 4, 6, 7, 6, 5, 7, 9, 7, 10, 7, 8, 10, 4, 7, 10, 6, 7,
                    7, 14, 11, 18, 14, 13, 22, 17, 16, 12, 11, 20, 16, 16, 15,
                    18, 16, 20, 22, 14, 19, 21, 19, 17, 15, 22, 16, 22, 22, 18,
                    21
                ])
            ],
            'fname':
            'output\\box(WORDS~AGE).png',
            'maintitle':
            'WORDS by AGE',
            'xlabels': ['AGE = old', 'AGE = young']
        }

        df = DataFrame()
        df.TESTMODE = True
        df.read_tbl('data/words~ageXcondition.csv')
        D = df.box_plot('WORDS', ['AGE'], output_dir='output')

        self.assertEqual(D['fname'], R['fname'])
        self.assertEqual(D['maintitle'], R['maintitle'])
        self.assertEqual(D['xlabels'], R['xlabels'])

        for d, r in zip(np.array(D['d']).flat, np.array(R['d']).flat):
            self.assertAlmostEqual(d, r)
Example #10
0
    def test0(self):
        R = {
            'd': [
                9.0, 8.0, 6.0, 8.0, 10.0, 4.0, 6.0, 5.0, 7.0, 7.0, 7.0, 9.0,
                6.0, 6.0, 6.0, 11.0, 6.0, 3.0, 8.0, 7.0, 11.0, 13.0, 8.0, 6.0,
                14.0, 11.0, 13.0, 13.0, 10.0, 11.0, 12.0, 11.0, 16.0, 11.0,
                9.0, 23.0, 12.0, 10.0, 19.0, 11.0, 10.0, 19.0, 14.0, 5.0, 10.0,
                11.0, 14.0, 15.0, 11.0, 11.0, 8.0, 6.0, 4.0, 6.0, 7.0, 6.0,
                5.0, 7.0, 9.0, 7.0, 10.0, 7.0, 8.0, 10.0, 4.0, 7.0, 10.0, 6.0,
                7.0, 7.0, 14.0, 11.0, 18.0, 14.0, 13.0, 22.0, 17.0, 16.0, 12.0,
                11.0, 20.0, 16.0, 16.0, 15.0, 18.0, 16.0, 20.0, 22.0, 14.0,
                19.0, 21.0, 19.0, 17.0, 15.0, 22.0, 16.0, 22.0, 22.0, 18.0,
                21.0
            ],
            'fname':
            'output\\box(WORDS).png',
            'maintitle':
            'WORDS',
            'val':
            'WORDS'
        }

        df = DataFrame()
        df.TESTMODE = True
        df.read_tbl('data/words~ageXcondition.csv')
        D = df.box_plot('WORDS', output_dir='output')

        self.assertEqual(D['fname'], R['fname'])
        self.assertEqual(D['maintitle'], R['maintitle'])
        self.assertEqual(D['val'], R['val'])

        for d, r in zip(np.array(D['d']).flat, np.array(R['d']).flat):
            self.assertAlmostEqual(d, r)
Example #11
0
    def test1(self):
        R = {'d': [np.array([ 9,  8,  6,  8, 10,  4,  6,  5,  7,  7,
                              7,  9,  6,  6,  6, 11,  6,  3,  8,  7,
                              11, 13,  8,  6, 14, 11, 13, 13, 10, 11,
                              12, 11, 16, 11,  9, 23, 12, 10, 19, 11,
                              10, 19, 14,  5, 10, 11, 14, 15, 11, 11]),
                   np.array([ 8,  6,  4,  6,  7,  6,  5,  7,  9,  7,
                              10,  7,  8, 10,  4,  7, 10, 6,  7,  7,
                              14, 11, 18, 14, 13, 22, 17, 16, 12, 11,
                              20, 16, 16, 15, 18, 16, 20, 22, 14, 19,
                              21, 19, 17, 15, 22, 16, 22, 22, 18, 21])],
             'fname': 'output\\box(WORDS~AGE).png',
             'maintitle': 'WORDS by AGE',
             'xlabels': [u'AGE = old', u'AGE = young']}
        
        df=DataFrame()
        df.TESTMODE=True
        df.read_tbl('data/words~ageXcondition.csv')
        D=df.box_plot('WORDS',['AGE'], output_dir='output')

        self.assertEqual(D['fname'],R['fname'])
        self.assertEqual(D['maintitle'],R['maintitle'])
        self.assertEqual(D['xlabels'],R['xlabels'])
        
        for d,r in zip(np.array(D['d']).flat,
                       np.array(R['d']).flat):
            self.assertAlmostEqual(d,r)
Example #12
0
 def test0(self):
     R = {'d': [9.0, 8.0, 6.0, 8.0, 10.0, 4.0, 6.0, 5.0, 7.0, 7.0,
                7.0, 9.0, 6.0, 6.0, 6.0, 11.0, 6.0, 3.0, 8.0, 7.0,
                11.0, 13.0, 8.0, 6.0, 14.0, 11.0, 13.0, 13.0, 10.0,
                11.0, 12.0, 11.0, 16.0, 11.0, 9.0, 23.0, 12.0, 10.0,
                19.0, 11.0, 10.0, 19.0, 14.0, 5.0, 10.0, 11.0, 14.0,
                15.0, 11.0, 11.0, 8.0, 6.0, 4.0, 6.0, 7.0, 6.0, 5.0,
                7.0, 9.0, 7.0, 10.0, 7.0, 8.0, 10.0, 4.0, 7.0, 10.0,
                6.0, 7.0, 7.0, 14.0, 11.0, 18.0, 14.0, 13.0, 22.0, 17.0,
                16.0, 12.0, 11.0, 20.0, 16.0, 16.0, 15.0, 18.0, 16.0,
                20.0, 22.0, 14.0, 19.0, 21.0, 19.0, 17.0, 15.0, 22.0,
                16.0, 22.0, 22.0, 18.0, 21.0],
          'fname': 'output\\box(WORDS).png',
          'maintitle': 'WORDS',
          'val': 'WORDS'}
     
     df=DataFrame()
     df.TESTMODE=True
     df.read_tbl('data/words~ageXcondition.csv')
     D=df.box_plot('WORDS', output_dir='output')
     
     self.assertEqual(D['fname'],R['fname'])
     self.assertEqual(D['maintitle'],R['maintitle'])
     self.assertEqual(D['val'],R['val'])
     
     for d,r in zip(np.array(D['d']).flat,
                    np.array(R['d']).flat):
         self.assertAlmostEqual(d,r)        
Example #13
0
def pivotTableBoxplot(filename,uid,factors):
	df = DataFrame()
	df.read_tbl(os.path.join(app.config['DATA_FOLDER'], filename))
	df.box_plot('data',factors)
	origoutputfn = "box(data~"+factors[0]
	for i in range(1,len(factors)):
		origoutputfn+=("_X_"+factors[i])
	origoutputfn+=").png"
	outputfn = 'box_plot'
	for i in range(0,len(factors)):
		outputfn+='_'+factors[i]
	outputfn+='.png'

	#  TODO:  check if file exists

	#  Need to move/rename because output automatically goes to the base directory
	os.rename(os.path.join(app.config['BASEDIR'], origoutputfn), os.path.join(app.config['DATA_FOLDER'], outputfn))
	return outputfn
Example #14
0
    def test2(self):
        R = {
            'd': [
                np.array([11, 13, 8, 6, 14, 11, 13, 13, 10, 11]),
                np.array([9, 8, 6, 8, 10, 4, 6, 5, 7, 7]),
                np.array([12, 11, 16, 11, 9, 23, 12, 10, 19, 11]),
                np.array([10, 19, 14, 5, 10, 11, 14, 15, 11, 11]),
                np.array([7, 9, 6, 6, 6, 11, 6, 3, 8, 7]),
                np.array([14, 11, 18, 14, 13, 22, 17, 16, 12, 11]),
                np.array([8, 6, 4, 6, 7, 6, 5, 7, 9, 7]),
                np.array([20, 16, 16, 15, 18, 16, 20, 22, 14, 19]),
                np.array([21, 19, 17, 15, 22, 16, 22, 22, 18, 21]),
                np.array([10, 7, 8, 10, 4, 7, 10, 6, 7, 7])
            ],
            'fname':
            'output\\box(WORDS~AGE_X_CONDITION).png',
            'maintitle':
            'WORDS by AGE * CONDITION',
            'xlabels': [
                'AGE = old\nCONDITION = adjective',
                'AGE = old\nCONDITION = counting',
                'AGE = old\nCONDITION = imagery',
                'AGE = old\nCONDITION = intention',
                'AGE = old\nCONDITION = rhyming',
                'AGE = young\nCONDITION = adjective',
                'AGE = young\nCONDITION = counting',
                'AGE = young\nCONDITION = imagery',
                'AGE = young\nCONDITION = intention',
                'AGE = young\nCONDITION = rhyming'
            ]
        }

        df = DataFrame()
        df.TESTMODE = True
        df.read_tbl('data/words~ageXcondition.csv')
        D = df.box_plot('WORDS', ['AGE', 'CONDITION'], output_dir='output')

        self.assertEqual(D['fname'], R['fname'])
        self.assertEqual(D['maintitle'], R['maintitle'])
        self.assertEqual(D['xlabels'], R['xlabels'])

        for d, r in zip(np.array(D['d']).flat, np.array(R['d']).flat):
            self.assertAlmostEqual(d, r)
Example #15
0
    def test2(self):
        R = {'d': [np.array([11, 13,  8,  6, 14, 11, 13, 13, 10, 11]),
                   np.array([ 9,  8,  6,  8, 10,  4,  6,  5,  7,  7]),
                   np.array([12, 11, 16, 11,  9, 23, 12, 10, 19, 11]),
                   np.array([10, 19, 14,  5, 10, 11, 14, 15, 11, 11]),
                   np.array([ 7,  9,  6,  6,  6, 11,  6,  3,  8,  7]),
                   np.array([14, 11, 18, 14, 13, 22, 17, 16, 12, 11]),
                   np.array([8, 6, 4, 6, 7, 6, 5, 7, 9, 7]),
                   np.array([20, 16, 16, 15, 18, 16, 20, 22, 14, 19]),
                   np.array([21, 19, 17, 15, 22, 16, 22, 22, 18, 21]),
                   np.array([10,  7,  8, 10,  4,  7, 10,  6,  7,  7])],
             'fname': 'output\\box(WORDS~AGE_X_CONDITION).png',
             'maintitle': 'WORDS by AGE * CONDITION',
             'xlabels': [u'AGE = old\nCONDITION = adjective',
                         u'AGE = old\nCONDITION = counting',
                         u'AGE = old\nCONDITION = imagery',
                         u'AGE = old\nCONDITION = intention',
                         u'AGE = old\nCONDITION = rhyming',
                         u'AGE = young\nCONDITION = adjective',
                         u'AGE = young\nCONDITION = counting',
                         u'AGE = young\nCONDITION = imagery',
                         u'AGE = young\nCONDITION = intention',
                         u'AGE = young\nCONDITION = rhyming']}
        
        df=DataFrame()
        df.TESTMODE=True
        df.read_tbl('data/words~ageXcondition.csv')
        D=df.box_plot('WORDS',['AGE','CONDITION'], output_dir='output')

        self.assertEqual(D['fname'],R['fname'])
        self.assertEqual(D['maintitle'],R['maintitle'])
        self.assertEqual(D['xlabels'],R['xlabels'])
        
        for d,r in zip(np.array(D['d']).flat,
                       np.array(R['d']).flat):
            self.assertAlmostEqual(d,r)