Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolyhedronFace: Fix pickling test #32025

Closed
mkoeppe opened this issue Jun 21, 2021 · 17 comments
Closed

PolyhedronFace: Fix pickling test #32025

mkoeppe opened this issue Jun 21, 2021 · 17 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented Jun 21, 2021

needed for #32013

We fix rich comparison of faces and pickled faces, so that as expected we have:

sage: P = polytopes.cube()
sage: f = P.faces(1)[2]
sage: f == loads(f.dumps())
True

Along the way we remove _test_pickling skips that are no longer necessary (because ppl polyhedra can be pickled).

Depends on #31959

CC: @kliem @tscrim

Component: geometry

Author: Jonathan Kliem

Branch/Commit: 2b9316b

Reviewer: Matthias Koeppe

Issue created by migration from https://trac.sagemath.org/ticket/32025

@mkoeppe mkoeppe added this to the sage-9.4 milestone Jun 21, 2021
@kliem
Copy link
Contributor

kliem commented Jun 21, 2021

comment:1

Can you please provide an example on where it fails? If you are going to fix it yourself then I guess you'll provide an example along with the fix.

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2021

comment:2

The TestSuite fails -- currently all calls to TestSuite use skip='_test_pickling'.

I'm working on something else right now - so help with this ticket would be welcome!

@kliem
Copy link
Contributor

kliem commented Jun 21, 2021

comment:3

Well, the only problem is that we currently require face._polyhedron to be identical for two faces to be tested equal. Otherwise, everything is working, isn't it?

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 21, 2021

comment:4

OK, perhaps it's too tricky to implement __richcmp__ for faces of polyhedra that are merely equal, not identical.

Although I suppose if the polyhedra are not the same, one could just delegate the comparison to as_polyhedron(...).

But I guess I can just skip the pickling test in #32013 to work around it.

@mkoeppe mkoeppe removed this from the sage-9.4 milestone Jun 21, 2021
@kliem
Copy link
Contributor

kliem commented Jun 22, 2021

comment:6

I didn't mean to imply that this does not need to be fixed. I just wanted to comment that the fixing needs to be done in richcmp and not pickling. Pickling works fine.

I guess instead of requiring the two polyhedra two be identical, we can just require the Vrepresentation and Hrepresentation to be the same:

    if self._polyhedron is not other._polyhedron:
-       raise NotImplementedError
+       if (self._polyhedron.Vrepresentation() != other._polyhedron.Vrepresentation() 
+               or self._polyhedron.Hrepresentation() != other._polyhedron.Hrepresentation()):
+           raise NotImplementedError

Actually we can be less strict and allow the Hrepresentation to differ. We could even allow the Vrepresentation to be a permutation of the other Vrepresentation, but this is definitely not needed to fix the pickling test for faces.

@kliem
Copy link
Contributor

kliem commented Jun 22, 2021

New commits:

981bb21allow rich comparison of pickled faces
52a6f40do not skip `test_pickling`, if it works

@kliem
Copy link
Contributor

kliem commented Jun 22, 2021

Author: Jonathan Kliem

@kliem
Copy link
Contributor

kliem commented Jun 22, 2021

Branch: public/32025

@kliem

This comment has been minimized.

@kliem
Copy link
Contributor

kliem commented Jun 22, 2021

Commit: 52a6f40

@kliem kliem changed the title PolyhedronFace: Fix pickling PolyhedronFace: Fix pickling test Jun 22, 2021
@kliem kliem added this to the sage-9.4 milestone Jun 22, 2021
@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2021

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

686d0afPolyhedron_base.product: Add doctest for alias 'cartesian_product'
2b1d108Merge #31919
7323b10ConvexSet_base._test_contains: Only test extension to AA for exact base rings
94e6858RelativeInterior.ambient, ambient_vector_space, is_universe: New
0c9bc94ConvexSet_base: Add default implementations of ambient, ambient_dim; add doctests
ce91e44src/sage/geometry/relative_interior.py: Fix doctest output
f0e7c58ambient_vector_space docstring: Fix bad blocks
200d967ConvexSet_base.ambient doctest: Actually test the method
f02ca28src/sage/geometry/polyhedron/face.py: Remove unused import
2b9316bMerge #31959

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jun 22, 2021

Changed commit from 52a6f40 to 2b9316b

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 22, 2021

comment:9

Merged to resolve merge conflict

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 22, 2021

Dependencies: #31959

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 23, 2021

Reviewer: Matthias Koeppe

@mkoeppe
Copy link
Contributor Author

mkoeppe commented Jun 23, 2021

comment:10

Thanks for working on this! LGTM

@vbraun
Copy link
Member

vbraun commented Jul 25, 2021

Changed branch from public/32025 to 2b9316b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants