Skip to content

Commit e49c142

Browse files
committed
Enhances experiment class documentation
1 parent d8d2a46 commit e49c142

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

src/easydiffraction/experiments/experiments.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515

1616
class Experiments(DatablockCollection):
17-
"""Collection manager for multiple Experiment instances."""
17+
"""Collection of Experiment data blocks.
18+
19+
Provides convenience constructors for common creation patterns and
20+
helper methods for simple presentation of collection contents.
21+
"""
1822

1923
def __init__(self) -> None:
2024
super().__init__(item_type=ExperimentBase)
@@ -25,13 +29,21 @@ def __init__(self) -> None:
2529

2630
@typechecked
2731
def add_from_cif_path(self, cif_path: str):
28-
"""Add a new experiment from a CIF file path."""
32+
"""Add an experiment from a CIF file path.
33+
34+
Args:
35+
cif_path: Path to a CIF document.
36+
"""
2937
experiment = ExperimentFactory.create(cif_path=cif_path)
3038
self.add(experiment)
3139

3240
@typechecked
3341
def add_from_cif_str(self, cif_str: str):
34-
"""Add a new experiment from CIF file content (string)."""
42+
"""Add an experiment from a CIF string.
43+
44+
Args:
45+
cif_str: Full CIF document as a string.
46+
"""
3547
experiment = ExperimentFactory.create(cif_str=cif_str)
3648
self.add(experiment)
3749

@@ -45,7 +57,16 @@ def add_from_data_path(
4557
radiation_probe: str = RadiationProbeEnum.default().value,
4658
scattering_type: str = ScatteringTypeEnum.default().value,
4759
):
48-
"""Add a new experiment from a data file path."""
60+
"""Add an experiment from a data file path.
61+
62+
Args:
63+
name: Experiment identifier.
64+
data_path: Path to the measured data file.
65+
sample_form: Sample form (powder or single crystal).
66+
beam_mode: Beam mode (constant wavelength or TOF).
67+
radiation_probe: Radiation probe (neutron or xray).
68+
scattering_type: Scattering type (bragg or total).
69+
"""
4970
experiment = ExperimentFactory.create(
5071
name=name,
5172
data_path=data_path,
@@ -65,7 +86,15 @@ def add_without_data(
6586
radiation_probe: str = RadiationProbeEnum.default().value,
6687
scattering_type: str = ScatteringTypeEnum.default().value,
6788
):
68-
"""Add a new experiment without any data file."""
89+
"""Add an experiment without associating a data file.
90+
91+
Args:
92+
name: Experiment identifier.
93+
sample_form: Sample form (powder or single crystal).
94+
beam_mode: Beam mode (constant wavelength or TOF).
95+
radiation_probe: Radiation probe (neutron or xray).
96+
scattering_type: Scattering type (bragg or total).
97+
"""
6998
experiment = ExperimentFactory.create(
7099
name=name,
71100
sample_form=sample_form,
@@ -77,6 +106,7 @@ def add_without_data(
77106

78107
@typechecked
79108
def remove(self, name: str) -> None:
109+
"""Remove an experiment by name if it exists."""
80110
if name in self:
81111
del self[name]
82112

@@ -85,9 +115,11 @@ def remove(self, name: str) -> None:
85115
# ------------
86116

87117
def show_names(self) -> None:
118+
"""Print the list of experiment names."""
88119
print(paragraph('Defined experiments' + ' 🔬'))
89120
print(self.names)
90121

91122
def show_params(self) -> None:
123+
"""Print parameters for each experiment in the collection."""
92124
for exp in self.values():
93125
exp.show_params()

0 commit comments

Comments
 (0)