Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Closed
wants to merge 1 commit into from
Closed

py: implemented rounding floats to precision #1382

wants to merge 1 commit into from

Conversation

turbinenreiter
Copy link
Contributor

in continuation of #1376

  • supports rounding floats to precision
  • uses macros
  • added warning may cause overflow

@turbinenreiter
Copy link
Contributor Author

oh man, now these macros break the stmhal builds.
I need to figure out how to get Travis running on my own repo, so I see these results before creating noisy pull requests.

@danicampora
Copy link
Member

It's really easy, I don't remember the exact steps, but is like 2 or 3
clicks on your repo config.

On Tue, Jul 14, 2015 at 3:07 PM, Sebastian Plamauer <
[email protected]> wrote:

oh man, now these macros break the stmhal builds.
I need to figure out how to get Travis running on my own repo, so I see
these results before creating noisy pull requests.


Reply to this email directly or view it on GitHub
#1382 (comment)
.

@pfalcon
Copy link
Contributor

pfalcon commented Jul 14, 2015

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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@pfalcon
Copy link
Contributor

pfalcon commented Jul 14, 2015

how to get Travis running on my own repo

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.

@turbinenreiter
Copy link
Contributor Author

@pfalcon right, I'm going to add tests.

Should I make changes in new commits, or should I squash them into one?

@pfalcon
Copy link
Contributor

pfalcon commented Jul 14, 2015

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.

@turbinenreiter
Copy link
Contributor Author

ok, see qemu-arm test fails:

basics/builtin_round.py: Traceback (most recent call last):
  File "<stdin>", line 6
SyntaxError: decimal numbers not supported

  FAIL test_main.c:42: Uncaught exception
  [builtin_round.py FAILED]

I guess I'd need separate tests for when floats are supported and when not? Not sure how to do that.

@danicampora
Copy link
Member

Make two tests, one with floats and another with ints. Place the float one in tests/float and it should be fine.

@pfalcon
Copy link
Contributor

pfalcon commented Jul 14, 2015

Make two tests, one with floats and another with ints. Place the float one in tests/float and it should be fine.

Or more specifically: leave basics/builtin_round.py as is, add float/builtin_round_float.py with new tests.

@turbinenreiter turbinenreiter changed the title py: implemented round up to 6 decimals and negative py: implemented rounding floats to precision Jul 14, 2015
@turbinenreiter
Copy link
Contributor Author

opinions?

@pfalcon
Copy link
Contributor

pfalcon commented Jul 19, 2015

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.

@turbinenreiter
Copy link
Contributor Author

Realized that because of the silence ;)

@pfalcon
Copy link
Contributor

pfalcon commented Jul 19, 2015

Perfect, thanks! Merged.

@pfalcon pfalcon closed this Jul 19, 2015
tannewt added a commit to tannewt/circuitpython that referenced this pull request Jul 14, 2019
Initial support for RGB led as Status indicator, fixes micropython#1382
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants