Skip to content

Behavior of negative exponentiation inconsistent between integer types #7648

Closed

Description

@jakevdp
>>> np.int64(2) ** -2
0.25
>>> np.int32(2) ** -2
0

Tested on OSX 10.8.5 w/ numpy 1.10 on both Python 2.7 and 3.5.

Activity

  1. navneethc commented on May 19, 2016

    @navneethc

    I second this.

    Following tested using:
    Python 3.5.1 (Python 3 environment created using Anaconda 4 64-bit)
    Numpy 1.11.0

    In [34]: np.int32(2)**-2
    Out[34]: 0.25
    
    In [35]: np.uint32(2)**-2
    Out[35]: 0
    
    In [36]: np.int64(2)**-2
    Out[36]: 0.25
    
    In [37]: np.uint64(2)**-2
    Out[37]: 0.25
    
    In [38]: np.int16(2)**-2
    Out[38]: 0
    
    In [39]: np.uint16(2)**-2
    Out[39]: 0
    
    In [40]: np.int8(2)**-2
    Out[40]: 0
    
    In [41]: np.uint8(2)**-2
    Out[41]: 0
    
  2. ewmoore commented on May 19, 2016

    @ewmoore
    Contributor

    See issue #7449 and PR #7459. The PR fixes this, but could use some review.

  3. mhvk commented on May 19, 2016

    @mhvk
    Contributor

    Just in case (have to run): Note that the array case should also keep working. In numpy 1.11:

    np.ones((2,), dtype=int) ** -2
    # array([1, 1])
    

    In current master:

    np.ones((2,), dtype=int) ** -2
    # array([0, 0])
    
  4. ewmoore commented on May 19, 2016

    @ewmoore
    Contributor

    Gah. That's mine.

  5. added a commit that references this issue on May 19, 2016
    5cde31b
  6. ewmoore commented on May 19, 2016

    @ewmoore
    Contributor

    See #7651.

  7. added this to the milestone on May 19, 2016
  8. removed this from the milestone on May 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions