-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
py: implemented rounding floats to precision #1382
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
Conversation
oh man, now these macros break the stmhal builds. |
It's really easy, I don't remember the exact steps, but is like 2 or 3 On Tue, Jul 14, 2015 at 3:07 PM, Sebastian Plamauer <
|
Well, unfortunately, there's swing of pendulum in another direction comparing to #1376 ;-). Let's start with the main issue: there should be tests. Just, as comments to the above issue said, you should avoid using N > 5 in the test. |
@@ -440,8 +440,18 @@ STATIC mp_obj_t mp_builtin_round(mp_uint_t n_args, const mp_obj_t *args) { | |||
mp_int_t num_dig = 0; | |||
if (n_args > 1) { | |||
num_dig = mp_obj_get_int(args[1]); | |||
if (num_dig > 0) { | |||
mp_not_implemented("round(..., N>0)"); | |||
if (num_dig > 0 && num_dig < 7) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should not be such check ("< 7") here, it's implementation-specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean leave it out entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, no need to test for < 7. Actually, maybe no need to test for >0, then <0 case should actually automagically work.
As @danicampora points, it's easy, but you don't even need to - we have (well, github has) Travis running on pull requests exactly to let people skip running Travis on their own repos. |
@pfalcon right, I'm going to add tests. Should I make changes in new commits, or should I squash them into one? |
I suggest adding new commits, then when you get green light, squash everything to be merged. |
ok, see qemu-arm test fails:
I guess I'd need separate tests for when floats are supported and when not? Not sure how to do that. |
Make two tests, one with floats and another with ints. Place the float one in |
Or more specifically: leave basics/builtin_round.py as is, add float/builtin_round_float.py with new tests. |
opinions? |
This is common theme - github doesn't send notification on new version of PR being pushed, so pushing your changes is not replacement for a bit of human chit-chat ;-). From a quick look, looks good, will target to merge later today. |
Realized that because of the silence ;) |
Perfect, thanks! Merged. |
Initial support for RGB led as Status indicator, fixes micropython#1382
in continuation of #1376