Skip to content

Commit

Permalink
fix bug in create_sample where cells copied from other cells did not …
Browse files Browse the repository at this point in the history
…properly add in the additional electrode/electrolyte components unless the cell already had a component already
  • Loading branch information
jdbocarsly committed Jul 12, 2024
1 parent 0e099f8 commit 8860d75
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pydatalab/pydatalab/routes/v0_1/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,17 +396,16 @@ def _create_sample(
"negative_electrode",
"electrolyte",
):
if copied_doc.get(component):
existing_consituent_ids = [
constituent["item"].get("item_id", None)
for constituent in copied_doc[component]
]
copied_doc[component] += [
constituent
for constituent in sample_dict.get(component, [])
if constituent["item"].get("item_id", None) is None
or constituent["item"].get("item_id") not in existing_consituent_ids
]
existing_consituent_ids = [
constituent["item"].get("item_id", None)
for constituent in copied_doc[component]
]
copied_doc[component] += [
constituent
for constituent in sample_dict.get(component, [])
if constituent["item"].get("item_id", None) is None
or constituent["item"].get("item_id") not in existing_consituent_ids
]

sample_dict = copied_doc

Expand Down

0 comments on commit 8860d75

Please sign in to comment.