Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change: start materials.basis.coordinates.id enumeration from 0 instead of 1 #142

Merged
merged 5 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions express/parsers/apps/espresso/formats/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,8 @@ def initial_basis(self, text):
Example:
{
'units': 'angstrom',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [2.1095228, 1.49165, 3.6538]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [2.1095228, 1.49165, 3.6538]}]
}
"""
alat = self._get_alat(text)
Expand Down Expand Up @@ -436,14 +436,14 @@ def _basis_convergence(self, text):
[
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
},
...
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
}
]
"""
Expand All @@ -462,8 +462,8 @@ def _extract_basis_from_bfgs_blocks(self, text):
Example:
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
}
"""
basis = {"units": "crystal", "elements": [], "coordinates": []}
Expand Down
4 changes: 2 additions & 2 deletions express/parsers/apps/espresso/formats/xml/xml_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def final_basis(self):
Example:
{
'units': 'angstrom',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
}
"""
pass
4 changes: 2 additions & 2 deletions express/parsers/apps/espresso/formats/xml/xml_pre64.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def final_basis(self):
Example:
{
'units': 'angstrom',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
}
"""
elements, coordinates = [], []
Expand Down
8 changes: 4 additions & 4 deletions express/parsers/apps/vasp/formats/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def _basis_convergence(self, text, atom_names):
[
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
},
...
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.0, 0.0, 0.0]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.0, 0.0, 0.0]}]
}
]
"""
Expand Down
4 changes: 2 additions & 2 deletions express/parsers/apps/vasp/formats/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ def final_basis(self):
Example:
{
'units': 'angstrom',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [1.11, 0.78, 1.93]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [1.11, 0.78, 1.93]}]
}
"""
lattice = self.final_lattice_vectors()
Expand Down
8 changes: 4 additions & 4 deletions express/parsers/mixins/ionic.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ def initial_basis(self):
Example:
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.25, 0.25, 0.25]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.25, 0.25, 0.25]}]
}
"""
pass
Expand Down Expand Up @@ -81,8 +81,8 @@ def final_basis(self):
Example:
{
'units': 'crystal',
'elements': [{'id': 1, 'value': 'Si'}, {'id': 2, 'value': 'Si'}],
'coordinates': [{'id': 1, 'value': [0.0, 0.0, 0.0]}, {'id': 2, 'value': [0.25, 0.25, 0.25]}]
'elements': [{'id': 0, 'value': 'Si'}, {'id': 1, 'value': 'Si'}],
'coordinates': [{'id': 0, 'value': [0.0, 0.0, 0.0]}, {'id': 1, 'value': [0.25, 0.25, 0.25]}]
}
"""
pass
Expand Down
4 changes: 2 additions & 2 deletions express/parsers/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ def basis(self):
"""
return {
"units": "crystal",
"elements": [{"id": i + 1, "value": v.species_string} for i, v in enumerate(self.structure.sites)],
"coordinates": [{"id": i + 1, "value": v.frac_coords.tolist()} for i, v in enumerate(self.structure.sites)],
"elements": [{"id": i, "value": v.species_string} for i, v in enumerate(self.structure.sites)],
"coordinates": [{"id": i, "value": v.frac_coords.tolist()} for i, v in enumerate(self.structure.sites)],
}

def space_group_symbol(self):
Expand Down
2 changes: 1 addition & 1 deletion express/properties/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def to_array_with_ids(array):
Returns:
list
"""
return [{"id": index + 1, "value": value} for index, value in enumerate(array)]
return [{"id": index, "value": value} for index, value in enumerate(array)]
2 changes: 1 addition & 1 deletion tests/fixtures/data.py
Git LFS file not shown
2 changes: 1 addition & 1 deletion tests/fixtures/espresso/v5_4/references.py
Git LFS file not shown
8 changes: 4 additions & 4 deletions tests/fixtures/nwchem/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

BASIS = {
"units": "angstrom",
"elements": [{"id": 1, "value": "O"}, {"id": 2, "value": "H"}, {"id": 3, "value": "H"}],
"elements": [{"id": 0, "value": "O"}, {"id": 1, "value": "H"}, {"id": 2, "value": "H"}],
"coordinates": [
{"id": 1, "value": [0.00000000, 0.00000000, 0.22143053]},
{"id": 2, "value": [0.00000000, 1.43042809, -0.88572213]},
{"id": 3, "value": [0.00000000, -1.43042809, -0.88572213]},
{"id": 0, "value": [0.00000000, 0.00000000, 0.22143053]},
{"id": 1, "value": [0.00000000, 1.43042809, -0.88572213]},
{"id": 2, "value": [0.00000000, -1.43042809, -0.88572213]},
],
}
2 changes: 1 addition & 1 deletion tests/unit/properties/non_scalar/test_atomic_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
ATOMIC_FORCES = {
"units": "eV/angstrom",
"name": "atomic_forces",
"values": [{"id": 1, "value": [-3.9e-07, -2.4e-07, 0.0]}, {"id": 2, "value": [3.9e-07, 2.4e-07, 0.0]}],
"values": [{"id": 0, "value": [-3.9e-07, -2.4e-07, 0.0]}, {"id": 1, "value": [3.9e-07, 2.4e-07, 0.0]}],
}


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/properties/non_scalar/test_magnetic_moments.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
MAGNETIC_MOMENTS = {
"units": "uB",
"name": "magnetic_moments",
"values": [{"id": 1, "value": [0, 0, 1.235]}, {"id": 2, "value": [0, 0, -1.235]}],
"values": [{"id": 0, "value": [0, 0, 1.235]}, {"id": 1, "value": [0, 0, -1.235]}],
}


Expand Down
6 changes: 3 additions & 3 deletions tests/unit/properties/non_scalar/test_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def setUp(self):
def tearDown(self):
super().setUp()

@mock.patch("express.properties.workflow.os")
def test_pyml_workflow(self, mock_os):
mock_os.listdir.return_value = MOCK_BASENAMES
@mock.patch("express.properties.workflow.os.listdir")
def test_pyml_workflow(self, mock_os_listdir):
mock_os_listdir.return_value = MOCK_BASENAMES

name = NAME
parser = PARSER
Expand Down
Loading