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

Bug in the associahedron object #25183

Closed
jplab opened this issue Apr 16, 2018 · 24 comments
Closed

Bug in the associahedron object #25183

jplab opened this issue Apr 16, 2018 · 24 comments

Comments

@jplab
Copy link

jplab commented Apr 16, 2018

The following lines currently occur:

sage: A = polytopes.associahedron(['A',3])
sage: face = A.faces(2)[3]
sage: face
<6,8,9,10>
sage: face.as_polyhedron()
/home/jplabbe/sage/local/lib/python2.7/site-packages/sage/repl/rich_output/display_manager.py:590: RichReprWarning: Exception in _rich_repr_ while displaying object: 'Associahedra_with_category.element_class' object has no attribute '_cartan_type'
  RichReprWarning,
<repr(<sage.combinat.root_system.associahedron.Associahedra_with_category.element_class at 0x7f48d0d7ad70>) failed: AttributeError: 'Associahedra_with_category.element_class' object has no attribute '_cartan_type'>

The construction as_polyhedron initializes the new (face-)polyhedron via P.__class__(parent, Vrep, None). In the case of the associahedron, this does not give a valid object, as the associahedron requires a cartan type as well.

Same (or similar problem) with:

  • minkowski_sum,
  • minkowski_difference,
  • translation,
  • dilation,
  • convex_hull,
  • intersection (actually even worse as coercion fails),
  • polar.

We fix the initialization of the associahedron to now require the cartan type on __init__ (before it was assumed to be set after initialization).

Further we have __new__ return the correct parent class such that e.g. the face of an Associahedron_class_ppl is constructed as Polyhedron_ppl.

We fix _coerce_map_from_ to take into account that no general polyhedron can be coerced to an associahedron.

We manually set the correct pushout of polyhedra over ZZ and associahedra (over QQ) to be polyhedra over QQ.

Depends on #27798

CC: @fchapoton @stumpc5 @tscrim @mo271 @jplab @LaisRast

Component: geometry

Keywords: associahedron

Author: Jonathan Kliem

Branch/Commit: d9083b7

Reviewer: Jean-Philippe Labbé, Travis Scrimshaw

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

@jplab jplab added this to the sage-8.2 milestone Apr 16, 2018
@kliem
Copy link
Contributor

kliem commented May 10, 2019

comment:2

I think I took care of it in #27798.

@kliem

This comment has been minimized.

@kliem
Copy link
Contributor

kliem commented May 16, 2019

Author: Jonathan Kliem

@kliem
Copy link
Contributor

kliem commented May 16, 2019

comment:3

This branch should fix the bug.

Feel free to change it, alter it, abonden it, etc.

Maybe there is a better way to obtain the correct parent, i.e. improve the following lines:

156             for typ1 in ancestors_of_associahedron:
157                 if typ1 in mro:
158                     return typ1(parent, Vrep, Hrep, **kwds)

New commits:

2643078added `backend` to associahedron and flow polytope
a9b4826typo
8716985corrected docstring
b873156associahedron actually uses the claimed backend now
1f4bb25comments by tscrim
2c812c5should have fixed bug in #25183
65b11c9removed redundant line

@kliem
Copy link
Contributor

kliem commented May 16, 2019

Commit: 65b11c9

@kliem
Copy link
Contributor

kliem commented May 16, 2019

Branch: public/25183

@kliem
Copy link
Contributor

kliem commented May 16, 2019

Dependencies: 27798

@kliem
Copy link
Contributor

kliem commented May 16, 2019

Changed dependencies from 27798 to #27798

@kliem kliem modified the milestones: sage-8.2, sage-8.9 Jul 1, 2019
@kliem
Copy link
Contributor

kliem commented Aug 27, 2019

comment:6

Once #27798 is done, I'm going to rebase it and solve the merge conflict. At the moment it seems pointless to me.

@kliem

This comment has been minimized.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2019

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

949b0a9added `backend` to associahedron and flow polytope
e137199changed default value of `backend`; small changes in documentation
0e892e7modify construction and coercion of associahedra to fix bug #25183

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2019

Changed commit from 65b11c9 to 0e892e7

@kliem

This comment has been minimized.

@kliem
Copy link
Contributor

kliem commented Aug 29, 2019

comment:10

I think I got things fixed now. Suggestions for better solutions are welcome.

@jplab
Copy link
Author

jplab commented Nov 12, 2019

comment:12

That looks good to me. Might be good to have some feedback from Travis or Frédéric on the cartan side of things, if they are done properly.

I would put this to positive review since the error appears to be fixed.

@jplab
Copy link
Author

jplab commented Nov 12, 2019

Reviewer: Jean-Philippe Labbé

@tscrim
Copy link
Collaborator

tscrim commented Nov 14, 2019

comment:13

I don't have any comments on the Cartan side as you are not really doing anything with them. However, I do have one comment about this code block:

            for typ1 in ancestors_of_associahedron:
                if typ1 in mro:
                    return typ1(parent, Vrep, Hrep, **kwds)

My understanding is there is no subclass relations among the classes in ancestors_of_associahedron. So I think it is faster to make that a set object and test

            for typ1 in mro:
                if typ1 in ancestors_of_associahedron:
                    return typ1(parent, Vrep, Hrep, **kwds)

as set containment check is much faster and these classes are likely to be higher in the MRO. It also has a side effect of making all of these classes run in the same time. For example, imagine if you are looking for a Polyhedron_polymake, that means it has to check the through the entire MRO 4 times (and a bit more to actually find it). So this could become really expensive if you create lots of (temporary) associahedra.

@kliem
Copy link
Contributor

kliem commented Nov 14, 2019

New commits:

cc20d20modify construction and coercion of associahedra to fix bug #25183
d9083b7small change of order of iteration to be more efficient

@kliem
Copy link
Contributor

kliem commented Nov 14, 2019

Changed commit from 0e892e7 to d9083b7

@kliem
Copy link
Contributor

kliem commented Nov 14, 2019

Changed branch from public/25183 to public/25183-reb

@kliem
Copy link
Contributor

kliem commented Nov 14, 2019

comment:15

Changed to order of iteration, such that it only runs once through mro now.

@tscrim
Copy link
Collaborator

tscrim commented Nov 14, 2019

Changed reviewer from Jean-Philippe Labbé to Jean-Philippe Labbé, Travis Scrimshaw

@tscrim
Copy link
Collaborator

tscrim commented Nov 14, 2019

comment:16

Thanks. LGTM.

@vbraun
Copy link
Member

vbraun commented Nov 16, 2019

Changed branch from public/25183-reb to d9083b7

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

4 participants