Exemplo n.º 1
0
def test_concept_style_cuts():
    assert list(concept_cuts(Direction.CAUSE, (0,))) == [
        KCut(Direction.CAUSE, KPartition(
            Part((), ()), Part((), (0,)), Part((0,), ())))]
    assert list(concept_cuts(Direction.EFFECT, (0,))) == [
        KCut(Direction.EFFECT, KPartition(
            Part((), ()), Part((), (0,)), Part((0,), ())))]
Exemplo n.º 2
0
def test_system_accessors(s):
    cut_cause = KCut(Direction.CAUSE,
                     KPartition(Part((0, 2), (0, 1)), Part((1, ), (2, ))))
    cs_cause = ConceptStyleSystem(s, Direction.CAUSE, cut_cause)
    assert cs_cause.cause_system.cut == cut_cause
    assert not cs_cause.effect_system.is_cut

    cut_effect = KCut(Direction.EFFECT,
                      KPartition(Part((0, 2), (0, 1)), Part((1, ), (2, ))))
    cs_effect = ConceptStyleSystem(s, Direction.EFFECT, cut_effect)
    assert not cs_effect.cause_system.is_cut
    assert cs_effect.effect_system.cut == cut_effect
Exemplo n.º 3
0
def test_kcut_equality(kcut_cause, kcut_effect):
    other = KCut(Direction.CAUSE, KPartition(
        Part((0, 2), (0,)), Part((), (2,)), Part((3,), (3,))))
    assert kcut_cause == other
    assert hash(kcut_cause) == hash(other)
    assert hash(kcut_cause) != hash(kcut_cause.partition)

    assert kcut_cause != kcut_effect
    assert hash(kcut_cause) != hash(kcut_effect)
Exemplo n.º 4
0
def test_all_partitions():
    mechanism, purview = (0, 1), (2, )
    assert set(all_partitions(mechanism, purview)) == set([
        KPartition(Part((0, 1), ()), Part((), (2, ))),
        KPartition(Part((0, ), ()), Part((1, ), ()), Part((), (2, ))),
        KPartition(Part((0, ), (2, )), Part((1, ), ()), Part((), ())),
        KPartition(Part((0, ), ()), Part((1, ), (2, )), Part((), ())),
    ])

    mechanism, purview = (0, 1), (2, 3)
    assert set(all_partitions(mechanism, purview)) == set([
        KPartition(Part((0, 1), ()), Part((), (2, 3))),
        KPartition(Part((0, ), ()), Part((1, ), (2, 3)), Part((), ())),
        KPartition(Part((0, ), (2, 3)), Part((1, ), ()), Part((), ())),
        KPartition(Part((0, ), ()), Part((1, ), ()), Part((), (2, 3))),
        KPartition(Part((0, ), ()), Part((1, ), (3, )), Part((), (2, ))),
        KPartition(Part((0, ), (2, )), Part((1, ), ()), Part((), (3, ))),
        KPartition(Part((0, ), ()), Part((1, ), (2, )), Part((), (3, ))),
        KPartition(Part((0, ), (3, )), Part((1, ), (2, )), Part((), ())),
        KPartition(Part((0, ), (3, )), Part((1, ), ()), Part((), (2, ))),
        KPartition(Part((0, ), (2, )), Part((1, ), (3, )), Part((), ())),
    ])
Exemplo n.º 5
0
def kcut_effect():
    partition = KPartition(Part((0, 2), (0, )), Part((), (2, )),
                           Part((3, ), (3, )))
    return KCut(Direction.EFFECT, partition)
Exemplo n.º 6
0
def kcut_cause():
    partition = KPartition(Part((0, 2), (0, )), Part((), (2, )),
                           Part((3, ), (3, )))
    return KCut(Direction.CAUSE, partition)
Exemplo n.º 7
0
def ac_cut(direction, *parts):
    return models.ActualCut(direction, KPartition(*parts))