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
84668f96
Commit
84668f96
authored
May 06, 2015
by
eric pellegrini
Browse files
Docstringed a few configurators
parent
df0ba797
Changes
7
Hide whitespace changes
Inline
Side-by-side
MDANSE/Framework/Configurators/AtomSelectionConfigurator.py
View file @
84668f96
...
...
@@ -67,8 +67,9 @@ class AtomSelectionConfigurator(IConfigurator):
def
configure
(
self
,
configuration
,
value
):
'''
Configure this configurator with a given input value. The value must be
a string that can be either an atom selection string or a valid user
Configure an input value.
The value must be a string that can be either an atom selection string or a valid user
definition.
:param configuration: the current configuration
...
...
@@ -174,7 +175,7 @@ class AtomSelectionConfigurator(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations about this configurator
Returns some informations about this configurator
.
:return: the information about this configurator
:rtype: str
...
...
MDANSE/Framework/Configurators/AtomTransmutationConfigurator.py
View file @
84668f96
...
...
@@ -39,6 +39,12 @@ class AtomTransmutationConfigurator(IConfigurator):
"""
This configurator allows to define a set of atoms to be transmutated to a given chemical
element.
For some analysis it can be necessary to change the nature of the chemical element of a given
part of the system to have results closer to experience. A good example is to change some
hydrogen atoms to deuterium in order to fit with experiments where deuteration experiments have
been performed for improving the contrast and having a better access to the dynamic of a specific part
of the molecular system.
To Build an atomic transmutation from the GUI you have to :
#. Create a workspace based on a MMTK trajectory data,
...
...
@@ -54,7 +60,9 @@ class AtomTransmutationConfigurator(IConfigurator):
def
configure
(
self
,
configuration
,
value
):
'''
Configure this configurator with a given input value. The value can be:
Configure an given input value.
The value can be:
#. None: no transmutation is performed
#. (str,str)-dict: for each (str,str) pair, a transmutation will be performed
by parsing the 1st element as an atom selection string and transmutating the
...
...
@@ -128,7 +136,7 @@ class AtomTransmutationConfigurator(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations about this configurator
Returns some informations about this configurator
.
:return: the information about this configurator
:rtype: str
...
...
MDANSE/Framework/Configurators/AxisSelectionConfigurator.py
View file @
84668f96
...
...
@@ -36,8 +36,9 @@ from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule
class
AxisSelection
(
IConfigurator
):
"""
This configurator allows to define an axis per molecule. For each molecule, the
axis is basically defined using the coordinates of two of its atoms.
This configurator allows to define a local axis per molecule.
For each molecule, the axis is defined using the coordinates of two atoms of the molecule.
To Build an axis selection from the GUI you have to :
#. Create a workspace based on a mmtk_trajectory data,
...
...
@@ -53,7 +54,9 @@ class AxisSelection(IConfigurator):
def
configure
(
self
,
configuration
,
value
):
'''
Configure this configurator with a given input value. The value can be:
Configure an input value.
The value can be:
#. a dict with 'molecule', 'endpoint1' and 'endpoint2' keys. 'molecule' key
is the molecule name for which the axis selection will be performed
and 'endpoint1' and 'endpoint2' keys are the names of two atoms of the molecule
...
...
@@ -85,7 +88,7 @@ class AxisSelection(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations about this configurator
Returns some informations about this configurator
.
:return: the information about this configurator
:rtype: str
...
...
MDANSE/Framework/Configurators/BasisSelectionConfigurator.py
View file @
84668f96
...
...
@@ -36,10 +36,11 @@ from MDANSE.MolecularDynamics.Trajectory import find_atoms_in_molecule
class
BasisSelection
(
IConfigurator
):
"""
This configurator allows to define basis per molecule. For each molecule, the
basis is basically defined using the coordinates of three of its atoms. This coordinates
will respectively define the origin the X axis and y axis of the basis, the Z axis
being defined in such a way that the basis is direct.
This configurator allows to define a local basis per molecule.
For each molecule, the basis is defined using the coordinates of three atoms of the molecule.
These coordinates will respectively define the origin, the X axis and y axis of the basis, the
Z axis being latter defined in such a way that the basis is direct.
To Build a basis selection from the GUI you have to :
#. Create a workspace based on a mmtk_trajectory data,
...
...
@@ -53,7 +54,9 @@ class BasisSelection(IConfigurator):
def
configure
(
self
,
configuration
,
value
):
'''
Configure this configurator with a given input value. The value can be:
Configure an input value.
The value can be:
#. a dict with 'molecule', 'origin', 'x_axis' and 'y_axis' keys.
'molecule' key is the molecule name for which the axis selection will be performed
and 'origin', 'x_axis' and 'y_axis' keys are the names of three atoms of the molecule
...
...
@@ -88,7 +91,7 @@ class BasisSelection(IConfigurator):
def
get_information
(
self
):
'''
Returns some informations about this configurator
Returns some informations about this configurator
.
:return: the information about this configurator
:rtype: str
...
...
MDANSE/Framework/Configurators/BooleanConfigurator.py
View file @
84668f96
...
...
@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
...
...
@@ -35,28 +35,41 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
BooleanConfigurator
(
IConfigurator
):
"""
This Configurator allows to input a Boolean Value (True or False).
The input value can be directly provided as a Python boolean or by the using the following (standard)
representation of a boolean: 'true'/'false', 'yes'/'no', 'y'/'n', '1'/'0', 1/0
"""
type
=
'boolean'
_default
=
False
_shortCuts
=
{
"true"
:
True
,
"yes"
:
True
,
"y"
:
True
,
"
t
"
:
True
,
"1"
:
True
,
"false"
:
False
,
"no"
:
False
,
"n"
:
False
,
"
f
"
:
False
,
"0"
:
False
}
_shortCuts
=
{
True
:
True
,
"true"
:
True
,
"yes"
:
True
,
"y"
:
True
,
"
1
"
:
True
,
1
:
True
,
False
:
False
,
"false"
:
False
,
"no"
:
False
,
"n"
:
False
,
"
0
"
:
False
,
0
:
False
}
def
configure
(
self
,
configuration
,
value
):
'''
Configure an input value.
The value must be one of True/False, 'true'/'false', 'yes'/'no', 'y'/'n', '1'/'0', 1/0.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input value
:type value: one of True/False, 'true'/'false', 'yes'/'no', 'y'/'n', '1'/'0', 1/0
'''
if
hasattr
(
value
,
"lower"
):
value
=
value
.
lower
()
if
not
self
.
_shortCuts
.
has_key
(
value
):
raise
ConfiguratorError
(
'invalid boolean string'
,
self
)
if
not
self
.
_shortCuts
.
has_key
(
value
):
raise
ConfiguratorError
(
'the input value can not be interpreted as a boolean'
,
self
)
value
=
bool
(
value
)
self
[
'value'
]
=
value
self
[
"value"
]
=
self
.
_shortCuts
[
value
]
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Value: %r"
%
self
[
'value'
]
\ No newline at end of file
MDANSE/Framework/Configurators/ComplexNumberConfigurator.py
View file @
84668f96
...
...
@@ -27,7 +27,7 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
from
MDANSE.Mathematics.Arithmetic
import
ComplexNumber
...
...
@@ -35,8 +35,7 @@ from MDANSE.Framework.Configurators.IConfigurator import IConfigurator, Configur
class
ComplexNumberConfigurator
(
IConfigurator
):
"""
This Configurator allows to input a Complex Value a + bi,
where a and b are real numbers and i is the imaginary unit.
This Configurator allows to input a complex number of the form a + bj.
"""
type
=
'complex_number'
...
...
@@ -44,17 +43,37 @@ class ComplexNumberConfigurator(IConfigurator):
_default
=
0
def
__init__
(
self
,
name
,
mini
=
None
,
maxi
=
None
,
choices
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will be appear in the configuration
:type name: str
:param mini: the minimum modulus of the input value. If None, no restriction in the modulus minimum.
:type mini: float or None
:param maxi: the maximum modulus of the input value. If None, no restriction in the modulus maximum.
:type maxi: float or None
:param choices: the list of complex numbers allowed for the input value. If None, any value will be allowed.
:type choices: list of complex or None
'''
# The base class constructor.
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
self
.
_mini
=
ComplexNumber
(
mini
)
if
mini
is
not
None
else
None
self
.
_mini
=
float
(
mini
)
if
mini
is
not
None
else
None
self
.
_maxi
=
ComplexNumber
(
maxi
)
if
maxi
is
not
None
else
None
self
.
_maxi
=
float
(
maxi
)
if
maxi
is
not
None
else
None
self
.
_choices
=
choices
if
choices
is
not
None
else
[]
def
configure
(
self
,
configuration
,
value
):
'''
Configure an input value.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input value
:type value: complex
'''
value
=
ComplexNumber
(
value
)
...
...
@@ -74,19 +93,43 @@ class ComplexNumberConfigurator(IConfigurator):
@
property
def
mini
(
self
):
'''
Returns the minimum value allowed for an input value of this configurator.
:return: the minimum value allowed for an input value of this configurator
:rtype: float or None
'''
return
self
.
_mini
@
property
def
maxi
(
self
):
'''
Returns the maximum value allowed for an input value of this configurator.
:return: the maximum value allowed for an input value of this configurator
:rtype: float or None
'''
return
self
.
_maxi
@
property
def
choices
(
self
):
'''
Returns the list of floats allowed for an input value of this configurator.
:return: the choices allowed for an input value of this configurator
:rtype: list of floats or None
'''
return
self
.
_choices
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Value: %r"
%
self
[
'value'
]
\ No newline at end of file
MDANSE/Framework/Configurators/FloatConfigurator.py
View file @
84668f96
...
...
@@ -27,14 +27,14 @@
'''
Created on Mar 30, 2015
@author:
p
ellegrini
@author:
Eric C. P
ellegrini
'''
from
MDANSE.Framework.Configurators.IConfigurator
import
IConfigurator
,
ConfiguratorError
class
FloatConfigurator
(
IConfigurator
):
"""
This Configurator allows to input a
F
loat
ing point Value
.
This Configurator allows to input a
f
loat.
"""
type
=
'float'
...
...
@@ -42,6 +42,18 @@ class FloatConfigurator(IConfigurator):
_default
=
0
def
__init__
(
self
,
name
,
mini
=
None
,
maxi
=
None
,
choices
=
None
,
**
kwargs
):
'''
Initializes the configurator.
:param name: the name of the configurator as it will be appear in the configuration
:type name: str
:param mini: the minimum value of the input value. If None, no restriction in the modulus minimum.
:type mini: float or None
:param maxi: the maximum value of the input value. If None, no restriction in the modulus maximum.
:type maxi: float or None
:param choices: the list of complex numbers allowed for the input value. If None, any value will be allowed.
:type choices: list of float or None
'''
# The base class constructor.
IConfigurator
.
__init__
(
self
,
name
,
**
kwargs
)
...
...
@@ -53,6 +65,14 @@ class FloatConfigurator(IConfigurator):
self
.
_choices
=
choices
if
choices
is
not
None
else
[]
def
configure
(
self
,
configuration
,
value
):
'''
Configure an input value.
:param configuration: the current configuration
:type configuration: a MDANSE.Framework.Configurable.Configurable object
:param value: the input value
:type value: float
'''
try
:
value
=
float
(
value
)
...
...
@@ -75,19 +95,43 @@ class FloatConfigurator(IConfigurator):
@
property
def
mini
(
self
):
'''
Returns the minimum value allowed for an input value of this configurator.
:return: the minimum value allowed for an input value of this configurator
:rtype: float or None
'''
return
self
.
_mini
@
property
def
maxi
(
self
):
'''
Returns the maximum value allowed for an input value of this configurator.
:return: the maximum value allowed for an input value of this configurator
:rtype: float or None
'''
return
self
.
_maxi
@
property
def
choices
(
self
):
'''
Returns the list of floats allowed for an input value of this configurator.
:return: the choices allowed for an input value of this configurator
:rtype: list of floats or None
'''
return
self
.
_choices
def
get_information
(
self
):
'''
Returns some informations about this configurator.
:return: the information about this configurator
:rtype: str
'''
return
"Value: %r"
%
self
[
'value'
]
\ No newline at end of file
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