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

Make function for handling time or reuse an existing one #4113

Closed
kratman opened this issue May 28, 2024 · 4 comments · Fixed by #4209
Closed

Make function for handling time or reuse an existing one #4113

kratman opened this issue May 28, 2024 · 4 comments · Fixed by #4209
Assignees
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours

Comments

@kratman
Copy link
Contributor

kratman commented May 28, 2024

The following code was added in #4073:

            elif term.endswith("s"):
                end_time_s = term.split("s")[0]
                termination_dict["time"] = (float(end_time_s), "s")
            elif term.endswith("min"):
                end_time_s = term.split("min")[0]
                termination_dict["time"] = (float(end_time_s) * 60, "s")
            elif term.endswith("h"):
                end_time_s = term.split("h")[0]
                termination_dict["time"] = (float(end_time_s) * 3600, "s")

This should probably be converted to a function. For example, if a space is required in the string then:

elif temer.split(" ")[1] in ["h", "min", "s"]:
    end_time = term.split(" ")[0]
    unit = term.split(" ")[1]
    termination_dict["time"] = convert_time_to_seconds(end_time, unit)
@agriyakhetarpal agriyakhetarpal added the difficulty: easy A good issue for someone new. Can be done in a few hours label May 28, 2024
@kratman
Copy link
Contributor Author

kratman commented May 28, 2024

Note: Part of this ticket is finding out if there are other instances where this change can be made. So whoever takes this up, please search for other time conversions

@valentinsulzer
Copy link
Member

@agriyakhetarpal
Copy link
Member

From #4073 (comment) I think you'll need to comment here, @mleot, so that GitHub can add your name to the list of potential assignees

@mleot
Copy link
Contributor

mleot commented May 28, 2024

Got it, commenting here.

mleot added a commit to mleot/PyBaMM that referenced this issue Jun 24, 2024
@kratman kratman closed this as completed in deca7e2 Jul 1, 2024
kratman added a commit that referenced this issue Jul 12, 2024
* Make function for handling time or reuse an existing one
Fixes #4113

* style: pre-commit fixes

* fixing raises RegEx Error Experiment Test

* fix pre-commit error

* Update pybamm/callbacks.py

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Valentin Sulzer <valentinsulzer@hotmail.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
js1tr3 pushed a commit to js1tr3/PyBaMM that referenced this issue Aug 12, 2024
…#4209)

* Make function for handling time or reuse an existing one
Fixes pybamm-team#4113

* style: pre-commit fixes

* fixing raises RegEx Error Experiment Test

* fix pre-commit error

* Update pybamm/callbacks.py

Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Co-authored-by: Valentin Sulzer <valentinsulzer@hotmail.com>
Co-authored-by: Eric G. Kratz <kratman@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy A good issue for someone new. Can be done in a few hours
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants