Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation #20

Merged
merged 16 commits into from Oct 5, 2016
Merged
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,6 @@
build/
docs/_build
dist/
.idea/
dist/
vcs.egg-info/
24 changes: 6 additions & 18 deletions vcs/Canvas.py
Expand Up @@ -1040,7 +1040,6 @@ def scriptobject(self, obj, script_filename=None, mode=None):
.. doctest:: canvas_scriptobject

>>> a=vcs.init()
>>> l=a.getline('red') # To Modify an existing line object
>>> i=a.createisoline('dean') # Create an instance of default isoline object
>>> a.scriptobject(i,'ex_isoline.py') # Save isoline object as a Python file 'isoline.py'
>>> a.scriptobject(i,'ex_isoline2') # Save isoline object as a JSON object 'isoline2.json'
Expand Down Expand Up @@ -1175,7 +1174,7 @@ def createboxfill(self, name=None, source='default'):

def getboxfill(self, Gfb_name_src='default'):
return vcs.getboxfill(Gfb_name_src)
getboxfill.__doc__ = vcs.manageElements.getboxfill
getboxfill.__doc__ = vcs.manageElements.getboxfill.__doc__

def boxfill(self, *args, **parms):
"""
Expand Down Expand Up @@ -1252,7 +1251,6 @@ def taylordiagram(self, *args, **parms):
.. doctest:: canvas_taylordiagram

>>> a=vcs.init()

>>> a.show('taylordiagram') # Show all the existing taylordiagram graphics methods
*******************Taylordiagram Names List**********************
...
Expand Down Expand Up @@ -2160,7 +2158,7 @@ def textcombined(self, *args, **parms):
...
*******************End Textorientation Names List**********************
>>> vcs.createtext('qa_tta', 'qa', '7left_tto', '7left') # Create instance of 'std_tt' and '7left_to'
<vcs.textcombined.Tc object at ...
<vcs.textcombined.Tc object at ...>
>>> tc=a.gettext('qa_tta', '7left_tto')
>>> tc.string='Text1' # Show the string "Text1" on the VCS Canvas
>>> tc.font=2 # Set the text size
Expand Down Expand Up @@ -2219,7 +2217,7 @@ def gettextextent(self, textobject):
>>> t.y=[.5]
>>> t.string=['Hello World']
>>> a.gettextextent(t)
[[0.5, 0.578125, 0.5, 0.5177065767284992]]
[[...]]

:param textobject: A VCS text object
:type textobject: textcombined
Expand Down Expand Up @@ -4485,7 +4483,7 @@ def ffmpeg(self, movie, files, bitrate=1024, rate=None, options=None):

ffmpeg ALWAYS overwrites the output file

.. admonishment:: Audio configuration
.. admonition:: Audio configuration

via the options arg you can add audio file to your movie (see ffmpeg help)

Expand Down Expand Up @@ -5477,22 +5475,12 @@ def getplot(self, Dp_name_src='default', template=None):
"""
.. deprecated:: 2.0

The getplot function is deprecated
The getplot function is deprecated. Do not use it.

This function will create a display plot object from an existing display
plot object from an existing VCS plot. If no display plot name
is given, then None is returned.

:Example:

.. doctest:: canvas_getplot

>>> a=vcs.init()
>>> a.show('template') # Show all the existing templates
*******************Template Names List**********************
...
*******************End Template Names List**********************
>>> plot1=a.getplot() # plot1 instance of 'dpy_plot_1' display plot

:param Dp_name_src: String name of an existing display plot object
:type Dp_name_src: str
Expand Down Expand Up @@ -5697,8 +5685,8 @@ def orientation(self, *args, **kargs):
return self.backend.orientation(*args, **kargs)

def getcolorcell(self, *args):
"""%s""" % vcs.getcolorcell.__doc__
return vcs.getcolorcell(args[0], self)
getcolorcell.__doc__ = vcs.utils.getcolorcell.__doc__

