Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Scientific Software
MDANSE
Commits
484f4101
Commit
484f4101
authored
May 22, 2015
by
eric pellegrini
Browse files
Completed the docstringing of Configurators
parent
a1f47fb7
Changes
23
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Configurators/ComplexNumberConfigurator.py
View file @
484f4101
...
...
@@ -46,7 +46,7 @@ class ComplexNumberConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration
:param name: the name of the configurator as it will appear in the configuration
:type name: str
:param mini: the minimum modulus allowed for the input value. If None, no restriction for the minimum.
:type mini: float or None
...
...
MDANSE/Framework/Configurators/FloatConfigurator.py
View file @
484f4101
...
...
@@ -45,7 +45,7 @@ class FloatConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param mini: the minimum value allowed for the input value. If None, no restriction for the minimum.
:type mini: float or None
...
...
MDANSE/Framework/Configurators/FramesConfigurator.py
View file @
484f4101
...
...
@@ -52,7 +52,7 @@ class FramesConfigurator(RangeConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration
:param name: the name of the configurator as it will appear in the configuration
.
:type name: str
'''
...
...
@@ -60,12 +60,12 @@ class FramesConfigurator(RangeConfigurator):
def
configure
(
self
,
configuration
,
value
):
'''
Configure
an input value
.
Configure
the frames range that will be used to perform an analysis
.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input value
:type value: 3-tuple
s
, 'all' or None
:type value: 3-tuple, 'all' or None
'''
trajConfig
=
configuration
[
self
.
_dependencies
[
'trajectory'
]]
...
...
MDANSE/Framework/Configurators/GroupingLevelConfigurator.py
View file @
484f4101
...
...
@@ -65,7 +65,7 @@ class GroupingLevelConfigurator(SingleChoiceConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration
:param name: the name of the configurator as it will appear in the configuration
:type name: str
:param choices: the level of granularities allowed for the input value. If None all levels are allowed.
:type choices: one of ['atom','group','residue','chain','molecule'] or None
...
...
MDANSE/Framework/Configurators/InputFileConfigurator.py
View file @
484f4101
...
...
@@ -48,7 +48,7 @@ class InputFileConfigurator(IConfigurator):
'''
Initializes the configurator object.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param wildcard: the wildcard used to filter the file. This will be used in MDANSE GUI when
browsing for the input file.
...
...
MDANSE/Framework/Configurators/IntegerConfigurator.py
View file @
484f4101
...
...
@@ -45,7 +45,7 @@ class IntegerConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param mini: the minimum value allowed for the input value. If None, no restriction for the minimum.
:type mini: int or None
...
...
MDANSE/Framework/Configurators/InterpolationOrderConfigurator.py
View file @
484f4101
...
...
@@ -58,7 +58,7 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str.
'''
...
...
MDANSE/Framework/Configurators/MMTKTrajectoryConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: Eric C. Pellegrini
'''
...
...
MDANSE/Framework/Configurators/McStasParametersConfigurator.py
View file @
484f4101
...
...
@@ -48,7 +48,7 @@ class McStasParametersConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param exclude: the parameters that exclude when building the McStas instrument parameters list.
:type exclude: list of str
...
...
MDANSE/Framework/Configurators/MultipleChoicesConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: Eric C. Pellegrini
'''
...
...
@@ -47,7 +47,7 @@ class MultipleChoicesConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param choices: the list of values allowed for selection.
:type choices: list
...
...
MDANSE/Framework/Configurators/NetCDFInputFileConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: Eric C. Pellegrini
'''
...
...
@@ -53,7 +53,7 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param variables: the list of NetCDF variables that must be present in the input NetCDF file or None if there is no compulsory variable.
:type variables: list of str or None
...
...
MDANSE/Framework/Configurators/OutputDirectoryConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: pellegrini
'''
...
...
@@ -48,7 +48,7 @@ class OutputDirectoryConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param new: if True the output directory path will be checked for being new.
:type new: bool
...
...
MDANSE/Framework/Configurators/OutputFilesConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: Eric C. Pellegrini
'''
...
...
@@ -55,7 +55,7 @@ class OutputFilesConfigurator(IConfigurator):
'''
Initializes the configurator.
:param name: the name of the configurator as it will
be
appear in the configuration.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param formats: the list of output file formats suported.
:type formats: list of str
...
...
MDANSE/Framework/Configurators/ProjectionConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 21
, 2015
@author: Eric C. Pellegrini
'''
...
...
MDANSE/Framework/Configurators/PythonObjectConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author: Eric C. Pellegrini
'''
...
...
MDANSE/Framework/Configurators/QVectorsConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author: Eric C. Pellegrini
'''
...
...
MDANSE/Framework/Configurators/RangeConfigurator.py
View file @
484f4101
...
...
@@ -25,9 +25,9 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
import
numpy
...
...
@@ -36,7 +36,9 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
RangeConfigurator
(
IConfigurator
):
"""
This configurator allow to input a range of value given 3 parameters : start, stop, step
This configurator allow to input a range of values given 3 parameters : start, stop, step.
By default the values are generated as a NumPy array.
"""
type
=
"range"
...
...
@@ -44,6 +46,24 @@ class RangeConfigurator(IConfigurator):
_default
=
(
0
,
10
,
1
)
def
__init__
(
self
,
name
,
valueType
=
int
,
includeLast
=
False
,
sort
=
False
,
toList
=
False
,
mini
=
None
,
maxi
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param valueType: the numeric type for the range.
:type valueType: int or float
:param includeLast: if True the last value of the interval will be included (closed interval) otherwise excluded (opened interval).
:type includeLast: bool
:param sort: if True, the values generated will be sorted in increasing order.
:type bool: if True, the values generated will be converted from a NumPy array to a python list.
:param toList:
:type toList: bool
:param mini: if not None, all values generated below mini will be discarded.
:type mini: int, float or None
:param maxi: if not None, all values generated over maxi will be discarded.
:type maxi: int, float or None
'''
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
...
...
@@ -60,6 +80,14 @@ class RangeConfigurator(IConfigurator):
self
.
_maxi
=
maxi
def
configure
(
self
,
configuration
,
value
):
'''
Configure a range from its first, last and step values.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the first, last and step values used to generate the range.
:type value: 3-tuple
'''
first
,
last
,
step
=
value
...
...
@@ -101,35 +129,77 @@ class RangeConfigurator(IConfigurator):
@
property
def
valueType
(
self
):
'''
Returns the values type of the range.
:return: the values type of the range.
:rtype: one of int or float
'''
return
self
.
_valueType
@
property
def
includeLast
(
self
):
'''
Returns whether or not the range will be closed (True) or opened (False).
:return: True if the generated range is closed, otherwise False.
:rtype: bool
'''
return
self
.
_includeLast
@
property
def
toList
(
self
):
'''
Returns whether or not the range will be generated a Numpy array (True) or python list (False).
:return: True if the generated range is a python list, otherwise it is a Numpy array.
:rtype: bool
'''
return
self
.
_toList
@
property
def
sort
(
self
):
'''
Returns whether or not the generated values will be sorted in increasing order.
:return: True if the generated values are sorted in in creasing order, False otherwise.
:rtype: bool
'''
return
self
.
_sort
@
property
def
mini
(
self
):
'''
Returns the minimum value for the range, None if no limit.
:return: the minimum value for the range, None if no limit.
:rtype: int or float
'''
return
self
.
_mini
@
property
def
maxi
(
self
):
'''
Returns the maximum value for the range, None if no limit.
:return: the maximum value for the range, None if no limit.
:rtype: int or float
'''
return
self
.
_maxi
def
get_information
(
self
):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
info
=
"$d values from %s to %s"
%
(
self
[
'number'
],
self
[
'first'
],
self
[
'last'
])
...
...
MDANSE/Framework/Configurators/RunningModeConfigurator.py
View file @
484f4101
...
...
@@ -25,9 +25,9 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
from
MDANSE
import
PLATFORM
...
...
@@ -35,22 +35,34 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
RunningModeConfigurator
(
IConfigurator
):
"""
This configurator allow to choose the mode use to run the calculation.
choose among "monoprocessor" or "multiprocessor",
and also, in the second case, the number of processors getting involve.
the
option "remote", is not yet available
.
This configurator allow
s
to choose the mode use
d
to run the calculation.
MDANSE currently support monoprocessor or multiprocessor (SMP) running modes. In the laster case, you have to specify
the
number of slots used for running the analysis
.
"""
type
=
'running_mode'
availablesModes
=
[
"monoprocessor"
,
"multiprocessor"
,
"remote"
]
availablesModes
=
[
"monoprocessor"
,
"multiprocessor"
]
_default
=
(
"monoprocessor"
,
1
)
def
configure
(
self
,
configuration
,
value
):
'''
Configure the running mode.
mode
=
value
[
0
].
lower
()
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the running mode specification. It can be "monoprocessor" string or a 2-tuple whose first element must
be "multiprocessor" string and 2nd element the number of slots allocated for running the analysis.
:type value: "monoprocessor" or 2-tuple
'''
if
isinstance
(
value
,
basestring
):
mode
=
value
else
:
mode
=
value
[
0
].
lower
()
if
not
mode
in
self
.
availablesModes
:
raise
ConfiguratorError
(
"%r is not a valid running mode."
%
mode
,
self
)
...
...
@@ -79,5 +91,11 @@ class RunningModeConfigurator(IConfigurator):
self
[
'slots'
]
=
slots
def
get_information
(
self
):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
return
"Run in %s mode (%d slots)"
%
(
self
[
"mode"
],
self
[
"slots"
])
\ No newline at end of file
MDANSE/Framework/Configurators/SingleChoiceConfigurator.py
View file @
484f4101
...
...
@@ -25,9 +25,9 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
...
...
@@ -42,12 +42,28 @@ class SingleChoiceConfigurator(IConfigurator):
_default
=
[]
def
__init__
(
self
,
name
,
choices
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param choices: the list of values allowed for selection.
:type choices: list
'''
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
self
.
_choices
=
choices
if
choices
is
not
None
else
[]
def
configure
(
self
,
configuration
,
value
):
'''
Configure the input item.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input selection list.
:type value: list
'''
try
:
self
[
"index"
]
=
self
.
_choices
.
index
(
value
)
...
...
@@ -58,9 +74,21 @@ class SingleChoiceConfigurator(IConfigurator):
@
property
def
choices
(
self
):
'''
Returns the list of allowed selection items.
:return: the list of allowed selection items.
:rtype: list
'''
return
self
.
_choices
def
get_information
(
self
):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
return
"Selected item: %r"
%
self
[
'value'
]
\ No newline at end of file
MDANSE/Framework/Configurators/StringConfigurator.py
View file @
484f4101
...
...
@@ -25,7 +25,7 @@
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
'''
Created on Ma
r 30
, 2015
Created on Ma
y 22
, 2015
@author: pellegrini
'''
...
...
@@ -36,7 +36,7 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
StringConfigurator
(
IConfigurator
):
"""
This Configurator allows to input a
S
tring
Value (sequence of unicode char)
.
This Configurator allows to input a
s
tring.
"""
type
=
'string'
...
...
@@ -44,6 +44,16 @@ class StringConfigurator(IConfigurator):
_default
=
""
def
__init__
(
self
,
name
,
evalType
=
None
,
acceptNullString
=
True
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will appear in the configuration.
:type name: str
:param evalType: the type to which the string will be evaluated or None if it is let as is.
:type evalType: python object or None
:param acceptNullString: if True a null (or blank) string can be input.
:type acceptNullString: bool
'''
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
...
...
@@ -52,11 +62,19 @@ class StringConfigurator(IConfigurator):
self
.
_acceptNullString
=
acceptNullString
def
configure
(
self
,
configuration
,
value
):
'''
Configure an input string.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input string
:type value: str
'''
value
=
str
(
value
)
if
not
self
.
_acceptNullString
:
if
not
value
:
if
not
value
.
strip
()
:
raise
ConfiguratorError
(
"invalid null string"
,
self
)
if
self
.
_evalType
is
not
None
:
...
...
@@ -68,14 +86,32 @@ class StringConfigurator(IConfigurator):
@
property
def
acceptNullString
(
self
):
'''
Returns whether or not a null (or blank) string is accepted.
:return: True if a null (or blank) string is accepted as input, False otherwise.
:rtype: bool
'''
return
self
.
_acceptNullString
@
property
def
evalType
(
self
):
'''
Returns the type to which the string will be evaluated or None if it is let as is.
:return: the type to which the string will be evaluated or None if it is let as is.
:rtype: python object or None
'''
return
self
.
_evalType
def
get_information
(
self
):
'''
Returns string information about this configurator.
:return: the information about this configurator.
:rtype: str
'''
return
"Value: %r"
%
self
[
'value'
]
\ No newline at end of file
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment