Skip to content

Commit

Permalink
ensure zeros in site formulae are printed as positive
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmyhill committed Nov 12, 2024
1 parent 2218ea5 commit 0352c24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions burnman/classes/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def site_formula(self, precision=2):
for i, site_occs in enumerate(self.site_occupancies):
formula += "["
for species, occ in site_occs.items():
if np.abs(occ) < 1.e-12:
occ = np.abs(occ)
formula += f"{species}{occ:0.{precision}f}"
formula += split_empty[i + 1]
return formula
Expand Down
2 changes: 1 addition & 1 deletion examples/example_fit_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
gt.set_composition(popt)

print("\nSite formula:")
print(gt.site_formula(2))
print(gt.site_formula(precision=2))

print(f"\nWeighted residual: {res:.3f}")
"""
Expand Down

0 comments on commit 0352c24

Please # to comment.