<commit_before>import relations


def test_equivalent_relations_are_union_compatible():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('gender', 'age', 'name')
    assert rel1.is_union_compatible(rel2)


def test_unequivalent_relations_are_union_compatible():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('symbol', 'price')
    assert not rel1.is_union_compatible(rel2)<commit_msg>Added tests for set union.<commit_after>from nose.tools import assert_raises

import relations


def test_equivalent_relations_are_union_compatible():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('gender', 'age', 'name')
    assert rel1.is_union_compatible(rel2)


def test_unequivalent_relations_are_union_compatible():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('symbol', 'price')
    assert not rel1.is_union_compatible(rel2)


def test_union_contains_elements_from_both_relations():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('gender', 'age', 'name')
    rel1.add(name='Alice', age=25, gender='F')
    rel2.add(name='Bob', age=32, gender='M')

    union = rel1.union(rel2)
    assert union.contains(name='Alice', age=25, gender='F')
    assert union.contains(name='Bob', age=32, gender='M')


def test_union_raises_error_if_not_union_compatible():
    rel1 = relations.Relation('name', 'age', 'gender')
    rel2 = relations.Relation('symbol', 'price')
    rel1.add(name='Alice', age=25, gender='F')
    rel2.add(symbol='AAPL', price='424.47')

    assert_raises(relations.NotUnionCompatible,
                  lambda: rel1.union(rel2))
{'fraction_non_alphanumeric': 0.148664343786295, 'fraction_numerical': 0.02497096399535424, 'mean_word_length': 5.334558823529412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5689813', 'n_tokens_mistral': 588, 'n_tokens_neox': 559, 'n_words': 102}