#18529: Topological manifolds: basics
-------------------------------------+-------------------------------------
Reporter: egourgoulhon | Owner: egourgoulhon
Type: enhancement | Status: needs_info
Priority: major | Milestone: sage-6.10
Component: geometry | Resolution:
Keywords: topological | Merged in:
manifolds | Reviewers: Travis Scrimshaw
Authors: Eric Gourgoulhon, | Work issues:
Travis Scrimshaw | Commit:
Report Upstream: N/A | 0fb39df7fafe7f0a765bf73b3f34a6cb41e65c40
Branch: | Stopgaps:
u/tscrim/top_manifolds_refactor |
Dependencies: #18175 |
-------------------------------------+-------------------------------------
Comment (by tscrim):
I did some exploring in the coercion code and some testing using this:
{{{#!python
from sage.structure.parent import Parent
from sage.structure.element_wrapper import ElementWrapper
from sage.misc.fast_methods import WithEqualityById
from sage.categories.additive_groups import AdditiveGroups
class Foo(Parent, WithEqualityById):
def __init__(self):
Parent.__init__(self, category=AdditiveGroups())
def __reduce__(self):
return (Foo, ())
def _coerce_map_from_(self, R):
return isinstance(R, Foo)
def _element_constructor_(self, x):
if isinstance(x, ElementWrapper) and isinstance(x.parent(), Foo):
return self(x.value)
return super(Foo, self)._element_constructor_(x)
class Element(ElementWrapper):
def _add_(self, other):
return self.parent()(self.value+other.value)
}}}
which I think is a minimal example of the behavior you want. Pickling and
coercion seem to work fine:
{{{
sage: F = Foo()
sage: F2 = loads(dumps(F))
sage: F(1) + F2(1)
2
sage: F == F2
False
}}}
Furthermore, from looking at your code, the reason why it now breaks is
you're assuming unique representation by not passing the scalar field
algebra as the first argument of the scalar field. So it's getting
mismatches because the `domain.scalar_field_algebra()` may not be the
scalar field algebra that was suppose to be creating that particular
scalar field. So for the scalar fields, I would instead have the first
argument be the corresponding algebra and get the domain from that (with
appropriate handling of parameters for the methods which create the scalar
fields). You might also consider caching the scalar field algebra that
gets created for a particular manifold to have unique representation
behavior.
--
Ticket URL: <http://trac.sagemath.org/ticket/18529#comment:80>
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/d/optout.