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

Add non integral tests for sqrt() #88530

Closed
AjithRamachandran mannequin opened this issue Jun 9, 2021 · 4 comments
Closed

Add non integral tests for sqrt() #88530

AjithRamachandran mannequin opened this issue Jun 9, 2021 · 4 comments
Labels
3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement

Comments

@AjithRamachandran
Copy link
Mannequin

AjithRamachandran mannequin commented Jun 9, 2021

BPO 44364
Nosy @mdickinson, @serhiy-storchaka, @AjithRamachandran
PRs
  • bpo-44364:Add non integral tests for sqrt() #26625
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-06-10.16:29:32.499>
    created_at = <Date 2021-06-09.15:14:51.752>
    labels = ['type-feature', 'tests', '3.10', '3.11']
    title = 'Add non integral tests for `sqrt()`'
    updated_at = <Date 2021-06-10.19:41:09.598>
    user = 'https://github.com/AjithRamachandran'

    bugs.python.org fields:

    activity = <Date 2021-06-10.19:41:09.598>
    actor = 'mark.dickinson'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-06-10.16:29:32.499>
    closer = 'mark.dickinson'
    components = ['Tests']
    creation = <Date 2021-06-09.15:14:51.752>
    creator = 'AjithRamachandran'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44364
    keywords = ['patch']
    message_count = 4.0
    messages = ['395549', '395563', '395564', '395566']
    nosy_count = 3.0
    nosy_names = ['mark.dickinson', 'serhiy.storchaka', 'AjithRamachandran']
    pr_nums = ['26625']
    priority = 'normal'
    resolution = None
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue44364'
    versions = ['Python 3.10', 'Python 3.11']

    @AjithRamachandran AjithRamachandran mannequin added 3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement labels Jun 9, 2021
    @mdickinson
    Copy link
    Member

    New changeset 90cd433 by Ajith Ramachandran in branch 'main':
    bpo-44364:Add non integral tests for sqrt() (bpo-26625)
    90cd433

    @serhiy-storchaka
    Copy link
    Member

    >>> math.sqrt(2.5) == 2.5**0.5
    True
    >>> math.sqrt(25.25) == 25.25**0.5
    True

    If we test the precision of math.sqrt(), would not be better to test it with data for which naive way of calculating the root returns different result? For example 2921 is the smallest integers for which math.sqrt(x) > x**0.5, and 3541 is the smallest integers for which math.sqrt(x) < x**0.5.

    @serhiy-storchaka
    Copy link
    Member

    65733 and 262694 are integers in range 1..1000000 with largest relative errors of naive square root (with different signs).

    33031 and 524557 are integers in range 1..1000000 with largest relative errors of naive cube root (with different signs).

    @mdickinson
    Copy link
    Member

    2921 is the smallest integers for which math.sqrt(x) > x**0.5

    This is platform-dependent. On my machine, for example, math.sqrt(2921) == 2921**0.5 returns True.

    I don't see a lot of value in additional tests here; we're only wrapping the libm sqrt, so we only really need enough testing to catch possible implementation errors in that wrapping. But testing only integers with an exact square root doesn't seem enough.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes tests Tests in the Lib/test dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants