Skip to content

Commit d441795

Browse files
committed
Refactor validation imports and remove unused DataTypes references
1 parent 6a52ea9 commit d441795

File tree

22 files changed

+13
-130
lines changed

22 files changed

+13
-130
lines changed

src/easydiffraction/analysis/categories/aliases.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from easydiffraction.core.category import CategoryItem
1111
from easydiffraction.core.parameters import StringDescriptor
1212
from easydiffraction.core.validation import AttributeSpec
13-
from easydiffraction.core.validation import DataTypes
1413
from easydiffraction.core.validation import RegexValidator
1514
from easydiffraction.io.cif.handler import CifHandler
1615

@@ -40,7 +39,6 @@ def __init__(
4039
description='...',
4140
value_spec=AttributeSpec(
4241
value=label,
43-
type_=DataTypes.STRING,
4442
default='...',
4543
content_validator=RegexValidator(pattern=r'^[A-Za-z_][A-Za-z0-9_]*$'),
4644
),
@@ -55,7 +53,6 @@ def __init__(
5553
description='...',
5654
value_spec=AttributeSpec(
5755
value=param_uid,
58-
type_=DataTypes.STRING,
5956
default='...',
6057
content_validator=RegexValidator(pattern=r'^[A-Za-z_][A-Za-z0-9_]*$'),
6158
),

src/easydiffraction/analysis/categories/constraints.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from easydiffraction.core.parameters import StringDescriptor
1212
from easydiffraction.core.singletons import ConstraintsHandler
1313
from easydiffraction.core.validation import AttributeSpec
14-
from easydiffraction.core.validation import DataTypes
1514
from easydiffraction.core.validation import RegexValidator
1615
from easydiffraction.io.cif.handler import CifHandler
1716

@@ -37,7 +36,6 @@ def __init__(
3736
description='...',
3837
value_spec=AttributeSpec(
3938
value=lhs_alias,
40-
type_=DataTypes.STRING,
4139
default='...',
4240
content_validator=RegexValidator(pattern=r'.*'),
4341
),
@@ -52,7 +50,6 @@ def __init__(
5250
description='...',
5351
value_spec=AttributeSpec(
5452
value=rhs_expr,
55-
type_=DataTypes.STRING,
5653
default='...',
5754
content_validator=RegexValidator(pattern=r'.*'),
5855
),

src/easydiffraction/analysis/categories/joint_fit_experiments.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from easydiffraction.core.parameters import NumericDescriptor
1212
from easydiffraction.core.parameters import StringDescriptor
1313
from easydiffraction.core.validation import AttributeSpec
14-
from easydiffraction.core.validation import DataTypes
1514
from easydiffraction.core.validation import RangeValidator
1615
from easydiffraction.core.validation import RegexValidator
1716
from easydiffraction.io.cif.handler import CifHandler
@@ -38,7 +37,6 @@ def __init__(
3837
description='...',
3938
value_spec=AttributeSpec(
4039
value=id,
41-
type_=DataTypes.STRING,
4240
default='...',
4341
content_validator=RegexValidator(pattern=r'^[A-Za-z_][A-Za-z0-9_]*$'),
4442
),
@@ -53,7 +51,6 @@ def __init__(
5351
description='...',
5452
value_spec=AttributeSpec(
5553
value=weight,
56-
type_=DataTypes.NUMERIC,
5754
default=0.0,
5855
content_validator=RangeValidator(),
5956
),

src/easydiffraction/experiments/categories/background/chebyshev.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from easydiffraction.core.parameters import Parameter
1919
from easydiffraction.core.parameters import StringDescriptor
2020
from easydiffraction.core.validation import AttributeSpec
21-
from easydiffraction.core.validation import DataTypes
2221
from easydiffraction.core.validation import RangeValidator
2322
from easydiffraction.core.validation import RegexValidator
2423
from easydiffraction.experiments.categories.background.base import BackgroundBase
@@ -50,7 +49,6 @@ def __init__(
5049
name='id',
5150
description='Identifier for this background polynomial term.',
5251
value_spec=AttributeSpec(
53-
type_=DataTypes.STRING,
5452
value=id,
5553
default='0',
5654
# TODO: the following pattern is valid for dict key
@@ -69,7 +67,6 @@ def __init__(
6967
description='Order used in a Chebyshev polynomial background term',
7068
value_spec=AttributeSpec(
7169
value=order,
72-
type_=DataTypes.NUMERIC,
7370
default=0.0,
7471
content_validator=RangeValidator(),
7572
),
@@ -84,7 +81,6 @@ def __init__(
8481
description='Coefficient used in a Chebyshev polynomial background term',
8582
value_spec=AttributeSpec(
8683
value=coef,
87-
type_=DataTypes.NUMERIC,
8884
default=0.0,
8985
content_validator=RangeValidator(),
9086
),

src/easydiffraction/experiments/categories/background/line_segment.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from easydiffraction.core.parameters import Parameter
1818
from easydiffraction.core.parameters import StringDescriptor
1919
from easydiffraction.core.validation import AttributeSpec
20-
from easydiffraction.core.validation import DataTypes
2120
from easydiffraction.core.validation import RangeValidator
2221
from easydiffraction.core.validation import RegexValidator
2322
from easydiffraction.experiments.categories.background.base import BackgroundBase
@@ -43,7 +42,6 @@ def __init__(
4342
name='id',
4443
description='Identifier for this background line segment.',
4544
value_spec=AttributeSpec(
46-
type_=DataTypes.STRING,
4745
value=id,
4846
default='0',
4947
# TODO: the following pattern is valid for dict key
@@ -65,7 +63,6 @@ def __init__(
6563
),
6664
value_spec=AttributeSpec(
6765
value=x,
68-
type_=DataTypes.NUMERIC,
6966
default=0.0,
7067
content_validator=RangeValidator(),
7168
),
@@ -84,7 +81,6 @@ def __init__(
8481
),
8582
value_spec=AttributeSpec(
8683
value=y,
87-
type_=DataTypes.NUMERIC,
8884
default=0.0,
8985
content_validator=RangeValidator(),
9086
), # TODO: rename to intensity

src/easydiffraction/experiments/categories/data/bragg_pd.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from easydiffraction.core.parameters import NumericDescriptor
1111
from easydiffraction.core.parameters import StringDescriptor
1212
from easydiffraction.core.validation import AttributeSpec
13-
from easydiffraction.core.validation import DataTypes
1413
from easydiffraction.core.validation import MembershipValidator
1514
from easydiffraction.core.validation import RangeValidator
1615
from easydiffraction.core.validation import RegexValidator
@@ -29,7 +28,6 @@ def __init__(self, **kwargs):
2928
name='point_id',
3029
description='Identifier for this data point in the dataset.',
3130
value_spec=AttributeSpec(
32-
type_=DataTypes.STRING,
3331
default='0',
3432
# TODO: the following pattern is valid for dict key
3533
# (keywords are not checked). CIF label is less strict.
@@ -46,7 +44,6 @@ def __init__(self, **kwargs):
4644
name='d_spacing',
4745
description='d-spacing value corresponding to this data point.',
4846
value_spec=AttributeSpec(
49-
type_=DataTypes.NUMERIC,
5047
default=0.0,
5148
content_validator=RangeValidator(ge=0),
5249
),
@@ -60,7 +57,6 @@ def __init__(self, **kwargs):
6057
name='intensity_meas',
6158
description='Intensity recorded at each measurement point as a function of angle/time',
6259
value_spec=AttributeSpec(
63-
type_=DataTypes.NUMERIC,
6460
default=0.0,
6561
content_validator=RangeValidator(ge=0),
6662
),
@@ -75,7 +71,6 @@ def __init__(self, **kwargs):
7571
name='intensity_meas_su',
7672
description='Standard uncertainty of the measured intensity at this data point.',
7773
value_spec=AttributeSpec(
78-
type_=DataTypes.NUMERIC,
7974
default=1.0,
8075
content_validator=RangeValidator(ge=0),
8176
),
@@ -90,7 +85,6 @@ def __init__(self, **kwargs):
9085
name='intensity_calc',
9186
description='Intensity value for a computed diffractogram at this data point.',
9287
value_spec=AttributeSpec(
93-
type_=DataTypes.NUMERIC,
9488
default=0.0,
9589
content_validator=RangeValidator(ge=0),
9690
),
@@ -104,7 +98,6 @@ def __init__(self, **kwargs):
10498
name='intensity_bkg',
10599
description='Intensity value for a computed background at this data point.',
106100
value_spec=AttributeSpec(
107-
type_=DataTypes.NUMERIC,
108101
default=0.0,
109102
content_validator=RangeValidator(ge=0),
110103
),
@@ -118,7 +111,6 @@ def __init__(self, **kwargs):
118111
name='calc_status',
119112
description='Status code of the data point in the calculation process.',
120113
value_spec=AttributeSpec(
121-
type_=DataTypes.STRING,
122114
default='incl', # TODO: Make Enum
123115
content_validator=MembershipValidator(allowed=['incl', 'excl']),
124116
),
@@ -169,7 +161,6 @@ def __init__(self, **kwargs):
169161
name='two_theta',
170162
description='Measured 2θ diffraction angle.',
171163
value_spec=AttributeSpec(
172-
type_=DataTypes.NUMERIC,
173164
default=0.0,
174165
content_validator=RangeValidator(ge=0, le=180),
175166
),
@@ -196,7 +187,6 @@ def __init__(self, **kwargs):
196187
name='time_of_flight',
197188
description='Measured time for time-of-flight neutron measurement.',
198189
value_spec=AttributeSpec(
199-
type_=DataTypes.NUMERIC,
200190
default=0.0,
201191
content_validator=RangeValidator(ge=0),
202192
),

src/easydiffraction/experiments/categories/data/bragg_sc.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from easydiffraction.core.parameters import NumericDescriptor
1111
from easydiffraction.core.parameters import StringDescriptor
1212
from easydiffraction.core.validation import AttributeSpec
13-
from easydiffraction.core.validation import DataTypes
1413
from easydiffraction.core.validation import RangeValidator
1514
from easydiffraction.core.validation import RegexValidator
1615
from easydiffraction.io.cif.handler import CifHandler
@@ -30,7 +29,6 @@ def __init__(self) -> None:
3029
name='id',
3130
description='Identifier of the reflection.',
3231
value_spec=AttributeSpec(
33-
type_=DataTypes.STRING,
3432
default='0',
3533
# TODO: the following pattern is valid for dict key
3634
# (keywords are not checked). CIF label is less strict.
@@ -47,7 +45,6 @@ def __init__(self) -> None:
4745
name='d_spacing',
4846
description='The distance between lattice planes in the crystal for this reflection.',
4947
value_spec=AttributeSpec(
50-
type_=DataTypes.NUMERIC,
5148
default=0.0,
5249
content_validator=RangeValidator(ge=0),
5350
),
@@ -62,7 +59,6 @@ def __init__(self) -> None:
6259
name='sin_theta_over_lambda',
6360
description='The sin(θ)/λ value for this reflection.',
6461
value_spec=AttributeSpec(
65-
type_=DataTypes.NUMERIC,
6662
default=0.0,
6763
content_validator=RangeValidator(ge=0),
6864
),
@@ -77,7 +73,6 @@ def __init__(self) -> None:
7773
name='index_h',
7874
description='Miller index h of a measured reflection.',
7975
value_spec=AttributeSpec(
80-
type_=DataTypes.NUMERIC,
8176
default=0.0,
8277
content_validator=RangeValidator(),
8378
),
@@ -91,7 +86,6 @@ def __init__(self) -> None:
9186
name='index_k',
9287
description='Miller index k of a measured reflection.',
9388
value_spec=AttributeSpec(
94-
type_=DataTypes.NUMERIC,
9589
default=0.0,
9690
content_validator=RangeValidator(),
9791
),
@@ -105,7 +99,6 @@ def __init__(self) -> None:
10599
name='index_l',
106100
description='Miller index l of a measured reflection.',
107101
value_spec=AttributeSpec(
108-
type_=DataTypes.NUMERIC,
109102
default=0.0,
110103
content_validator=RangeValidator(),
111104
),
@@ -119,7 +112,6 @@ def __init__(self) -> None:
119112
name='intensity_meas',
120113
description=' The intensity of the reflection derived from the measurements.',
121114
value_spec=AttributeSpec(
122-
type_=DataTypes.NUMERIC,
123115
default=0.0,
124116
content_validator=RangeValidator(ge=0),
125117
),
@@ -133,7 +125,6 @@ def __init__(self) -> None:
133125
name='intensity_meas_su',
134126
description='Standard uncertainty of the measured intensity.',
135127
value_spec=AttributeSpec(
136-
type_=DataTypes.NUMERIC,
137128
default=0.0,
138129
content_validator=RangeValidator(ge=0),
139130
),
@@ -147,7 +138,6 @@ def __init__(self) -> None:
147138
name='intensity_calc',
148139
description='The intensity of the reflection calculated from the atom site data.',
149140
value_spec=AttributeSpec(
150-
type_=DataTypes.NUMERIC,
151141
default=0.0,
152142
content_validator=RangeValidator(ge=0),
153143
),
@@ -161,7 +151,6 @@ def __init__(self) -> None:
161151
name='wavelength',
162152
description='The mean wavelength of radiation used to measure this reflection.',
163153
value_spec=AttributeSpec(
164-
type_=DataTypes.NUMERIC,
165154
default=0.0,
166155
content_validator=RangeValidator(ge=0),
167156
),

src/easydiffraction/experiments/categories/data/total_pd.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from easydiffraction.core.parameters import NumericDescriptor
1212
from easydiffraction.core.parameters import StringDescriptor
1313
from easydiffraction.core.validation import AttributeSpec
14-
from easydiffraction.core.validation import DataTypes
1514
from easydiffraction.core.validation import MembershipValidator
1615
from easydiffraction.core.validation import RangeValidator
1716
from easydiffraction.core.validation import RegexValidator
@@ -32,7 +31,6 @@ def __init__(self) -> None:
3231
name='point_id',
3332
description='Identifier for this data point in the dataset.',
3433
value_spec=AttributeSpec(
35-
type_=DataTypes.STRING,
3634
default='0',
3735
content_validator=RegexValidator(pattern=r'^[A-Za-z0-9_]*$'),
3836
),
@@ -46,7 +44,6 @@ def __init__(self) -> None:
4644
name='r',
4745
description='Interatomic distance in real space.',
4846
value_spec=AttributeSpec(
49-
type_=DataTypes.NUMERIC,
5047
default=0.0,
5148
content_validator=RangeValidator(ge=0),
5249
),
@@ -61,7 +58,6 @@ def __init__(self) -> None:
6158
name='g_r_meas',
6259
description='Measured pair distribution function G(r).',
6360
value_spec=AttributeSpec(
64-
type_=DataTypes.NUMERIC,
6561
default=0.0,
6662
),
6763
cif_handler=CifHandler(
@@ -74,7 +70,6 @@ def __init__(self) -> None:
7470
name='g_r_meas_su',
7571
description='Standard uncertainty of measured G(r).',
7672
value_spec=AttributeSpec(
77-
type_=DataTypes.NUMERIC,
7873
default=0.0,
7974
content_validator=RangeValidator(ge=0),
8075
),
@@ -88,7 +83,6 @@ def __init__(self) -> None:
8883
name='g_r_calc',
8984
description='Calculated pair distribution function G(r).',
9085
value_spec=AttributeSpec(
91-
type_=DataTypes.NUMERIC,
9286
default=0.0,
9387
),
9488
cif_handler=CifHandler(
@@ -101,7 +95,6 @@ def __init__(self) -> None:
10195
name='calc_status',
10296
description='Status code of the data point in calculation.',
10397
value_spec=AttributeSpec(
104-
type_=DataTypes.STRING,
10598
default='incl',
10699
content_validator=MembershipValidator(allowed=['incl', 'excl']),
107100
),

src/easydiffraction/experiments/categories/excluded_regions.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from easydiffraction.core.parameters import NumericDescriptor
1212
from easydiffraction.core.parameters import StringDescriptor
1313
from easydiffraction.core.validation import AttributeSpec
14-
from easydiffraction.core.validation import DataTypes
1514
from easydiffraction.core.validation import RangeValidator
1615
from easydiffraction.core.validation import RegexValidator
1716
from easydiffraction.io.cif.handler import CifHandler
@@ -36,7 +35,6 @@ def __init__(
3635
name='id',
3736
description='Identifier for this excluded region.',
3837
value_spec=AttributeSpec(
39-
type_=DataTypes.STRING,
4038
value=id,
4139
default='0',
4240
# TODO: the following pattern is valid for dict key
@@ -55,7 +53,6 @@ def __init__(
5553
description='Start of the excluded region.',
5654
value_spec=AttributeSpec(
5755
value=start,
58-
type_=DataTypes.NUMERIC,
5956
default=0.0,
6057
content_validator=RangeValidator(),
6158
),
@@ -70,7 +67,6 @@ def __init__(
7067
description='End of the excluded region.',
7168
value_spec=AttributeSpec(
7269
value=end,
73-
type_=DataTypes.NUMERIC,
7470
default=0.0,
7571
content_validator=RangeValidator(),
7672
),

0 commit comments

Comments
 (0)