Skip to content
Open
Show file tree
Hide file tree
Changes from 8 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
4 changes: 2 additions & 2 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ concurrency:

jobs:
run-py-linter:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: [3.10.13]
Expand All @@ -33,7 +33,7 @@ jobs:

run-py-tests:
needs: run-py-linter
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
python-version:
Expand Down
9 changes: 9 additions & 0 deletions dist/js/basis/basis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ export declare class Basis {
get hashString(): string;
get atomicLabelsArray(): string[];
get elementsWithLabelsArray(): string[];
/**
* Strips any label associated with atomic symbol
* Possible labels:
* (1) Fe1, Fe11
* (2) Fe-a, Fe-b, Fe-1, Fe-1a
* (3) Fe_a, Fe_b, Fe_1, Fe_1a
* As of Mar 2025, only single digit numerical labels are allowed
*/
static stripLabelToGetElementSymbol: (elementWithLabel: string) => string;
/**
* Returns an array of strings with chemical elements and their atomic positions.
* E.g., ``` ['Si 0 0 0', 'Li 0.5 0.5 0.5']```
Expand Down
29 changes: 22 additions & 7 deletions dist/js/basis/basis.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ class Basis {
const clsInstance = new Basis(this.toJSON());
clsInstance.toStandardRepresentation();
const standardRep = clsInstance.elementsAndCoordinatesAndLabelsArray.map((entry) => {
const element = entry[0];
const coordinate = entry[1];
const atomicLabel = entry[2];
const [element, coordinate, atomicLabel] = entry;
const toleratedCoordinates = coordinate.map((x) => math_1.default.round(x, constants_1.HASH_TOLERANCE));
return `${element}${atomicLabel} ${toleratedCoordinates.join()}`;
});
Expand Down Expand Up @@ -367,10 +365,8 @@ class Basis {
* E.g., ``` ['Si 0 0 0', 'Li 0.5 0.5 0.5']```
*/
get atomicPositions() {
return this.elementsAndCoordinatesAndLabelsArray.map((entry, idx) => {
const element = entry[0];
const coordinate = entry[1];
const atomicLabel = this.atomicLabelsArray[idx];
return this.elementsAndCoordinatesAndLabelsArray.map((entry) => {
const [element, coordinate, atomicLabel] = entry;
return `${element}${atomicLabel} ${coordinate
.map((x) => underscore_string_1.default.sprintf("%14.9f", x).trim())
.join(" ")}`;
Expand Down Expand Up @@ -522,3 +518,22 @@ class Basis {
}
}
exports.Basis = Basis;
/**
* Strips any label associated with atomic symbol
* Possible labels:
* (1) Fe1, Fe11
* (2) Fe-a, Fe-b, Fe-1, Fe-1a
* (3) Fe_a, Fe_b, Fe_1, Fe_1a
* As of Mar 2025, only single digit numerical labels are allowed
*/
Basis.stripLabelToGetElementSymbol = (elementWithLabel) => {
// Strip anything after `-` or `_`
let elementSymbol = elementWithLabel.split(/[- _]/)[0];
// Exclude digit labels at the end of the symbol if present
elementSymbol = elementSymbol.replace(/\d+$/, "");
// Return symbol in title case
elementSymbol =
elementSymbol.charAt(0).toUpperCase() + elementSymbol.slice(1).toLowerCase();
// We can improve by validating element symbol matches one from the periodic table
return elementSymbol;
};
Loading
Loading