-
Notifications
You must be signed in to change notification settings - Fork 3
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
Feat: xyz file parsing - nAtoms & nLines to check formatting. Created… #52
base: epic/SOF-5386
Are you sure you want to change the base?
Conversation
… functions and tests
src/parsers/xyz.js
Outdated
@@ -140,10 +141,25 @@ function fromMaterial(materialOrConfig, fractional = false) { | |||
return fromBasis(basis, "%11.6f"); | |||
} | |||
|
|||
export function atomsCount(xyzFile) { | |||
const xyzArray = xyzFile.split(/\r?\n/); | |||
return Integer.parseInt(xyzArray[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getNumberOfAtomsByFileExtension
… for getting number of atoms in parsers
src/parsers/xyz.js
Outdated
import _ from "underscore"; | ||
import s from "underscore.string"; | ||
|
||
import { Basis } from "../basis/basis"; | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay i will look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return {...defaultMaterialConfig}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: utilize this function instead of defaultMaterialConfig
in code.
… functions and tests