Re: [sage-devel] Heavy-computation @property in Matrix class

2016-04-29 Thread Nicolas M. Thiery
On Tue, Apr 26, 2016 at 10:53:37AM +0200, Johan S. R. Nielsen wrote:
> I came across this because it currently breaks tab-completion on
> matrices in the Emacs sage-mode: perhaps due to a bug, IPython inspects
> the properties when tab-completing, so when a property throws an
> exception, no tab-completion is given. That means that invertible
> matrices don't tab-complete in sage-mode. The terminal is OK, and I
> don't know about other interfaces.

Just for the record, this also breaks introspection in the
IPython terminal and notebooks:

sage: sage: m = matrix([[1,1],[2,2]])
sage: sage: m.*rank*?
...
ZeroDivisionError

which has been annoying me for a while. Thanks for bringing this up!

Cheers,
Nicolas
--
Nicolas M. ThiƩry "Isil" 
http://Nicolas.Thiery.name/

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Heavy-computation @property in Matrix class

2016-04-26 Thread Johan S . R . Nielsen
Hi

I came across the following in sage/matrix/matrix2.pyx:14367:

@property
def I(self):
r"""
Returns the inverse of the matrix, if it exists.

"""
return ~self

Basically, I don't understand why this def should be a property, and it
seems to me to be problematic. Specifically:

1) This is a property that can throw an exception. Isn't that a problem?

2) This is a property that runs a heavy computation when called. Isn't
that a problem?

I came across this because it currently breaks tab-completion on
matrices in the Emacs sage-mode: perhaps due to a bug, IPython inspects
the properties when tab-completing, so when a property throws an
exception, no tab-completion is given. That means that invertible
matrices don't tab-complete in sage-mode. The terminal is OK, and I
don't know about other interfaces.

There are other @property defs in that class, like conjugate and
hermitian.

Best,
Johan

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.