Re: [sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Nathann Cohen
> * delete 'RingElement.abs'. Then any subclass that wants absolute > values needs to implement __abs__ (that's necessary anyway) and, if it > wants the method accessible in another form as well, also a suitable > 'abs'. I could see why that's not so desirable +1 ! Nathann -- You received this

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Nils Bruin
On Jan 5, 1:27 am, Volker Braun wrote: > Also, x.__abs__() is just the Python magic method for abs(x). The function > call syntax abs(x) will always call __abs__ and return an AttributeError if > it is not defined. So all we have is an x.abs() method that behaves exactly > like abs(x), for better

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Dima Pasechnik
On 2013-01-05, Simon King wrote: > Hi Dima, > > On 2013-01-05, Dima Pasechnik wrote: >> On 2013-01-05, Simon King wrote: >>> sage: a.abs # but that's good: >>> NotImplemented >> >> this is still a hack, as R() might in principle not have anything to do >> with abs(). In such a case NotIm

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Simon King
Hi Dima, On 2013-01-05, Dima Pasechnik wrote: > On 2013-01-05, Simon King wrote: >> sage: a.abs # but that's good: >> NotImplemented > > this is still a hack, as R() might in principle not have anything to do > with abs(). In such a case NotImplemented is misleading, and it better > be t

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Dima Pasechnik
On 2013-01-05, Simon King wrote: > Hi John, > > On 2013-01-05, john_perry_usm wrote: >> thinking of how java interfaces & multiple inheritance work: >> wouldn't it be possible to have an interface orabstract class >> that defines an abstract function abs, along with associated >> functions that r

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Simon King
Hi John, On 2013-01-05, john_perry_usm wrote: > thinking of how java interfaces & multiple inheritance work: > wouldn't it be possible to have an interface orabstract class > that defines an abstract function abs, along with associated > functions that require an abs functions, then declare in th

Re: [sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Volker Braun
On Saturday, January 5, 2013 8:45:47 AM UTC, Nathann Cohen wrote: > What the hell ? You are *NOT* supposed to implement an abs() method, > because such a method does not necessarily make sense ! > There is certainly an argument to be made that abs() should or should not be defined by default. B

Re: [sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Nathann Cohen
> Naming consistency. It makes it clear that you are supposed to implement > absolute value through __abs__() and not norm() or absolute_value() etc. O_O What the hell ? You are *NOT* supposed to implement an abs() method, because such a method does not necessarily make sense ! And by the way, r

[sage-devel] Re: Attribute errors with polynomials

2013-01-05 Thread Volker Braun
On Saturday, January 5, 2013 4:50:35 AM UTC, Nils Bruin wrote: > Perhaps more importantly: What is to be gained with the added > indirection of abs Naming consistency. It makes it clear that you are supposed to implement absolute value through __abs__() and not norm() or absolute_value() etc.

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread Nils Bruin
On Jan 4, 8:17 pm, Dima Pasechnik wrote: > > The abs() method is defined in sage.structure.element.RingElement. If > > but why? not all rings have any meaningful abs().. > > > that method makes sense for your specific class of ring elements, > > implement a method __abs__. Perhaps more importantl

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread Dima Pasechnik
On 2013-01-04, Simon King wrote: > Hi Nathann, > > On 2013-01-04, Nathann Cohen wrote: >> --e89a8f6467594d8d3f04d276c2d8 >> Content-Type: text/plain; charset=ISO-8859-1 >> sage: p >> x^3 - 3*x >> sage: p.abs() >> ... >> AttributeError: >> 'sage.rings.polynomial.polynomial_integer_dense_flint.Poly

Re: [sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread john_perry_usm
tab-completion has been fun for me from time to time, as John Cremona points out. thinking of how java interfaces & multiple inheritance work: wouldn't it be possible to have an interface orabstract class that defines an abstract function abs, along with associated functions that require an abs

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread mmarco
I don't know if this could be doable, but here is a proposal: to modify the tab completion code so that methods that consist only in raising a NotImplemented error are not shown. This way we could keep the structure there for developpers to follow the name conventions, and we wouldn't confuse user

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread Nathann Cohen
Helloo !!! Well, it provides a general interface for typical tasks (in order to avoid > that the same functionality is provided by methods of different names in > different classes). I think it's useful, even though it means that some > methods > exist in a context in which they ma

Re: [sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread John Cremona
I agree with Nathan. There may well be many rings for which it makes sense to have an abs() function, but as that is not true for all rings I cannot see the sense in having a dummy abs() function that high up the hierarchy.Similarly with N. Another one is version() which I just noticed exists

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread Simon King
Hi Nathann, On 2013-01-04, Nathann Cohen wrote: > --e89a8f6467594d8d3f04d276c2d8 > Content-Type: text/plain; charset=ISO-8859-1 > sage: p > x^3 - 3*x > sage: p.abs() > ... > AttributeError: > 'sage.rings.polynomial.polynomial_integer_dense_flint.Polynomial_integer_dense_flint' > object has no att

[sage-devel] Re: Attribute errors with polynomials

2013-01-04 Thread Javier López Peña
Hi Nathan, What do you mean by calling absolute value or norm of a polynomial? Why should these methods even be defined? Cheers, J On Friday, January 4, 2013 1:50:14 PM UTC, Nathann Cohen wrote: > > Hell everybody !!! > > Of course I do not know if what I do has any meaning, but I sti