Skip to content

BUG: Inconsistent behaviour of return type of int64.__pow__ #8809

Closed
@eric-wieser

Description

@eric-wieser

Raised by this stackoverflow question. The following code , run on master...

x_actual = 49997
x3_actual = x_actual ** 3

for dtype in [np.int64, np.uint64, np.float64]:
	x = {}
	x['scalar'] = dtype(x_actual)
	x[    '0d'] = np.array(x_actual, dtype=dtype)
	x[    '1d'] = np.array([x_actual], dtype=dtype)
	x[    '2d'] = np.array([[x_actual]], dtype=dtype)

	x3 = {k: x**3 for k, x in x.items()}

	assert all(v == x3_actual for v in x3.values())  #ok

	print("input type of {}:".format(np.dtype(dtype)))
	for k, v in x3.items():
		print("{:>8s}: {}".format(k, v.dtype))
	print()

Gives the alarming output of:

input of int64
  scalar: int64
      0d: int64
      1d: int64
      2d: int64

input of uint64
  scalar: float64
      0d: float64
      1d: uint64    # What?
      2d: uint64    # What?

input of float64
  scalar: float64
      0d: float64
      1d: float64
      2d: float64

The return dtype of power should not depend on the shape of the input array

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