Skip to content
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

[Bug]: pybam.Experiment parse units error #4608

Closed
chuckliu1979 opened this issue Nov 25, 2024 · 1 comment · Fixed by #4641
Closed

[Bug]: pybam.Experiment parse units error #4608

chuckliu1979 opened this issue Nov 25, 2024 · 1 comment · Fixed by #4641
Assignees
Labels
bug Something isn't working

Comments

@chuckliu1979
Copy link

PyBaMM Version

24.9.0

Python Version

python 3.10

Describe the bug

in https://github.com/pybamm-team/PyBaMM/blob/develop/src/pybamm/experiment/step/base_step.py function def _convert_electric(value_string), if the value_string float value contains 'e' or 'E', the units incorrect parsed:

Python 3.12.3 (main, Nov 6 2024, 18:32:19) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

value_string = "-1.1729285959021311e-05 W"
unit = value_string.lstrip("0123456789.- ")
unit
'e-05 W'
unit = value_string.lstrip("0123456789eE.- ")
unit
'W'

for python3, according to https://docs.python.org/3/library/functions.html#float, should accept 'e' or 'E' as well

Steps to Reproduce

  1. value_string = "-1.1729285959021311e-05 W"
  2. unit = value_string.lstrip("0123456789.- ")

get incorrect unit 'e-05 W', it should be 'W'

Relevant log output

@chuckliu1979 chuckliu1979 added the bug Something isn't working label Nov 25, 2024
@kratman
Copy link
Contributor

kratman commented Nov 25, 2024

Thanks @chuckliu1979 I will take a look at this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants