Printing deprecated functions in gray ?

58 views
Skip to first unread message

Nathann Cohen

unread,
Sep 24, 2014, 10:54:16 AM9/24/14
to Sage devel, vdel...@labri.fr
Hello everybody !

Here I was deprecating stuff, and I wondered: could we make it explicit in the tab-completion that some functions are deprecated ?

In particular, I have to (I am not proud) replace a (now deprecated) designs.orthogonal_array with a (note the terminal 's') designs.orthogonal_arrays.

Wouldn't it be cool if typing "designs.<tab>" would display the first deprecated function in light gray, so as to mean "it's disappearing" ?

I was wondering how to prevent users from reading the (long) documentation of this function before noticing that it is deprecated when they call it, only to see how the new one works.

Clearly not critical :-P

Nathann

William A Stein

unread,
Sep 24, 2014, 11:02:27 AM9/24/14
to sage-...@googlegroups.com, vdel...@labri.fr
Maybe you could write at the TOP of the docstring:

DEPRECATED

Or even make the deprecation decorator prepend that to the docstring
automatically?

>
> Clearly not critical :-P



>
> Nathann
>
> --
> 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+...@googlegroups.com.
> To post to this group, send email to sage-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.



--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org
wst...@uw.edu

Volker Braun

unread,
Sep 24, 2014, 11:10:22 AM9/24/14
to sage-...@googlegroups.com, vdel...@labri.fr
IMHO it would be best to not have deprecated methods in the tab completion to start with.

However, its not trivial to find out that something is deprecated. Of course you can easily check for the decorator, but a method could also end up throwing a deprecation warning because it calls a deprecated method. Or call the deprecation warning in the method body.

Travis Scrimshaw

unread,
Sep 24, 2014, 5:44:10 PM9/24/14
to sage-...@googlegroups.com, vdel...@labri.fr
On Wednesday, September 24, 2014 10:10:22 AM UTC-5, Volker Braun wrote:
IMHO it would be best to not have deprecated methods in the tab completion to start with.

I strongly disagree with this as it defeats half the purpose of deprecation. If suddenly a function/method I was working with (and had a long name that I never remembered or was not lazy enough to type out) suddenly doesn't appear under tab completion. I would think the function is no longer in Sage and would have no idea what it was replaced by.

However, its not trivial to find out that something is deprecated. Of course you can easily check for the decorator, but a method could also end up throwing a deprecation warning because it calls a deprecated method. Or call the deprecation warning in the method body.

+1 for having a decorator for deprecation (and for it automatically updating the docstring), rather than having to explicitly call the deprecation explicitly (I believe the only thing we have currently is the @rename_keyword). If a method calls a deprecated function, then something isn't being doctested (properly).

+1 for changing the output for deprecated functions/methods/classes on tab completion, but -1 on removing them altogether.

Best,
Travis

 

Nathann Cohen

unread,
Sep 25, 2014, 5:43:57 AM9/25/14
to sage-...@googlegroups.com, vdel...@labri.fr
Maybe you could write at the TOP of the docstring:

   DEPRECATED

Or even make the deprecation decorator prepend that to the docstring
automatically?

Having a brain is underrated. Good idea. Thanks.

Nathann 

Nathann Cohen

unread,
Sep 25, 2014, 5:45:50 AM9/25/14
to sage-...@googlegroups.com, vdel...@labri.fr
Hello !

+1 for having a decorator for deprecation (and for it automatically updating the docstring), rather than having to explicitly call the deprecation explicitly (I believe the only thing we have currently is the @rename_keyword). If a method calls a deprecated function, then something isn't being doctested (properly).

+1 for changing the output for deprecated functions/methods/classes on tab completion, but -1 on removing them altogether.

I will try to modify the deprecation decorators to update the doc, but I have no idea how to change anything related to tab completion. Especially if colors are involved.

Nathann 

Nathann Cohen

unread,
Sep 25, 2014, 5:53:59 AM9/25/14
to Sage devel
Update: the feature already exists for deprecated_function_alias, eg:

designs.BalancedIncompleteBlockDesign?

But it is not the case for deprecated_callable_import, which is the one I use. So I will update that one.

Nathann

--
You received this message because you are subscribed to a topic in the Google Groups "sage-devel" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-devel/tD8tHOp3q1I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-devel+...@googlegroups.com.

Nathann Cohen

unread,
Sep 25, 2014, 6:04:55 AM9/25/14
to Sage devel
> But it is not the case for deprecated_callable_import, which is the one I use. So I will update that one.

Done at http://trac.sagemath.org/ticket/17038

Nathann

Volker Braun

unread,
Sep 25, 2014, 7:35:11 AM9/25/14
to sage-...@googlegroups.com, vdel...@labri.fr
On Wednesday, September 24, 2014 10:44:10 PM UTC+1, Travis Scrimshaw wrote:
On Wednesday, September 24, 2014 10:10:22 AM UTC-5, Volker Braun wrote:
IMHO it would be best to not have deprecated methods in the tab completion to start with.

I strongly disagree with this as it defeats half the purpose of deprecation. If suddenly a function/method I was working with (and had a long name that I never remembered or was not lazy enough to type out) suddenly doesn't appear under tab completion. I would think the function is no longer in Sage and would have no idea what it was replaced by.

Presumably the old method is being replaced by one that is better named. So if you can't recall the old name then it should be easier to find the new one than finding the old one and then following the deprecation link. Of course that assumes that the deprecation was actually an improvement ;-)


Nathann Cohen

unread,
Sep 25, 2014, 7:37:33 AM9/25/14
to Sage devel
> Presumably the old method is being replaced by one that is better named. So
> if you can't recall the old name then it should be easier to find the new
> one than finding the old one and then following the deprecation link. Of
> course that assumes that the deprecation was actually an improvement ;-)

Not necessarily. WittDesign was replaced by designs.WittDesign. If you
are not used to those "tab" things you will not find it immediately.

Nathann

Volker Braun

unread,
Sep 25, 2014, 8:03:40 AM9/25/14
to sage-...@googlegroups.com
Then maybe Witt<tab> should just include designs.WittDesign in the tab completion. 
Reply all
Reply to author
Forward
0 new messages