8000 Moving extract_atom types functoin from reader/xps to nexusutils/help… by RubelMozumder · Pull Request #94 · FAIRmat-NFDI/pynxtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Moving extract_atom types functoin from reader/xps to nexusutils/help… #94

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

Merged
merged 4 commits into from
Apr 21, 2023

Conversation

RubelMozumder
Copy link
Collaborator

…er module.

@coveralls
Copy link
cover 8000 alls commented Apr 20, 2023

Pull Request Test Coverage Report for Build 4765763654

  • 58 of 64 (90.63%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.2%) to 58.01%

Changes Missing Coverage Covered Lines Changed/Added Lines %
nexusutils/dataconverter/helpers.py 46 52 88.46%
Files with Coverage Reduction New Missed Lines %
nexusutils/dataconverter/helpers.py 1 95.89%
Totals Coverage Status
Change from base Build 4759275507: 0.2%
Covered Lines: 4700
Relevant Lines: 8102

💛 - Coveralls

@mkuehbach
Copy link
Collaborator

Handling of atoms does work which is logically unrelated to parsing so instead of placing these functions in the generic helpers.py better would be to make py file with a speaking name were all this atom handling is stored this file can be in the same place like helpers at the same level of the directory tree in this way one could then import it selectively where needed, I agree that such functions should be in the generic place for the dataconverter as it is indeed cross-reader

atom_types: set = set()
element: str = ""
# tested with "(C38H54S4)n(NaO2)5(CH4)NH3B"
for char in formula:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it compare with the solution in NOMAD? Any reason why we not take the same solution as the one there (https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-FAIR/-/blob/develop/nomad/parsing/nexus.py ase lib used below line # 320)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could use the the example their with pymatgen. The p 8000 oint is only to extract the chemical formula if we use pymatgen nexusutils will be havier. I think this is not a good practice. Frankly, I tried to use 'ase' lib or is their any function to do it, as we already have 'ase' in dependencies list.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact lines 343-345 are doing the job there. The question if this code should do the same or not? And also what Markus asked if and how 'D' is handled, etc.


test_chemical_formula = "(C38H54S4)n(NaO2)5(CH4)NH3B"
expected_atom_types = ['C', 'H', 'B', 'N', 'Na', 'O', 'S']

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have difference between our solution here and the ase based solution in NOMAD, please also add an example which shows how it should work where the another solution fails on!

def extract_atom_types(formula: str, mode: str = 'hill') -> Union[Set, List]:
def convert_to_hill(atoms_typ):
"""Convert list of atom into to hill."""
if not isinstance(atoms_typ, list) and isinstance(atoms_typ, set):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a check which catches the case when atoms_typ is empty or neither list nor set

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if atoms_typ has D (deuterium)?

"""

test_chemical_formula = "(C38H54S4)n(NaO2)5(CH4)NH3B"
expected_atom_types = ['C', 'H', 'B', 'N', 'Na', 'O', 'S']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should test with all words available in the Hill vocabulary

@RubelMozumder RubelMozumder force-pushed the XPS_update branch 2 times, most recently from 7e95749 to 8ceb132 Compare April 21, 2023 13:15
Copy link
Collaborator
@sanbrock sanbrock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

questions should be answered after the merge

@sanbrock sanbrock merged commit 6018a57 into master Apr 21, 2023
@RubelMozumder RubelMozumder deleted the XPS_update branch April 22, 2023 09:36
RubelMozumder added a commit that referenced this pull request Jun 28, 2023
#94)

* Moving extract_atom types functoin from reader/xps to nexusutils/helper module.

* Moving extract_atom types functoin from reader/xps to nexusutils/help

* Working on requested changes.

* Working on requested changes.

---------

Co-authored-by: RubelMozumder <rubelmozumder@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0