def test_loading_unordered_feature_lists(tmpdir):
    d = {
        'a/N': [('f1', 1), ('f2', 2), ('f3', 3)],
        'b/N': [('f3', 3), ('f1', 1), ('f2', 2), ],
        'c/N': [('f3', 3), ('f2', 2), ('f1', 1)],
    }  # three identical vectors
    v = Vectors(d)
    filename = str(tmpdir.join('outfile.txt'))
    v.to_tsv(filename)

    v1 = v.from_tsv(filename)
    assert v.columns == v1.columns # rows can be in any order, but columns need to be sorted
    for word in d.keys():
        assert_array_equal(v.get_vector(word).A, v1.get_vector(word).A)
def test_loading_dict_of_dicts():
    d = {
        'monday': {
            'det:the': 23,
            'amod:terrible': 321
        },
        'tuesday': {
            'amod:awful': 231,
            'det:a': 12
        }
    }
    v = Vectors(d)

    v1 = v.from_dict_of_dicts(d)
    assert v.columns == v1.columns
    for word in d.keys():
        assert_array_equal(v.get_vector(word).A, v1.get_vector(word).A)