def getcolormapname(self):
"""
Expand Down
1 change: 1 addition & 0 deletions vcs/Pdata.py
Expand Up @@ -63,6 +63,7 @@ class Pds(object):
.. describe:: Modify an existing line:

.. code-block:: python

# Get a copy of 'red' line
ln=a.getline('red')

Expand Down
2 changes: 1 addition & 1 deletion vcs/Ptext.py
Expand Up @@ -98,7 +98,7 @@ class Pt(object):
ln.type='dash-dot'
# Same as ln.type=4
ln.type='long-dash'
"""
"""
##########################################################################
# #
# Initialize the line attributes. #
Expand Down
3 changes: 2 additions & 1 deletion vcs/Pxlabels.py
Expand Up @@ -68,6 +68,7 @@ class Pxl(object):
.. describe:: Modify an existing line:

.. code-block:: python

# Get a copy of 'red' line
ln=a.getline('red')

Expand Down Expand Up @@ -99,7 +100,7 @@ class Pxl(object):
ln.type='dash-dot'
# Same as ln.type=4
ln.type='long-dash'
"""
"""
##########################################################################
# #
# Initialize the line attributes. #
Expand Down
3 changes: 2 additions & 1 deletion vcs/Pxtickmarks.py
Expand Up @@ -69,6 +69,7 @@ class Pxt(object):
.. describe:: Modify an existing line:

.. code-block:: python

# Get a copy of 'red' line
ln=a.getline('red')

Expand Down Expand Up @@ -100,7 +101,7 @@ class Pxt(object):
ln.type='dash-dot'
# Same as ln.type=4
ln.type='long-dash'
"""
"""
__slots__ = [
"line",
"priority",
Expand Down
3 changes: 2 additions & 1 deletion vcs/Pylabels.py
Expand Up @@ -68,6 +68,7 @@ class Pyl(object):
.. describe:: Modify an existing line:

.. code-block:: python

# Get a copy of 'red' line
ln=a.getline('red')

Expand Down Expand Up @@ -99,7 +100,7 @@ class Pyl(object):
ln.type='dash-dot'
# Same as ln.type=4
ln.type='long-dash'
"""
"""
##########################################################################
# #
# Initialize the line attributes. #
Expand Down
1 change: 1 addition & 0 deletions vcs/Pytickmarks.py
Expand Up @@ -68,6 +68,7 @@ class Pyt(object):
.. describe:: Modify an existing line:

.. code-block:: python

# Get a copy of 'red' line
ln=a.getline('red')

Expand Down
24 changes: 12 additions & 12 deletions vcs/__init__.py
Expand Up @@ -253,7 +253,7 @@

def init(mode=1, pause_time=0, call_from_gui=0, size=None,
backend="vtk", geometry=None, bg=None):
'''
"""
Initialize and construct a VCS Canvas object.

