From 15bb56caf52bffeac503d4170aa0b82c4d3725b2 Mon Sep 17 00:00:00 2001 From: Arturs Bekasovs <arturs.bekasovs@stfc.ac.uk> Date: Fri, 6 Jun 2014 15:06:00 +0100 Subject: [PATCH] Refs #9568. MuonCalculateAsymmetry Plus a small fix for it in alg. property default value display --- .../algorithms/MuonCalculateAsymmetry-v1.rst | 50 +++++++++++++++++++ .../mantiddoc/directives/properties.py | 6 +++ 2 files changed, 56 insertions(+) diff --git a/Code/Mantid/docs/source/algorithms/MuonCalculateAsymmetry-v1.rst b/Code/Mantid/docs/source/algorithms/MuonCalculateAsymmetry-v1.rst index a0b012ed993..49a1dc7530b 100644 --- a/Code/Mantid/docs/source/algorithms/MuonCalculateAsymmetry-v1.rst +++ b/Code/Mantid/docs/source/algorithms/MuonCalculateAsymmetry-v1.rst @@ -24,4 +24,54 @@ For every mode, either one or two data acquisition period workspaces can be provided. PeriodOperation determines in which way period data will be merged at the end. +Usage +----- + +**Example - Pair asymmetry for a single period:** + +.. testcode:: ExPairAsymmetry + + y = [1,2,3] + [4,5,6] + x = [1,2,3] * 2 + input = CreateWorkspace(x, y, NSpec=2) + + output = MuonCalculateAsymmetry(FirstPeriodWorkspace = input, + OutputType = 'PairAsymmetry', + PairFirstIndex = 1, + PairSecondIndex = 0, + Alpha = 0.5) + + print 'Output:', ', '.join('{:.3f}'.format(y) for y in output.readY(0)) + +Output: + +.. testoutput:: ExPairAsymmetry + + Output: 0.778, 0.667, 0.600 + +**Example - Group asymmetry for two periods:** + +.. testcode:: ExGroupAsymmetryMultiperiod + + y1 = [100,50,10] + y2 = [150,20,1] + x = [1,2,3] + + input1 = CreateWorkspace(x, y1) + input2 = CreateWorkspace(x, y2) + + output = MuonCalculateAsymmetry(FirstPeriodWorkspace = input1, + SecondPeriodWorkspace = input2, + PeriodOperation = '-', + OutputType = 'GroupAsymmetry', + GroupIndex = 0) + + print 'Output:', ', '.join('{:.3f}'.format(y) for y in output.readY(0)) + +Output: + +.. testoutput:: ExGroupAsymmetryMultiperiod + + Output: -0.286, 0.606, 0.263 + .. categories:: diff --git a/Code/Mantid/docs/sphinxext/mantiddoc/directives/properties.py b/Code/Mantid/docs/sphinxext/mantiddoc/directives/properties.py index 469da90563c..d662e342471 100644 --- a/Code/Mantid/docs/sphinxext/mantiddoc/directives/properties.py +++ b/Code/Mantid/docs/sphinxext/mantiddoc/directives/properties.py @@ -1,4 +1,5 @@ from base import BaseDirective +import string class PropertiesDirective(BaseDirective): @@ -140,6 +141,11 @@ class PropertiesDirective(BaseDirective): # Fall-back default for anything defaultstr = str(default) + # A special case for single-character default values (e.g. + or *, see MuonLoad). We don't + # want them to be interpreted as list items. + if len(defaultstr) == 1 and defaultstr in string.punctuation: + defaultstr = "\\" + defaultstr + # Replace the ugly default values with "Optional" if (defaultstr == "8.9884656743115785e+307") or \ (defaultstr == "1.7976931348623157e+308") or \ -- GitLab