Feat: xyz file parsing - nAtoms & nLines to check formatting. Created…#52
Feat: xyz file parsing - nAtoms & nLines to check formatting. Created…#52adewyer wants to merge 13 commits intoepic/SOF-5386from
Conversation
… functions and tests
src/parsers/xyz.js
Outdated
|
|
||
| export function atomsCount(xyzFile) { | ||
| const xyzArray = xyzFile.split(/\r?\n/); | ||
| return Integer.parseInt(xyzArray[0]); |
There was a problem hiding this comment.
- Why do we even need this function, if all this does is just split on newlines? This is not specific to XYZ format, is it?
- No docstring, explanation of the expected behavior
There was a problem hiding this comment.
The first line of an xyz file contains the number of atoms. So we split the string by new lines and then return the first new line to get the number of atoms in the file.
src/parsers/xyz.js
Outdated
| const content = xyzFile.split(/\r?\n/); | ||
| if (!content[-1]) { | ||
| content.pop(); | ||
| } |
There was a problem hiding this comment.
Not sure what's happening above - no explanation either.
…nd converting to poscar to made instead of web-app
src/parsers/parsers.js
Outdated
| * @param {String} fileContent | ||
| * @returns {Number} | ||
| */ | ||
| export function getAtomsInFileByExtension(fileExtension, fileContent) { |
There was a problem hiding this comment.
getNumberOfAtomsByFileExtension
… for getting number of atoms in parsers
src/parsers/xyz.js
Outdated
| import { ConstrainedBasis } from "../basis/constrained_basis"; | ||
| import { Lattice } from "../lattice/lattice"; | ||
| // eslint-disable-next-line import/no-cycle | ||
| import { defaultMaterialConfig } from "../material"; |
There was a problem hiding this comment.
I understand your comment above, but we should not be introducing circular dependencies with new code. It's usually a sign of not having a correct placement of the code
src/parsers/xyz.js
Outdated
| const xyzBasis = xyzArrayBasisOnly.join("\n"); | ||
| xyzConfig.basis = toBasisConfig(xyzBasis); | ||
| xyzConfig.basis.units = "cartesian"; | ||
| return poscar.toPoscar(xyzConfig); |
There was a problem hiding this comment.
The placement of this function seems to be bad at the moment, hence the circular dependency. We should move this functionality to resolve the problem - maybe to top-level of parsers?
src/parsers/parsers.js
Outdated
| @@ -1,11 +1,47 @@ | |||
| // eslint-disable-next-line import/no-cycle | |||
| import { defaultMaterialConfig } from "../material"; | |||
There was a problem hiding this comment.
Moving the xyzToPoscar function from parsers/xyz.js to this file fixed the import xyz circular dependency, but created one for defaultMaterialConfig. Previously this circular dependency was noted inside parsers/xyz.js
a7520d7 to
78572e9
Compare
|
Not sure why CICD tests are failing. Everything passes locally Basis Cell Primitive Cell AtomicConstraints Lattice Lattice Bravais Lattice Reciprocal Lattice Vectors Parsers:Espresso Parsers:XYZ Parsers.POSCAR Parsers:XYZ Parsers:CombinatorialBasis Tools:Basis Tools:Supercell Tools:Surface 56 passing (105ms) |
| @@ -18,6 +18,8 @@ jobs: | |||
| steps: | |||
There was a problem hiding this comment.
Fixes from @tjduigna to fix CICD test failures caused by git lfs not pulling test files.
| }, | ||
| lattice: { | ||
| // Primitive cell for Diamond FCC Silicon at ambient conditions | ||
| type: LATTICE_TYPE.FCC, |
There was a problem hiding this comment.
I suspect the fact that we are using LATTICE_TYPE here and in the Lattice, and then import Lattice inside Material could lead to circular dependency which could lead to the problem with tests for https://github.com/Exabyte-io/exabyte-stack/pull/235/files#r805085142
There was a problem hiding this comment.
okay i will look into this.
There was a problem hiding this comment.
We saw these same errors prior to me moving default materials out of material.
Previously we imported both LATTICE_TYPE & LATTICE into material.js. Wouldn't that lead to the same circular error?
| * @returns {Object} | ||
| */ | ||
| export function getDefaultMaterialConfig() { | ||
| return defaultMaterialConfig; |
There was a problem hiding this comment.
return {...defaultMaterialConfig}
There was a problem hiding this comment.
Note: utilize this function instead of defaultMaterialConfig in code.
… functions and tests