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

Migrate to f-strings in python-package\lightgbm\plotting.py (#4136) #4279

Merged
merged 3 commits into from
May 13, 2021

Conversation

akshitadixit
Copy link
Contributor

Related to #4136

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for taking the time to contribute! Please see a few suggestions below.



def _float2str(value, precision=None):
return ("{0:.{1}f}".format(value, precision)
return (f"{value:.{precision}f}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work! Did not know you could do string interpolation on the right-hand side of the : in an f-string.

I tested a few cases and confirmed that this still has the expected behavior.

assert _float2str(0.0000001) == '1e-07'
assert _float2str(0.0000001, precision=1) == '0.0'
assert _float2str(0.0000001, precision=10) == '0.0000001000'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, even I learnt this today :)

python-package/lightgbm/plotting.py Outdated Show resolved Hide resolved
python-package/lightgbm/plotting.py Outdated Show resolved Hide resolved
akshitadixit and others added 2 commits May 12, 2021 20:03
Co-authored-by: James Lamb <jaylamb20@gmail.com>
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@StrikerRUS StrikerRUS requested a review from jameslamb May 12, 2021 22:17
@jameslamb jameslamb merged commit adf36d7 into microsoft:master May 13, 2021
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants