Commit 6b9954cf authored by eric pellegrini's avatar eric pellegrini

The configurable object is now set as a keyword to avoid crash when

calling build_doc and get_default_parameters class method
parent 66423be2
......@@ -77,7 +77,7 @@ class Configurable(object):
for name,(typ,kwds) in self.settings.items():
try:
self._configuration[name] = REGISTRY["configurator"][typ](self, name, **kwds)
self._configuration[name] = REGISTRY["configurator"][typ](name, configurable=self,**kwds)
# Any kind of error has to be caught
except:
raise ConfigurationError("Invalid type for %r configurator" % name)
......@@ -187,7 +187,7 @@ class Configurable(object):
:param cls: the configurable class for which documentation should be built
:type cls: an instance of MDANSE.Framework.Configurable.Configurable derived class
:return: the documnetation about the configurable class
:return: the documentation about the configurable class
:rtype: str
'''
......
......@@ -47,7 +47,7 @@ class AtomsListConfigurator(IConfigurator):
_default = None
def __init__(self, configurable, name, nAtoms=2, **kwargs):
def __init__(self, name, nAtoms=2, **kwargs):
'''
Initializes the configurator.
......@@ -57,7 +57,7 @@ class AtomsListConfigurator(IConfigurator):
:type nAtoms: int
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._nAtoms = nAtoms
......
......@@ -42,7 +42,7 @@ class ComplexNumberConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None,**kwargs):
'''
Initializes the configurator.
......@@ -57,7 +57,7 @@ class ComplexNumberConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = float(mini) if mini is not None else None
......
......@@ -41,7 +41,7 @@ class FloatConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class FloatConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = float(mini) if mini is not None else None
......
......@@ -48,7 +48,7 @@ class FramesConfigurator(RangeConfigurator):
type = 'frames'
def __init__(self, configurable, name, **kwargs):
def __init__(self, name, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class FramesConfigurator(RangeConfigurator):
:type name: str
'''
RangeConfigurator.__init__(self, configurable, name, sort=True, **kwargs)
RangeConfigurator.__init__(self, name, sort=True, **kwargs)
def configure(self, value):
'''
......
......@@ -62,7 +62,7 @@ class GroupingLevelConfigurator(SingleChoiceConfigurator):
_default = "atom"
def __init__(self, configurable, name, choices=None, **kwargs):
def __init__(self, name, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -77,7 +77,7 @@ class GroupingLevelConfigurator(SingleChoiceConfigurator):
else:
choices = list(set(LEVELS.keys()).intersection(choices))
SingleChoiceConfigurator.__init__(self, configurable, name, choices=choices, **kwargs)
SingleChoiceConfigurator.__init__(self, name, choices=choices, **kwargs)
def configure(self,value):
'''
......
......@@ -97,7 +97,7 @@ class IConfigurator(dict):
_doc_ = "undocumented"
def __init__(self, configurable, name, dependencies=None, default=None, label=None, widget=None):
def __init__(self, name, **kwargs):
'''
Initializes a configurator object.
......@@ -117,15 +117,15 @@ class IConfigurator(dict):
self._name = name
self._configurable = configurable
self._configurable = kwargs.get('configurable',None)
self._dependencies = dependencies if dependencies is not None else {}
self._dependencies = kwargs.get('dependencies',{})
self._default = default if default is not None else self.__class__._default
self._default = kwargs.get('default',self.__class__._default)
self._label = label if label is not None else " ".join(name.split('_')).strip()
self._label = kwargs.get('label'," ".join(name.split('_')).strip())
self._widget = widget if widget is not None else self.type
self._widget = kwargs.get('widget',self.type)
@property
def default(self):
......@@ -192,6 +192,10 @@ class IConfigurator(dict):
:note: this is an abstract method.
'''
def set_configurable(self,configurable):
self._configurable = configurable
def check_dependencies(self, configured):
'''
......
......@@ -44,7 +44,7 @@ class InputFileConfigurator(IConfigurator):
_default = ""
def __init__(self, configurable, name, wildcard="All files|*.*",**kwargs):
def __init__(self, name, wildcard="All files|*.*",**kwargs):
'''
Initializes the configurator object.
......@@ -56,7 +56,7 @@ class InputFileConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._wildcard = wildcard
......
......@@ -41,7 +41,7 @@ class IntegerConfigurator(IConfigurator):
_default = 0
def __init__(self, configurable, name, mini=None, maxi=None, choices=None, **kwargs):
def __init__(self, name, mini=None, maxi=None, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -56,7 +56,7 @@ class IntegerConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._mini = int(mini) if mini is not None else None
......
......@@ -50,7 +50,7 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
_default = "no interpolation"
def __init__(self, configurable, name, orders=None,**kwargs):
def __init__(self, name, orders=None,**kwargs):
'''
Initializes the configurator.
......@@ -61,7 +61,7 @@ class InterpolationOrderConfigurator(SingleChoiceConfigurator):
if orders is None:
orders = ["no interpolation","1st order","2nd order","3rd order","4th order","5th order"]
SingleChoiceConfigurator.__init__(self, configurable, name, choices=orders, **kwargs)
SingleChoiceConfigurator.__init__(self, name, choices=orders, **kwargs)
def configure(self, value):
'''
......
......@@ -60,7 +60,7 @@ class McStasParametersConfigurator(IConfigurator):
'sample_rotation_deg': 45.0,
'detector_height_m': 3.0}
def __init__(self, configurable, name, exclude=None, **kwargs):
def __init__(self, name, exclude=None, **kwargs):
'''
Initializes the configurator.
......@@ -71,7 +71,7 @@ class McStasParametersConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._exclude = exclude if exclude is not None else []
......
......@@ -43,7 +43,7 @@ class MultipleChoicesConfigurator(IConfigurator):
_default = []
def __init__(self, configurable, name, choices=None, nChoices=None, **kwargs):
def __init__(self, name, choices=None, nChoices=None, **kwargs):
'''
Initializes the configurator.
......@@ -55,7 +55,7 @@ class MultipleChoicesConfigurator(IConfigurator):
:type nChoices: int or None
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._choices = choices
......
......@@ -49,7 +49,7 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
_default = ''
def __init__(self, configurable, name, variables=None, **kwargs):
def __init__(self, name, variables=None, **kwargs):
'''
Initializes the configurator.
......@@ -60,7 +60,7 @@ class NetCDFInputFileConfigurator(InputFileConfigurator):
'''
# The base class constructor.
InputFileConfigurator.__init__(self, configurable, name, **kwargs)
InputFileConfigurator.__init__(self, name, **kwargs)
self._variables = variables if variables is not None else []
......
......@@ -44,7 +44,7 @@ class OutputDirectoryConfigurator(IConfigurator):
_default = os.getcwd()
def __init__(self, configurable, name, new=False, **kwargs):
def __init__(self, name, new=False, **kwargs):
'''
Initializes the configurator.
......@@ -54,7 +54,7 @@ class OutputDirectoryConfigurator(IConfigurator):
:type new: bool
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._new = new
......
......@@ -52,7 +52,7 @@ class OutputFilesConfigurator(IConfigurator):
_default = (os.path.join(tempfile.gettempdir(),"output"), ["netcdf"])
def __init__(self, configurable, name, formats=None, **kwargs):
def __init__(self, name, formats=None, **kwargs):
'''
Initializes the configurator.
......@@ -62,7 +62,7 @@ class OutputFilesConfigurator(IConfigurator):
:type formats: list of str
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._formats = formats if formats is not None else OutputFilesConfigurator._default[2]
......
......@@ -42,7 +42,7 @@ class PythonScriptConfigurator(InputFileConfigurator):
_default = ''
def __init__(self, configurable, name, variables=None, **kwargs):
def __init__(self, name, variables=None, **kwargs):
'''
Initializes the configurator.
......@@ -53,7 +53,7 @@ class PythonScriptConfigurator(InputFileConfigurator):
'''
# The base class constructor.
InputFileConfigurator.__init__(self, configurable, name, **kwargs)
InputFileConfigurator.__init__(self, name, **kwargs)
self._variables = variables if variables is not None else []
......
......@@ -45,7 +45,7 @@ class RangeConfigurator(IConfigurator):
_default = (0,10,1)
def __init__(self, configurable, name, valueType=int, includeLast=False, sort=False, toList=False, mini=None, maxi=None, **kwargs):
def __init__(self, name, valueType=int, includeLast=False, sort=False, toList=False, mini=None, maxi=None, **kwargs):
'''
Initializes the configurator.
......@@ -65,7 +65,7 @@ class RangeConfigurator(IConfigurator):
:type maxi: int, float or None
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._valueType = valueType
......
......@@ -41,7 +41,7 @@ class SingleChoiceConfigurator(IConfigurator):
_default = []
def __init__(self, configurable, name, choices=None, **kwargs):
def __init__(self, name, choices=None, **kwargs):
'''
Initializes the configurator.
......@@ -51,7 +51,7 @@ class SingleChoiceConfigurator(IConfigurator):
:type choices: list
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._choices = choices if choices is not None else []
......
......@@ -43,7 +43,7 @@ class StringConfigurator(IConfigurator):
_default = ""
def __init__(self, configurable, name, evalType=None, acceptNullString=True, **kwargs):
def __init__(self, name, evalType=None, acceptNullString=True, **kwargs):
'''
Initializes the configurator.
......@@ -55,7 +55,7 @@ class StringConfigurator(IConfigurator):
:type acceptNullString: bool
'''
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._evalType = evalType
......
......@@ -45,7 +45,7 @@ class VectorConfigurator(IConfigurator):
_default = [1.0,0.0,0.0]
def __init__(self, configurable, name, valueType=int, normalize=False, notNull=False, dimension=3, **kwargs):
def __init__(self, name, valueType=int, normalize=False, notNull=False, dimension=3, **kwargs):
'''
Initializes the configurator.
......@@ -62,7 +62,7 @@ class VectorConfigurator(IConfigurator):
'''
# The base class constructor.
IConfigurator.__init__(self, configurable, name, **kwargs)
IConfigurator.__init__(self, name, **kwargs)
self._valueType = valueType
......
......@@ -46,7 +46,7 @@ class WeightsConfigurator(SingleChoiceConfigurator):
_default = "equal"
def __init__(self, configurable, name, **kwargs):
def __init__(self, name, **kwargs):
'''
Initializes the configurator.
......@@ -54,7 +54,7 @@ class WeightsConfigurator(SingleChoiceConfigurator):
:type name: str
'''
SingleChoiceConfigurator.__init__(self, configurable, name, choices=ELEMENTS.numericProperties, **kwargs)
SingleChoiceConfigurator.__init__(self, name, choices=ELEMENTS.numericProperties, **kwargs)
def configure(self, value):
'''
......
......@@ -260,6 +260,7 @@ class IJob(Configurable):
#. parameters (dict): optional. If not None, the parameters with which the job file will be built.
"""
f = open(jobFile, 'w')
# The first line contains the call to the python executable. This is necessary for the file to
......
......@@ -9,14 +9,14 @@ class TestCCF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['instrument_resolution'] = ('gaussian', {'mu': 0.0, 'sigma': 10.0})
parameters['normalize'] = False
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0, 5, 0.1)})
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0.1, 5, 0.1)})
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'b_coherent'
job = REGISTRY['job']['ccf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,12 +9,12 @@ class TestCN(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['r_values'] = (0, 10, 1)
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
job = REGISTRY['job']['cn']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,13 +9,13 @@ class TestDCSF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['instrument_resolution'] = ('gaussian', {'mu': 0.0, 'sigma': 10.0})
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0, 5, 0.1)})
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0.1, 5, 0.1)})
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'b_coherent'
job = REGISTRY['job']['dcsf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,15 +9,15 @@ class TestDISF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['instrument_resolution'] = ('gaussian', {'mu': 0.0, 'sigma': 10.0})
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['projection'] = None
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0, 5, 0.1)})
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0.1, 5, 0.1)})
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'b_incoherent'
job = REGISTRY['job']['disf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,13 +9,13 @@ class TestDP(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['axis'] = 'c'
parameters['dr'] = 0.01
parameters['frames'] = (0, 10, 1)
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'equal'
job = REGISTRY['job']['dp']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,14 +9,14 @@ class TestEISF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['projection'] = None
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0, 5, 0.1)})
parameters['q_vectors'] = ('spherical_lattice', {'width': 0.1, 'n_vectors': 50, 'shells': (0.1, 5, 0.1)})
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'b_incoherent'
job = REGISTRY['job']['eisf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,6 +9,7 @@ class TestGACF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['normalize'] = False
......@@ -16,7 +17,6 @@ class TestGACF(UnitTest):
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['trajectory_variable'] = 'velocities'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'equal'
job = REGISTRY['job']['gacf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,6 +9,7 @@ class TestGDISF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['instrument_resolution'] = ('gaussian', {'mu': 0.0, 'sigma': 10.0})
......@@ -17,7 +18,6 @@ class TestGDISF(UnitTest):
parameters['q_shells'] = (0, 10, 1)
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'b_incoherent'
job = REGISTRY['job']['gdisf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,13 +9,13 @@ class TestMSD(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['projection'] = None
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'equal'
job = REGISTRY['job']['msd']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -11,7 +11,7 @@ class TestMVI(UnitTest):
parameters['display'] = False
parameters['frames'] = (0, 10, 1)
parameters['instrument'] = '../../../Data/McStas/Instruments/Simple_ToF_Flat_Sample.out'
parameters['options'] = {'ncount': 10000, 'dir': '/tmp/mcstas_output/29.09.2015-16:29:41'}
parameters['options'] = {'ncount': 10000, 'dir': '/tmp/mcstas_output/06.10.2015-17:23:53'}
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['parameters'] = {'beam_wavelength_Angs': 2.0, 'container_thickness_m': 5e-05, 'environment_radius_m': 0.025, 'sample_detector_distance_m': 4.0, 'container': '/users/pellegrini/workspace/MDANSE/Data/McStas/Samples/Al.laz', 'environment_thickness_m': 0.002, 'detector_height_m': 3.0, 'beam_resolution_meV': 0.1, 'sample_height_m': 0.05, 'sample_thickness_m': 0.001, 'environment': '/users/pellegrini/workspace/MDANSE/Data/McStas/Samples/Al.laz', 'sample_width_m': 0.02, 'sample_rotation_deg': 45.0}
parameters['sample_coh'] = '../../../Data/NetCDF/dcsf_prot.nc'
......
......@@ -9,6 +9,7 @@ class TestPACF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['grouping_level'] = 'atom'
parameters['normalize'] = False
......@@ -16,7 +17,6 @@ class TestPACF(UnitTest):
parameters['projection'] = None
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None
parameters['weights'] = 'equal'
job = REGISTRY['job']['pacf']()
self.assertNotRaises(job.run, parameters, status=False)
......
......@@ -9,12 +9,12 @@ class TestPDF(UnitTest):
def test(self):
parameters = {}
parameters['atom_selection'] = 'all'
parameters['atom_transmutation'] = None
parameters['frames'] = (0, 10, 1)
parameters['output_files'] = ('/tmp/output', ['netcdf'])
parameters['r_values'] = (0, 10, 1)
parameters['running_mode'] = ('monoprocessor', 1)
parameters['trajectory'] = '../../../Data/Trajectories/MMTK/waterbox_in_periodic_universe.nc'
parameters['transmutated_atoms'] = None