#14789: Implement hyperplane arrangements
---------------------------------+------------------------------
Reporter: kcrisman | Owner: sage-combinat
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.11
Component: combinatorics | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Dependencies:
Stopgaps: |
---------------------------------+------------------------------
Comment (by vbraun):
Very nice! I like the functionality but have a couple of suggestions to
integrate it with the rest of Sage.
There is a lot of needless copy/deepcopy-ing. Most objects in Sage are
immutable and don't need to be copied ever, you can just use/return the
existing object. E.g. polyhedra are immutable. You should figure out
whether you want your objects to be immutable, too. I suggest you make
everything immutable, it is generally a big source of errors to make
caching work with mutable stuff.
Caching can be done with the `@cached_method` decorator, this is much
easier to understand/maintain than a `__getattr__` hack.
Please no version number for individual files, Sage already has a version
number.
Instead of `__repr__`, you should implement `_repr_`, see
http://www.sagemath.org/doc/developer/coding_in_python.html#special-sage-
functions
I think its confusing to have a `Hyperplane` in the global namespace that
is not a `Polyhedron`. How about you replace it essentially with the
arrangement consisting of a single-hyperplane. So instead of a special
`add_hyperplane`, just use union:
{{{
A = HyperplaneArrangement([[1,0,0],[0,1,1],[0,1,-1],[1,-1,0],[1,1,0]])
B = A.union(HyperplaneArrangement([[1,1,1]])
B = A.union([[1,1,1]]) # syntactic sugar for adding list of
hyperplanes
B = A.union([1,1,1]) # syntactic sugar for adding single
hyperplane
B = A & [1,1,1] # operator notation
}}}
and pick an operator to overload (probably either plus or ampersand) as an
alias for union.
The !HyperplaneArrangement should be a Parent and individual hyperplanes
its elements. Roughly:
{{{
class Hyperplane(AffineSubspace, Element):
def __init__(self, parent, ...):
Element.__init__(self, parent=parent)
class HyperplaneArrangement(Parent):
Element = Hyperplane
def __init__(self, ...):
Parent.__init__(self, base=base_ring, category=Sets())
}}}
and always use `hyperplane_arrangement.element_class()` instead of the
plain `Hyperplane` class. This automatically gives you a `base_ring()`
method (Sage generally uses `base_ring` instead of `base_field` even if it
is only implemented for fields).
--
Ticket URL: <http://trac.sagemath.org/ticket/14789#comment:13>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/groups/opt_out.