10000 Now passing test_math from 3.13.2 with some caveat by hbina · Pull Request #5610 · RustPython/RustPython · GitHub
[go: up one dir, main page]

Skip to content

Now passing test_math from 3.13.2 with some caveat #5610

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

Merged
merged 1 commit into from
Apr 5, 2025

Conversation

hbina
Copy link
Contributor
@hbina hbina commented Mar 15, 2025

There are incompatibilities in the implementation of fma from libc vs musl.

I have added the tests that shows the differences here,

#[test]
fn fma_negative_zero() {
    let tiny = 1e-300;
    assert!(libm::fma(tiny, tiny, 0.0).is_sign_positive());
    // TODO: RUSTPYTHON incompatibility between fma inside libc and musl
    // assert!(libm::fma(tiny, -tiny, 0.0).is_sign_negative());
    assert!(libm::fma(-tiny, -tiny, 0.0).is_sign_positive());
    // TODO: RUSTPYTHON incompatibility between fma inside libc and musl
    // assert!(libm::fma(-tiny, tiny, 0.0).is_sign_negative());
    assert!(libm::fma(tiny, tiny, -0.0).is_sign_positive());
    assert!(libm::fma(tiny, -tiny, -0.0).is_sign_negative());
    assert!(libm::fma(-tiny, -tiny, -0.0).is_sign_positive());
    assert!(libm::fma(-tiny, tiny, -0.0).is_sign_negative());
}

@hbina hbina force-pushed the hbina-fix-py313-test-math branch 2 times, most recently from 4dd3ff8 to 594a330 Compare March 23, 2025 13:42
@youknowone
Copy link
Member

I am a bit confused by the libc vs musl situation. Which version fits to CPython behavior? Does CPython follow musl implementation?
libm's README says it is a port of musl implementaiton. So if we follow the libm implementation, is it compatible to CPython?

@hbina
Copy link
Contributor Author
hbina commented Mar 30, 2025

CPython uses the system's libm, so on most system its probably going to be libc's libm. Meanwhile, the Rust's libm is based on musl's libm.

@hbina hbina force-pushed the hbina-fix-py313-test-math branch from ee05a75 to 7191aae Compare April 1, 2025 09:53
Implemnted fma in math module.
@hbina hbina force-pushed the hbina-fix-py313-test-math branch from 7191aae to af42192 Compare April 5, 2025 03:17
@youknowone youknowone changed the title Now passing test_math from 3.12.2 with some caveat Now passing test_math from 3.13.2 with some caveat Apr 5, 2025
Copy link
Member
@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Thanks!

@youknowone youknowone merged commit d800a6b into RustPython:main Apr 5, 2025
10 of 11 checks passed
@hbina hbina deleted the hbina-fix-py313-test-math branch April 5, 2025 08:08
Shakil582 pushed a commit to Shakil582/RustPython that referenced this pull request Apr 6, 2025
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.

2 participants
0