Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

py/modmath: New function math hypot.#8593

Open
Leah1115 wants to merge 1 commit into
micropython:mastermicropython/micropython:masterfrom
ECE595:math/hypot-new-funcECE595/micropython:math/hypot-new-funcCopy head branch name to clipboard
Open

py/modmath: New function math hypot.#8593
Leah1115 wants to merge 1 commit into
micropython:mastermicropython/micropython:masterfrom
ECE595:math/hypot-new-funcECE595/micropython:math/hypot-new-funcCopy head branch name to clipboard

Conversation

@Leah1115

Copy link
Copy Markdown

Implement the math.hypot function.
This implementation covers the Change in CPython 3.8, Multidimensional support of math.hypot(). python/cpython#8474
This was worked on with the assistance of @wang3450

@dlech dlech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good to add this function to docs/library/math.rst too.

And mark the relevant line as Completed in docs/differences/python_38.rst.

Comment thread py/modmath.c
ans = (mp_float_t)0.0;
for (size_t i = 0; i < n_args; i++) {
a = mp_obj_get_float(args[i]);
a_pow2 = MICROPY_FLOAT_C_FUN(pow)(a, 2);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be more efficient to just do ans += a * a instead of calling pow?

@dpgeorge dpgeorge added the py-core Relates to py/ directory in source label Apr 29, 2022
(),
(1.5, 1.5, 0.5),
(1.5, 0.5, 1.5),
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we add tests for NaN and infinity arguments and return values?

@projectgus

Copy link
Copy Markdown
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

py-core Relates to py/ directory in source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.