holoviz / param

Param: Make your Python code clearer and more reliable by declaring Parameters
https://param.holoviz.org
BSD 3-Clause "New" or "Revised" License
422 stars 73 forks source link

IPython extension causes confusing help text? #115

Open ceball opened 9 years ago

ceball commented 9 years ago

If I'm using ipython and I run %load_ext param.ipython everything seems good. But if I'm not using ipython, or if I use ipython without loading the ipython extension, I think the help text for a parameterized instance is confusing.

Standard python:

>>> import param
>>> class X(param.Parameterized):
...     y = param.Parameter(default=1)
... 
>>> x = X(y=10)
>>> x.y
10
>>> help(x)

Gives me:

Help on X in module __main__ object:

class X(param.parameterized.Parameterized)
 |  params(y=Parameter, name=String)
 |  ESC[1;32mParameters of 'X'
 |  =================
 |  ESC[0m
 |  ESC[1;31mParameters changed from their default values are marked in red.ESC[0m
 |  ESC[1;36mSoft bound values are marked in cyan.ESC[0m
 |  C/V= Constant/Variable, RO/RW = ReadOnly/ReadWrite, AN=Allow None
 |  
 |  ESC[1;34mNameValue    Type    Mode ESC[0m
 |  
 |  y   1  Parameter  V RW 
 |  
 |  ESC[1;32mParameter docstrings:
 |  =====================ESC[0m
 |  
 |  ESC[1;34my: < No docstring available >ESC[0m
 |  
...

Maybe my terminal's not very clever, so it can't display colors, but you can see that there was no attempt to color the y line, and the value shown is the default rather than the actual value.

Additionally, the attached screenshot shows the result from within ipython (without having run %load_ext param.ipython):

ipython

If I deliberately stop the ipython extension from importing when I import param, here's what I get instead for help(x):

Help on X in module __main__ object:

class X(param.parameterized.Parameterized)
 |  params(y=Parameter, name=String)
 |  
 |  Method resolution order:
 |      X
 |      param.parameterized.Parameterized
 |      __builtin__.object
 |  
 |  Data descriptors defined here:
 |  
 |  name
 |      String identifier for this object.
 |  
 |  y
 |  
 |  ----------------------------------------------------------------------
...

i.e. no attempt to show the current value or say if it's changed from the default (so at least it doesn't mislead).

ceball commented 7 years ago

Check if still a problem