diff --git a/src/easyreflectometry/project.py b/src/easyreflectometry/project.py index 4480b828..883edf8b 100644 --- a/src/easyreflectometry/project.py +++ b/src/easyreflectometry/project.py @@ -23,8 +23,8 @@ from easyreflectometry.model import ModelCollection from easyreflectometry.model import PercentageFhwm from easyreflectometry.sample import Layer -from easyreflectometry.sample import MaterialCollection from easyreflectometry.sample import Material +from easyreflectometry.sample import MaterialCollection from easyreflectometry.sample import Multilayer from easyreflectometry.sample import Sample from easyreflectometry.sample.collections.base_collection import BaseCollection @@ -284,18 +284,15 @@ def default_model(self): layers = [ Layer(material=self._materials[0], thickness=0.0, roughness=0.0, name='Vacuum Layer'), - Layer(material=self._materials[1], thickness=100.0, roughness=3.0, name='Multi-layer'), + Layer(material=self._materials[1], thickness=100.0, roughness=3.0, name='D2O Layer'), Layer(material=self._materials[2], thickness=0.0, roughness=1.2, name='Si Layer'), ] assemblies = [ Multilayer(layers[0], name='Superphase'), - Multilayer(layers[1], name='Multi-layer'), + Multilayer(layers[1], name='D2O'), Multilayer(layers[2], name='Subphase'), ] sample = Sample(*assemblies) - sample[0].layers[0].thickness.enabled = False - sample[0].layers[0].roughness.enabled = False - sample[-1].layers[-1].thickness.enabled = False model = Model(sample=sample) self.models = ModelCollection([model]) diff --git a/src/easyreflectometry/sample/collections/sample.py b/src/easyreflectometry/sample/collections/sample.py index 626aff6d..12394474 100644 --- a/src/easyreflectometry/sample/collections/sample.py +++ b/src/easyreflectometry/sample/collections/sample.py @@ -49,6 +49,7 @@ def __init__( if not issubclass(type(assembly), BaseAssembly): raise ValueError('The elements must be an Assembly.') super().__init__(name, interface, unique_name=unique_name, *assemblies, **kwargs) + self._disable_changes_to_outermost_layers() def add_assembly(self, assembly: Optional[BaseAssembly] = None): """Add an assembly to the sample. diff --git a/tests/sample/collections/test_sample.py b/tests/sample/collections/test_sample.py index 1cca441a..fb9955bf 100644 --- a/tests/sample/collections/test_sample.py +++ b/tests/sample/collections/test_sample.py @@ -51,7 +51,7 @@ def test_add_assembly(self): # Expect assert_equal(p[0].name, 'EasyMultilayer') assert_equal(p[1].name, 'EasyMultilayer') - assert_equal(p[2].name, 'New EasyMultilayer') + assert_equal(p[2].name, 'EasyMultilayer added') assert_equal(p[3].name, 'EasySurfactantLayer') p._enable_changes_to_outermost_layers.assert_called() p._disable_changes_to_outermost_layers.assert_called() diff --git a/tests/test_project.py b/tests/test_project.py index 8edd4de6..095b1581 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -30,8 +30,8 @@ def test_constructor(self): # Expect assert project._info == { - 'name': 'Example Project', - 'short_description': 'reflectometry, 1D', + 'name': 'ExampleProject', + 'short_description': 'Reflectometry, 1D', 'samples': 'None', 'experiments': 'None', 'modified': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'), @@ -78,8 +78,8 @@ def test_reset(self): # Expect assert project._info == { - 'name': 'Example Project', - 'short_description': 'reflectometry, 1D', + 'name': 'ExampleProject', + 'short_description': 'Reflectometry, 1D', 'samples': 'None', 'experiments': 'None', 'modified': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'), @@ -222,7 +222,7 @@ def test_path_json(self, tmp_path): project.set_path_project_parent(tmp_path) # Then Expect - assert project.path_json == Path(tmp_path) / 'Example Project' / 'project.json' + assert project.path_json == Path(tmp_path) / 'ExampleProject' / 'project.json' def test_add_material(self): # When @@ -270,8 +270,8 @@ def test_default_info(self): # Expect assert info == { - 'name': 'Example Project', - 'short_description': 'reflectometry, 1D', + 'name': 'ExampleProject', + 'short_description': 'Reflectometry, 1D', 'samples': 'None', 'experiments': 'None', 'modified': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'), @@ -294,8 +294,8 @@ def test_as_dict(self): 'with_experiments', ] assert project_dict['info'] == { - 'name': 'Example Project', - 'short_description': 'reflectometry, 1D', + 'name': 'ExampleProject', + 'short_description': 'Reflectometry, 1D', 'samples': 'None', 'experiments': 'None', 'modified': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'), @@ -491,19 +491,19 @@ def test_create(self, tmp_path): project = Project() project.set_path_project_parent(tmp_path) project._info['modified'] = 'modified' - project._info['name'] = 'Test Project' + project._info['name'] = 'TestProject' # Then project.create() # Expect - assert project.path == tmp_path / 'Test Project' + assert project.path == tmp_path / 'TestProject' assert project.path.exists() assert (project.path / 'experiments').exists() assert project.created is True assert project._info == { - 'name': 'Test Project', - 'short_description': 'reflectometry, 1D', + 'name': 'TestProject', + 'short_description': 'Reflectometry, 1D', 'samples': 'None', 'experiments': 'None', 'modified': datetime.datetime.now().strftime('%d.%m.%Y %H:%M'),