Skip to content

Improve speed of quantity stringification #2090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions docs/releasehistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
### Behavior changes

### Bugfixes

- [PR #2052](https://github.com/openforcefield/openff-toolkit/pull/2052): Fixes bug where `Topology.from_pdb` couldn't load NH4+ ([Issue #2051](https://github.com/openforcefield/openff-toolkit/issues/2051))

### Miscellaneous
Expand All @@ -22,7 +23,9 @@ Releases follow the `major.minor.micro` scheme recommended by [PEP440](https://w
- [PR #2078](https://github.com/openforcefield/openff-toolkit/pull/2078): Updates molecule cookbook molecule.from_qcschema()

### New features

- [PR #2066](https://github.com/openforcefield/openff-toolkit/pull/2066): Improves runtime in some situations by making AmberToolsToolkitWrapper perform lazy evaluation of AmberTools version. (@vamironov)
- [PR #2090](https://github.com/openforcefield/openff-toolkit/pull/2090): Improves runtime of force field serialization via faster `Quantity` stringification.


### Improved documentation and warnings
Expand Down
2 changes: 1 addition & 1 deletion openff/toolkit/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def quantity_to_string(input_quantity: Quantity) -> str:
The serialized quantity

"""
unitless_value: float | int | NDArray | list = input_quantity.m_as(input_quantity.units)
unitless_value: float | int | NDArray | list = input_quantity.m
# The string representation of a numpy array doesn't have commas and breaks the
# parser, thus we convert any arrays to list here
if isinstance(unitless_value, np.ndarray):
Expand Down
Loading