:Example:
Expand All @@ -278,17 +278,17 @@ def init(mode=1, pause_time=0, call_from_gui=0, size=None,

bg_canvas = vcs.init(bg=True)

:param size: Aspect ratio for canvas (width / height)
:param backend: Which VCS backend to use
:param geometry: Size (in pixels) you want the canvas to be.
:param bg: Initialize a canvas to render in "background" mode (without displaying a window)
:type size: float or case-insensitive str
:type backend: str, `vtk.vtkRenderWindow`
:type geometry: dict or tuple
:type bg: bool
:return: an initialized canvas
:rtype: vcs.Canvas.Canvas
'''
:param size: Aspect ratio for canvas (width / height)
:param backend: Which VCS backend to use
:param geometry: Size (in pixels) you want the canvas to be.
:param bg: Initialize a canvas to render in "background" mode (without displaying a window)
:type size: float or case-insensitive str
:type backend: str, `vtk.vtkRenderWindow`
:type geometry: dict or tuple
:type bg: bool
:return: an initialized canvas
:rtype: vcs.Canvas.Canvas
"""
canvas = Canvas.Canvas(
mode=mode,
pause_time=pause_time,
Expand Down
23 changes: 12 additions & 11 deletions vcs/animate_helper.py
Expand Up @@ -22,21 +22,22 @@ def showerror(msg):
class animate_obj_old(object):

"""
Function: animate
Animate the contents of the VCS Canvas. The animation can also be controlled from
the animation GUI. (See VCDAT for more details.)

Description of Function:
Animate the contents of the VCS Canvas. The animation can also be controlled from
the animation GUI. (See VCDAT for more details.)
See the `animation GUI documentation`_

See the animation GUI documenation located at URL:
http://www-pcmdi.llnl.gov/software/vcs
.. _animation GUI documentation: http://www-pcmdi.llnl.gov/software/vcs

Example of Use:
a=vcs.init()
a.plot(array,'default','isofill','quick')
a.animate()
:Example:

"""
.. doctest:: animate_helper_obj_old

>>> a=vcs.init()
>>> a.plot(array,'default','isofill','quick')
>>> a.animate()

"""

##########################################################################
# Initialize the animation flags #
Expand Down
29 changes: 28 additions & 1 deletion vcs/boxfill.py
Expand Up @@ -356,6 +356,33 @@ class Gfb(object):
""" % xmldocs.graphics_method_core # noqa

def rename(self, newname):
"""
Renames the boxfill in the VCS name table.

.. note::

This function will not rename the 'default' boxfill.
If rename is called on the 'default' boxfill, newname is associated with default in the VCS name table,
but the boxfill's name will not be changed, and will behave in all ways as a 'default' boxfill.

:Example:

.. doctest:: gfb_rename

>>> b=vcs.createboxfill()
>>> b.name
'...'
>>> vcs.listelements('boxfill') # list will include the name show above
[...]
>>> b.rename('foo')
>>> b.name
'foo'
>>> vcs.listelements('boxfill') # list will include 'foo', but not the old name
[...'foo'...]

:param newname: The new name you want given to the boxfill
:type newname:
"""
if newname == "default":
raise Exception(
"You cannot overwrite the default boxfill graphic method")
Expand Down Expand Up @@ -1085,7 +1112,7 @@ def script(self, script_filename, mode='a'):
f = open(script_filename, mode)
vcs.utils.dumpToJson(self, f)
f.close()
script.__doc__ = xmldocs.boxfill_script
script.__doc__ = xmldocs.scriptdocs['boxfill']

###############################################################################
# END OF FILE #
Expand Down
58 changes: 25 additions & 33 deletions vcs/colormap.py
Expand Up @@ -305,33 +305,27 @@ def setcolorcell(self, index, red, green, blue, alpha=100.):

:Example:

::
.. doctest:: colormap_setcolorcell

#Create a vcs Canvas
a = vcs.init()
#Create a colormap
cmap = a.createcolormap('example', 'default')
#Set RGBA values
cmap.setcolorcell(1,255,255,255,1.0)
>>> a = vcs.init() # Create a vcs Canvas
>>> cmap = a.createcolormap('example', 'default') # Create a colormap
>>> cmap.setcolorcell(40,80,95,1.0) # Set RGBA values

:param index: Integer from 0-255.
:type index: int
:param index: Integer from 0-255.
:type index: int

:param red: Integer from 0-255 representing the concentration of red in the colorcell.
:type red: int
:param red: Integer from 0-255 representing the concentration of red in the colorcell.
:type red: int

:param green: Integer from 0-255 representing the concentration of green in the colorcell.
:type green: int
:param green: Integer from 0-255 representing the concentration of green in the colorcell.
:type green: int

:param blue: Integer from 0-255 representing the concentration of blue in the colorcell.
:type blue: int
:param blue: Integer from 0-255 representing the concentration of blue in the colorcell.
:type blue: int

:param alpha: Float representing the percentage of opacity in the colorcell.
:type alpha: float

:returns:
:rtype:
"""
:param alpha: Float representing the percentage of opacity in the colorcell.
:type alpha: float
"""
self.index[index] = [red, green, blue, alpha]

# get a colorcell RGB
Expand All @@ -341,20 +335,18 @@ def getcolorcell(self, index):

:Example:

::
.. doctest:: colormap_getcolorcell

#Create a vcs Canvas
a = vcs.init()
#Create a colormap
cmap = a.createcolormap('example', 'default')
#Get RGBA values
cmap.getcolorcell(1)
>>> a=vcs.init() # Create a vcs Canvas
>>> cmap = a.createcolormap('example', 'default') # Create a colormap
>>> cmap.getcolorcell(1) # Get RGBA values
[0, 0, 0, 100.0]

:param index: Index of a cell in the colormap. Must be an integer from 0-255.
:type index: int
:param index: Index of a cell in the colormap. Must be an integer from 0-255.
:type index: int

:returns: A list containing the red, green, blue, and alpha values (in that order), of the colorcell at the given index.
:rtype: list
:returns: A list containing the red, green, blue, and alpha values (in that order), of the colorcell at the given index.
:rtype: list
"""
return self.index[index]

Expand Down Expand Up @@ -436,7 +428,7 @@ def script(self, script_filename=None, mode=None):
vcs.utils.dumpToJson(self, f)
f.close()

script.__doc__ = xmldocs.colormap_script
script.__doc__ = xmldocs.scriptdocs['colormap']
##########################################################################
# END OF FILE #
##########################################################################
12 changes: 11 additions & 1 deletion vcs/colors.py
Expand Up @@ -2,9 +2,19 @@


def matplotlib2vcs(cmap, vcs_name=None):
"""Convert a matplotlib colormap to a vcs colormap
"""
Convert a matplotlib colormap to a vcs colormap
Input can be either the actual matplotlib colormap or its name
Optional second argument: vcs_name, name of the resulting vcs colormap

:param cmap: A matplotlib colormap or string name of a matplotlib colormap
:type cmap: str , matplotlib colormap

:param vcs_name: String to set the name of the generated VCS colormap
:type vcs_name: str

:returns: A VCS colormap object
:rtype: vcs.colormap.Cp
"""
import vcs
import matplotlib.cm
Expand Down