FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Divergence in default rounding of `xt::round()` from `np.round()` · Issue #2800 · xtensor-stack/xtensor · GitHub

Repository navigation

Divergence in default rounding of xt::round() from np.round() #2800

Open

Description

Consider following bankers rounding for xt::round() instead of rounding away from zero
xtensor -

xt::xarray<double> arr1 =  {0.5, 1.5, 2.5, 3.5, 4.5};
std::cout<<xt::round(arr1)<<std::endl;

{ 1.,  2.,  3.,  4.,  5.}

numpy -

>>> import numpy as np
>>> arr1 = np.array([0.5, 1.5, 2.5, 3.5, 4.5])
>>> np.round(arr1)
array([0., 2., 2., 4., 4.])

What numpy follows when rounding exact halves is round half to nearest even. You can read why it is the default rounding model followed by IEEE_754 becuase of eliminating biases here.

Activity

  1. faze-geek commented on Jul 30, 2024

    Author

    @JohanMabille If this is a valid issue, I'd like to send in a fix. Thanks.

  2. changed the title [-]DIvergence in default rounding of `xt::round()` from `np.round()`[/-] [+]Divergence in default rounding of `xt::round()` from `np.round()`[/+] on Jul 30, 2024
  3. faze-geek commented on Jul 30, 2024

    Author

    If we want to stick with the original, this must be mentioned somewhere like noteable differences.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL