Skip to content

Commit

Permalink
Fixing error mentioned by sandor.
Browse files Browse the repository at this point in the history
  • Loading branch information
RubelMozumder committed Dec 1, 2023
1 parent 7581787 commit e67380c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions pynxtools/dataconverter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def extract_atom_types(formula, mode='hill'):

return atom_types


# pylint: disable=too-many-branches
def transform_to_intended_dt(str_value: Any) -> Optional[Any]:
"""Transform string to the intended data type, if not then return str_value.
Expand Down Expand Up @@ -702,7 +702,11 @@ def transform_to_intended_dt(str_value: Any) -> Optional[Any]:
parts = str_value.split(sym)
modified_parts = []
for part in parts:
modified_parts.append(transform_to_intended_dt(part))
part = transform_to_intended_dt(part)
if (isinstance(part, int) or isinstance(part, float)):
modified_parts.append(part)
else:
return str_value
return transform_to_intended_dt(modified_parts)

return str_value
Expand Down
2 changes: 1 addition & 1 deletion pynxtools/dataconverter/readers/xrd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@units": ""}
},
"/ENTRY[entry]/INSTRUMENT[instrument]/SOURCE[source]/xray_tube_current": {"xrdml_1.5": {"value": "/xrdMeasurements/xrdMeasurement/incidentBeamPath/xRayTube/current",
"@units": ""}
"@units": "/xrdMeasurements/xrdMeasurement/incidentBeamPath/xRayTube/current/unit"}
},
"/ENTRY[entry]/INSTRUMENT[instrument]/SOURCE[source]/source_peak_wavelength": {"xrdml_1.5": {"value": "",
"@units": ""}
Expand Down
2 changes: 1 addition & 1 deletion pynxtools/dataconverter/readers/xrd/xrd_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def check_unit(unit: str):
"""
if unit is None:
return unit
unit_map = {'Angstrom': 'angstrom',
unit_map = {'Angstrom': '\u212B',
}
correct_unit = unit_map.get(unit, None)
if correct_unit is None:
Expand Down
2 changes: 1 addition & 1 deletion pynxtools/definitions
Submodule definitions updated 428 files
1 change: 1 addition & 0 deletions tests/dataconverter/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def listify_template(data_dict: Template):
('test', 'test'),
(['59', '3.00005', '498E-36'], np.array([59.0, 3.00005, 4.98e-34])),
('23 34 444 5000', np.array([23., 34., 444., 5000.])),
('xrd experiment','xrd experiment'),
(None, None),
])
def test_transform_to_intended_dt(input_data, expected_output):
Expand Down

0 comments on commit e67380c

Please sign in to comment.