Giter VIP home page Giter VIP logo

Comments (8)

rougier avatar rougier commented on May 18, 2024

Oh yes, forgot about negative value... Many thanks.
Could make a PR ?

from numpy-100.

MarredCheese avatar MarredCheese commented on May 18, 2024

Ok, will try do that soon.

On Tue, Jul 26, 2016 at 12:05 PM, Nicolas P. Rougier <
[email protected]> wrote:

Oh yes, forgot about negative value... Many thanks.
Could make a PR ?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#15 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AO-LbGQGWNKpQ3XKBFpTAOB73CQzYHcjks5qZj5TgaJpZM4JVPaJ
.

from numpy-100.

rougier avatar rougier commented on May 18, 2024

Thanks !

from numpy-100.

ibah avatar ibah commented on May 18, 2024

round() also doesn't work properly, as 1, 3, 5, ... are rounded to 2, 4, 6 (instead of 1, 3, 5)

I suggest following solution:
print(np.copysign(np.ceil(np.abs(Z)), Z))

from numpy-100.

rougier avatar rougier commented on May 18, 2024

What is your numpy version ? For me np.round(1.0) gives me 1.0

from numpy-100.

ibah avatar ibah commented on May 18, 2024

Numpy 1.11.1

The code:
Z = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5])
print (np.round(Z + np.copysign(0.5, Z)))
for me prints:
[ 2. 2. 2. 3. 4. 4.]
while it should be:
[ 1. 2. 2. 3. 3. 4.]

I think this is because "For values exactly halfway between rounded decimal values, Numpy rounds to the nearest even value.", http://docs.scipy.org/doc/numpy/reference/generated/numpy.around.html

from numpy-100.

rougier avatar rougier commented on May 18, 2024

Ah ok. Sorry, I did not understand your first example.
Could you make a PR with your changes ?

from numpy-100.

ibah avatar ibah commented on May 18, 2024

Yes, I wasn't clear in my first example.
I just created the PR. Please comment/modify in case I did anything wrong, as this is my first PR on github.
Thanks,

from numpy-100.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.