def test_encode_too_many_attributes_dense(self): my_arff = { "attributes": [["attr", "INTEGER"]], "data": [[0], [1, 2]], "relation": 'Too many attributes' } encoder = arff.ArffEncoder() with self.assertRaisesRegexp( arff.BadObject, "Instance 1 has 2 attributes, expected 1"): encoder.encode(my_arff)
def test_encode_too_many_attributes_coo(self): coo = COOStub([1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 3], [0, 1, 2, 3, 4, 5, 0]) coo.format = 'coo' my_arff = { "attributes": [["attr", "INTEGER"]], "data": coo, "relation": 'Too many attributes' } encoder = arff.ArffEncoder() with self.assertRaisesRegexp( arff.BadObject, "Instance 1 has at least 2 attributes, " "expected 1"): encoder.encode(my_arff)
def get_encoder(self): encoder = arff.ArffEncoder() return encoder
def get_encoder(self): decoder = arff.ArffEncoder() return decoder
def write(self, obj, filename): encoder = arff.ArffEncoder() f = open(filename, 'wb') f.write(encoder.encode(obj)) f.close() return