def test_json_deserialization(s, transition): objects = [ Direction.CAUSE, s.network, # Network s, # Subsystem models.Bipartition(models.Part((0, ), ()), models.Part((1, ), (2, 3))), models.KPartition(models.Part((0, ), ()), models.Part((1, ), (2, 3))), models.Tripartition(models.Part((0, ), ()), models.Part((1, ), (2, 3)), models.Part((3, ), (4, ))), models.Cut((0, ), (2, )), models.NullCut((0, 1)), models.KCut( Direction.CAUSE, models.KPartition(models.Part((0, ), ()), models.Part((1, ), (2, 3)))), s.concept((1, 2)), s.concept((1, )), compute.ces(s), compute.sia(s), transition, transition.find_actual_cause((0, ), (0, )), actual.account(transition), actual.sia(transition) ] for o in objects: loaded = jsonify.loads(jsonify.dumps(o)) assert loaded == o
def test_cuts_can_have_node_labels(node_labels): models.NullCut((0, 1), node_labels=node_labels) models.Cut((0, ), (1, ), node_labels=node_labels) k_partition = models.KPartition(models.Part((0, 1), (0, )), models.Part((), (1, )), node_labels=node_labels) models.KCut(Direction.CAUSE, k_partition, node_labels=node_labels)
def test_null_cut_equality(): cut = models.NullCut((2, 3)) other = models.NullCut((2, 3)) assert cut == other assert hash(cut) == hash(other)
def test_null_cut_str(): cut = models.NullCut((2, 3)) assert str(cut) == "NullCut((2, 3))"
def test_null_cut(): cut = models.NullCut((2, 3)) assert cut.indices == (2, 3) assert cut.is_null assert np.array_equal(cut.cut_matrix(4), np.zeros((4, 4)))