def test_fill_small_dict(self):
        fvm = FeatureVectorMatrix()
        fvm.add_row(d3)
        self.assertEquals(fvm.get_row_dict(0), d3)

        fvm.add_row(d4)
        self.assertEquals(fvm.get_row_dict(1), d4)

        self.assertEquals(fvm.get_row_list(0), [ d3[c] if c in d3 else fvm._default_value for c in fvm.column_names() ])
    def test_matrix(self):
        fvm = FeatureVectorMatrix()
        fvm.set_column_names(c3)
        fvm.add_row(d3, 'one')
        fvm.add_row(d4, 'two')
        fvm.add_row(d4, 'three')

        self.assertEquals(4, fvm.column_count())
        self.assertEquals(3, fvm.row_count())

        v3_old = fvm.get_row_list(0)
        self.assertEquals(fvm.get_row_dict('two'), d4)

        rfvm = fvm.transpose()
        self.assertEquals(3, rfvm.column_count())
        self.assertEquals(4, rfvm.row_count())

        self.assertEquals(rfvm.get_row_dict(2), {'three': 3, 'two': 3, 'one': 3})
        self.assertEquals(rfvm.get_row_dict(3), {'two': 4, 'three': 4})

        self.assertEquals(rfvm.column_names(), ['one', 'two', 'three'])
        self.assertEquals(rfvm.get_row_list(2), [3, 3, 3])
        self.assertEquals(rfvm.get_row_list(3), [0, 4, 4])

        fvm2 = rfvm.transpose()
        self.assertEquals(4, fvm2.column_count())
        self.assertEquals(3, fvm2.row_count())

        self.assertEquals(fvm2.get_row_dict(2), d4)
        self.assertEquals(fvm2.get_row_dict(0), d3)
        self.assertEquals(fvm2.get_row_list(0), v3_old)

        self.assertEquals(fvm2.get_row_dict('two'), d4)
    def test2(self):
        fvm = FeatureVectorMatrix()
        fvm.set_column_names(c3)
        self.assertEquals(c3, fvm.column_names())

        fvm.add_row(d3)
        self.assertEquals(3, fvm.column_count())

        self.assertEquals(fvm.get_row_list(0), v3)

        fvm.add_row(d2_4)
        self.assertEquals(7, fvm.column_count())
        self.assertEquals(fvm.get_row_list(0), v3 + [0,0,0,0])
        self.assertEquals(fvm.get_row_dict(0), d3)
    def test2_key(self):
        fvm = FeatureVectorMatrix()
        fvm.set_column_names(c3)
        self.assertEquals(c3, fvm.column_names())

        fvm.add_row(d3, 'a')
        self.assertEquals(3, fvm.column_count())

        self.assertEquals(fvm.get_row_list('a'), v3)

        fvm.add_row(d2_4, 'b')
        self.assertEquals(7, fvm.column_count())
        self.assertEquals(fvm.get_row_list('a'), v3 + [0,0,0,0])
        self.assertEquals(fvm['a'], v3 + [0,0,0,0])
        self.assertEquals(fvm[0], v3 + [0,0,0,0])

        self.assertEquals(fvm.get_row_dict('a'), d3)

        self.assertEquals([ k for k in fvm ], ['a', 'b'])