Skip to content

Commit

Permalink
Improve CreateSingleValuedWorkspace docs and add usage tests.
Browse files Browse the repository at this point in the history
Refs #9574
  • Loading branch information
martyngigg committed Jun 5, 2014
1 parent 9344224 commit 7698532
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
Expand Up @@ -54,8 +54,8 @@ class DLLExport CreateSingleValuedWorkspace : public Mantid::API::Algorithm
virtual ~CreateSingleValuedWorkspace() {}
/// Algorithm's name
virtual const std::string name() const { return "CreateSingleValuedWorkspace"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return "Creates a 2D workspace with a single value contained in it.";}
///Summary of algorithms purpose
virtual const std::string summary() const {return "Creates a 2D workspace containing a single X, Y & E value.";}

/// Algorithm's version
virtual int version() const { return (1); }
Expand Down
Expand Up @@ -10,7 +10,65 @@ Description
-----------

Creates a 2D workspace that contains a single value and an optional
error value. This is useful if, for example, there is a need to multiply
(or divide etc) a workspace by a single value.
error value. This was traditionally used for doing binary operations between
a workspace and a single value. However, now that the Python access allows
the standard binary operations with workspaces & single numbers, the requirement
for this algorithm is almost gone.

One use case for which it will be required is when performing operations using only
the MantidPlot GUI point-and-click approach.

Usage
-----

**Workspace with single y value and zero error:**

.. testcode::

five = CreateSingleValuedWorkspace(5)

print "Number of histograms:",five.getNumberHistograms()
print "Length of y array:",len(five.readY(0))
print "Length of e array:",len(five.readE(0))
print "Length of x array:",len(five.readX(0))

print "y value:",five.readY(0)
print "e value:",five.readE(0)

Output:

.. testoutput::

Number of histograms: 1
Length of y array: 1
Length of e array: 1
Length of x array: 1
y value: [ 5.]
e value: [ 0.]

**Workspace with single y and e value:**

.. testcode::

five = CreateSingleValuedWorkspace(5, 0.1)

print "Number of histograms:",five.getNumberHistograms()
print "Length of y array:",len(five.readY(0))
print "Length of e array:",len(five.readE(0))
print "Length of x array:",len(five.readX(0))

print "y value:",five.readY(0)
print "e value:",five.readE(0)

Output:

.. testoutput::

Number of histograms: 1
Length of y array: 1
Length of e array: 1
Length of x array: 1
y value: [ 5.]
e value: [ 0.1]

.. categories::

0 comments on commit 7698532

Please sign in to comment.