Skip to content

Commit

Permalink
Changed coefficient to str
Browse files Browse the repository at this point in the history
  • Loading branch information
hampusnasstrom committed Nov 8, 2024
1 parent da73e46 commit 668e98f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/perovskite_solar_cell_database/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class PerovskiteIonComponent(SystemComponent, PerovskiteIonSection):
)
)
coefficient = Quantity(
type=float,
type=str,
description='The stoichiometric coefficient',
a_eln=ELNAnnotation(component=ELNComponentEnum.NumberEditQuantity),
shape=[],
Expand Down Expand Up @@ -831,12 +831,10 @@ def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None:
self.short_form += ion.abbreviation
if ion.coefficient is None:
continue
if ion.coefficient == 1:
if ion.coefficient == '1':
coefficient_str = ''
elif ion.coefficient == int(ion.coefficient):
coefficient_str = str(int(ion.coefficient))
else:
coefficient_str = f'{ion.coefficient:.2}'
coefficient_str = ion.coefficient
self.long_form += f'{ion.abbreviation}{coefficient_str}'
if not isinstance(ion.molecular_formula, str):
continue
Expand Down

0 comments on commit 668e98f

Please sign in to comment.