Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-09 Thread Eric Gourgoulhon
Thank you all for the discussion and recommendations ! (it's nice to develop within such a responsive community) I've updated the ticket #18529 accordingly, removing UniqueRepresentation for manifolds and charts and letting them inherit directly from Wit

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-08 Thread Eric Gourgoulhon
Hi, Le dimanche 8 novembre 2015 07:32:48 UTC+1, David Roe a écrit : > > > > I think Nils' point about the downsides of having a cache is one reason > not to use UniqueRepresentation, both because it can generate references to > objects you might want to forget, and because sometimes you just wan

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-07 Thread David Roe
On Sat, Nov 7, 2015 at 6:28 PM, Travis Scrimshaw wrote: > Hey Simon, > > >> >I would then be advocating for using UniqueRepresentation if that >> was >> >> > the only issue. >> >> >> >> It really depends whether in comparing manifolds you would prefer to >> do >> >> *some* >> >> heuristics to

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-07 Thread Travis Scrimshaw
Hey Simon, >> >I would then be advocating for using UniqueRepresentation if that > was > >> > the only issue. > >> > >> It really depends whether in comparing manifolds you would prefer to do > >> *some* > >> heuristics to detect homeomorphic manifolds, or prefer to consider > >> manifo

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-07 Thread Simon King
Hi Travis, On 2015-11-06, Travis Scrimshaw wrote: >> On 2015-11-05, Travis Scrimshaw > wrote: >> >I would then be advocating for using UniqueRepresentation if that was >> > the only issue. >> >> It really depends whether in comparing manifolds you would prefer to do >> *some* >> heuristi

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread Eric Gourgoulhon
Le vendredi 6 novembre 2015 17:32:49 UTC+1, Nils Bruin a écrit : > > > Furthermore, if X and Y happen to be non-identical but "equal" charts, > would you want points._coordinates[X] be identical to points_coordinates[Y] > ? Would that ever be useful? > Not much: in the current setting, we shoul

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread Nils Bruin
On Friday, November 6, 2015 at 2:58:24 AM UTC-8, Eric Gourgoulhon wrote: > > > However, your example with NAN in the reply to Simon shows that dictionary > lookup shortcuts equality testing on identical keys. If I understand > correctly, this means that even if we had a slow __eq__ for charts, a

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread Travis Scrimshaw
Hey Simon, > > On 2015-11-05, Travis Scrimshaw > wrote: > >I would then be advocating for using UniqueRepresentation if that was > > the only issue. > > It really depends whether in comparing manifolds you would prefer to do > *some* > heuristics to detect homeomorphic manifolds, or prefe

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread Simon King
Hi Travis, On 2015-11-05, Travis Scrimshaw wrote: >I would then be advocating for using UniqueRepresentation if that was > the only issue. It really depends whether in comparing manifolds you would prefer to do *some* heuristics to detect homeomorphic manifolds, or prefer to consider manifo

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread mmarco
But the random number generator suffers from the same issues: how random it really is deppends on the platform. I would suggest joining both ideas: random number plus time stamp. El jueves, 5 de noviembre de 2015, 17:08:11 (UTC+1), Jeroen Demeyer escribió: > > On 2015-11-05 16:27, Travis Scrims

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-06 Thread Eric Gourgoulhon
Hi, Le vendredi 6 novembre 2015 00:16:26 UTC+1, Nils Bruin a écrit : > > On Thursday, November 5, 2015 at 2:35:57 PM UTC-8, Eric Gourgoulhon wrote: >> >> Yes charts are immutable: a chart is defined by two parameters, which are >> passed to the constructor: its domain (a manifold) and its coordi

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Nils Bruin
On Thursday, November 5, 2015 at 2:30:08 AM UTC-8, Simon King wrote: > Certainly, if "A is B" then "A==B" will be True. Actually I am not sure > if A.__eq__ would be invoked at all if you compare to identical objects > (i.e., I don't know what Python does). > This is famous in Python: sage:

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Nils Bruin
On Thursday, November 5, 2015 at 2:35:57 PM UTC-8, Eric Gourgoulhon wrote: > > Yes charts are immutable: a chart is defined by two parameters, which are > passed to the constructor: its domain (a manifold) and its coordinates (a > list of symbolic variables). These two parameters do not change du

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Eric Gourgoulhon
Thanks for your suggestions. Le jeudi 5 novembre 2015 18:54:40 UTC+1, Nils Bruin a écrit : > > On Thursday, November 5, 2015 at 7:22:10 AM UTC-8, Travis Scrimshaw wrote: >> >>So I'm somewhat inclined to use EqualityById and let the pickling be >> broken (and redefining _test_pickling to do no

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Nils Bruin
On Thursday, November 5, 2015 at 10:42:47 AM UTC-8, Eric Gourgoulhon wrote: > > > So we see that the objects used as keys are charts, vector frames and > manifolds. > I think that's a very strong reason to go with equality-by-id and *not* unique representation: You really don't want to risk tha

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Eric Gourgoulhon
For the benefit of the discussion, here is the list of dictionaries involved in the manifold tickets colllected at #18528 . Each dictionary is presented in the form - values | key: the key - chart restrictions | key: open subset (i.e. manifold) - transit

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Nils Bruin
On Thursday, November 5, 2015 at 7:22:10 AM UTC-8, Travis Scrimshaw wrote: > >So I'm somewhat inclined to use EqualityById and let the pickling be > broken (and redefining _test_pickling to do nothing (i.e., passes) with a > docstring warning that it is intentionally broken). I'm starting to

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Jeroen Demeyer
On 2015-11-05 16:27, Travis Scrimshaw wrote: I'm guessing a random large number is better because it won't stop working in 2038? Mostly, it's better because there is a much smaller chance of collisions: there is a hidden assumption that there will not be 2 manifolds created with the same time

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Travis Scrimshaw
On Thursday, November 5, 2015 at 5:08:15 AM UTC-6, Jeroen Demeyer wrote: > > On 2015-11-05 01:26, Travis Scrimshaw wrote: > > So we > > add an additional unique identifier to the cache key, the time from the > > epoch the object was created. > > That's an extremely ugly hack. If you absolutely

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Travis Scrimshaw
Hey Simon, > > What about a mixed approach: It seems that you have, on the one hand, > nice manifolds that you know by name (S^n, T^n, RR^n, L(p,q), ...). You > want that manifolds that you know by name are identical if and only if > they have the same name. But you also want to be able to buil

Re: [sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Jeroen Demeyer
On 2015-11-05 01:26, Travis Scrimshaw wrote: So we add an additional unique identifier to the cache key, the time from the epoch the object was created. That's an extremely ugly hack. If you absolutely must use a unique identifier, generate a sufficiently large random number. -- You received

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Simon King
Hi Eric, On 2015-11-05, Eric Gourgoulhon wrote: > Le jeudi 5 novembre 2015 10:32:29 UTC+1, Simon King a =C3=A9crit : > Yes this is precisely what we had in mind: to delegate the mathematical > comparison of manifolds to a specific method is_homeomorphic, which > in most case will answer "I cannot

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Eric Gourgoulhon
Le jeudi 5 novembre 2015 01:57:27 UTC+1, Nils Bruin a écrit : > > On Wednesday, November 4, 2015 at 2:10:51 PM UTC-8, Eric Gourgoulhon wrote: >> >> Hi sage-dev, >> >> There is an ongoing discussion at #18529 >> about defining __eq__ for >> manifolds and w

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Simon King
Hi Eric, On 2015-11-05, Eric Gourgoulhon wrote: > This is precisely why in the current setting the string representing the > manifold's name is part of the manifold's identity, thanks to the=20 > UniqueRepresentation mechanism. No, this is thanks to the CachedRepresentation mechanism only! Uniqu

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Eric Gourgoulhon
Le jeudi 5 novembre 2015 10:32:29 UTC+1, Simon King a écrit : > > > - Or IF you really want to use them as dictionary keys, then just let > manifolds compare by identity (so, you allow that two homeomorphic > manifolds evaluate as non-equal), and have a separate method > M.is_homeomor

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Eric Gourgoulhon
Hi Simon, Thanks for your feedback! Le jeudi 5 novembre 2015 10:17:35 UTC+1, Simon King a écrit : > > Hi Eric, > > > Are you serious? Certainly you are aware that there is no algorithm that > would be able to test whether two arbitrary compact 4-manifolds are > homeomorphic. And if I am not m

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Simon King
Hi Nils, On 2015-11-05, Nils Bruin wrote: > In general, I don't think there is a real problem if > > A = manifold( B = manifold( > has (A is B) equal to False. I would think it's not really a problem if it > has A == B equal to False. +1 > Indeed, this would mean that manifolds stored in separ

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Simon King
Hi Travis, On 2015-11-05, Travis Scrimshaw wrote: > - We need the manifold to be defined in order for check the charts (as it > is the domain of said map). > - We can't just use EqualityById without UniqueRepresentation because this > breaks pickling. > - We can only define manifolds by (latex)

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-05 Thread Simon King
Hi Eric, On 2015-11-04, Eric Gourgoulhon wrote: > The context is as follows: > > - Manifolds are parents, whose elements are points. > - Manifolds are characterized by a user-defined atlas, which is a list of > coordinate charts defined on the > fly by the user, along with transition maps. "De

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-04 Thread Nils Bruin
On Wednesday, November 4, 2015 at 2:10:51 PM UTC-8, Eric Gourgoulhon wrote: > > Hi sage-dev, > > There is an ongoing discussion at #18529 > about defining __eq__ for > manifolds and whether one should > use UniqueRepresentation (which implements equality by

[sage-devel] Re: Manifold equality and UniqueRepresentation

2015-11-04 Thread Travis Scrimshaw
I should note for those not wanting to read through the discussion in full that we arrived at the current design dealing with the following issues: - We need the manifold to be defined in order for check the charts (as it is the domain of said map). - We can't just use EqualityById without Uniqu