Skip to content

Commit

Permalink
chore: allow filter by compatible functionals
Browse files Browse the repository at this point in the history
  • Loading branch information
azech-hqs committed Aug 29, 2023
1 parent c9b8562 commit f150162
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/include/meta_properties/pseudopotential.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import _ from "underscore";
import { Property } from "../../property";

export class Pseudopotential extends Property {
static compatibleExchangeCorrelation = {
hse06: ["pbe", "hse06"],
};

get path() {
return this.prop("path");
}
Expand Down Expand Up @@ -68,11 +72,17 @@ export class Pseudopotential extends Property {
* @param {String} exchangeCorrelation.functional
*/
static filterRawDataByExchangeCorrelation(rawData, exchangeCorrelation) {
return rawData.filter((el) =>
Object.keys(exchangeCorrelation).reduce(
(mem, key) => mem && el.exchangeCorrelation[key] === exchangeCorrelation[key],
),
const { functional } = exchangeCorrelation;
const isCompatibleWithOther = Object.keys(this.compatibleExchangeCorrelation).includes(
functional,
);
return rawData.filter((item) => {
return isCompatibleWithOther
? this.compatibleExchangeCorrelation[functional].includes(
item.exchangeCorrelation?.functional,
)
: functional === item.exchangeCorrelation?.functional;
});
}

// filter unique (assuming that path is always unique)
Expand Down

0 comments on commit f150162

Please sign in to comment.