
import pickle
import unittest

from hypothesis import given
import hypothesis.strategies as st

from . import strategies

class TestHomologyClass(unittest.TestCase):
    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))
    
    @given(strategies.homology_classes())
    def test_pickle(self, hc):
        self.assertEqual(hc, pickle.loads(pickle.dumps(hc)))
    
    @given(st.data())
    def test_hash(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertImplies(hc1 == hc2, hash(hc1) == hash(hc2))
    
    @given(st.data())
    def test_canonical(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertEqual(hc1.canonical() + hc2.canonical(), (hc1 + hc2).canonical())
        self.assertEqual(hc1.canonical() - hc2.canonical(), (hc1 - hc2).canonical())
        self.assertEqual(-(hc1.canonical()), (-hc1).canonical())
    
    @given(st.data())
    def test_image(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        h = data.draw(strategies.mappings(hc1.triangulation))
        self.assertEqual(h(hc1 + hc2), h(hc1) + h(hc2))
    
    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T), min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))
    
    @given(st.data())
    def test_orientation(self, data):
        hc = data.draw(strategies.homology_classes())
        edge = data.draw(st.sampled_from(hc.triangulation.edges))
        self.assertEqual(hc(edge), -hc(~edge))


f9526c1c2c34439f532eeebcdf151367265caa9e
<mask token>


class TestHomologyClass(unittest.TestCase):

    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T),
            min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))
    <mask token>

<mask token>


class TestHomologyClass(unittest.TestCase):

    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))

    @given(strategies.homology_classes())
    def test_pickle(self, hc):
        self.assertEqual(hc, pickle.loads(pickle.dumps(hc)))
    <mask token>
    <mask token>
    <mask token>

    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T),
            min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))
    <mask token>

<mask token>


class TestHomologyClass(unittest.TestCase):

    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))

    @given(strategies.homology_classes())
    def test_pickle(self, hc):
        self.assertEqual(hc, pickle.loads(pickle.dumps(hc)))
    <mask token>
    <mask token>

    @given(st.data())
    def test_image(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        h = data.draw(strategies.mappings(hc1.triangulation))
        self.assertEqual(h(hc1 + hc2), h(hc1) + h(hc2))

    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T),
            min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))
    <mask token>

<mask token>


class TestHomologyClass(unittest.TestCase):

    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))

    @given(strategies.homology_classes())
    def test_pickle(self, hc):
        self.assertEqual(hc, pickle.loads(pickle.dumps(hc)))

    @given(st.data())
    def test_hash(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertImplies(hc1 == hc2, hash(hc1) == hash(hc2))

    @given(st.data())
    def test_canonical(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertEqual(hc1.canonical() + hc2.canonical(), (hc1 + hc2).
            canonical())
        self.assertEqual(hc1.canonical() - hc2.canonical(), (hc1 - hc2).
            canonical())
        self.assertEqual(-hc1.canonical(), (-hc1).canonical())

    @given(st.data())
    def test_image(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        h = data.draw(strategies.mappings(hc1.triangulation))
        self.assertEqual(h(hc1 + hc2), h(hc1) + h(hc2))

    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T),
            min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))

    @given(st.data())
    def test_orientation(self, data):
        hc = data.draw(strategies.homology_classes())
        edge = data.draw(st.sampled_from(hc.triangulation.edges))
        self.assertEqual(hc(edge), -hc(~edge))


import pickle
import unittest

from hypothesis import given
import hypothesis.strategies as st

from . import strategies

class TestHomologyClass(unittest.TestCase):
    def assertImplies(self, A, B):
        self.assertTrue(not A or B, msg='AssertionError: %s =/=> %s' % (A, B))
    
    @given(strategies.homology_classes())
    def test_pickle(self, hc):
        self.assertEqual(hc, pickle.loads(pickle.dumps(hc)))
    
    @given(st.data())
    def test_hash(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertImplies(hc1 == hc2, hash(hc1) == hash(hc2))
    
    @given(st.data())
    def test_canonical(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        self.assertEqual(hc1.canonical() + hc2.canonical(), (hc1 + hc2).canonical())
        self.assertEqual(hc1.canonical() - hc2.canonical(), (hc1 - hc2).canonical())
        self.assertEqual(-(hc1.canonical()), (-hc1).canonical())
    
    @given(st.data())
    def test_image(self, data):
        hc1 = data.draw(strategies.homology_classes())
        hc2 = data.draw(strategies.homology_classes(hc1.triangulation))
        h = data.draw(strategies.mappings(hc1.triangulation))
        self.assertEqual(h(hc1 + hc2), h(hc1) + h(hc2))
    
    @given(st.data())
    def test_abelian(self, data):
        T = data.draw(strategies.triangulations())
        hcs = data.draw(st.lists(elements=strategies.homology_classes(T), min_size=1))
        self.assertEqual(sum(hcs), sum(data.draw(st.permutations(hcs))))
    
    @given(st.data())
    def test_orientation(self, data):
        hc = data.draw(strategies.homology_classes())
        edge = data.draw(st.sampled_from(hc.triangulation.edges))
        self.assertEqual(hc(edge), -hc(~edge))

