Skip to content

Issues with "Mixing arrays and Python scalars" section #98

Description

@asmeurer

A few issues with the mixing arrays and Python scalars section that came up from testing:

  • The matmul operator (@) does not (and should not) support scalar types, so it should be excluded.
  • Should boolean arrays be required to work with arithmetic operators. NumPy gives errors in some cases, for example:
>>> import numpy as np
>>> np.array(False) - False
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: numpy boolean subtract, the `-` operator, is not supported, use the bitwise_xor, the `^` operator, or the logical_xor function instead. 
  • How should casting work? For example, int8 array + large Python int. Should it cast the int, or give an error. Or should this be unspecified.
  • The above question also applies for Python float -> float32 casting, which is implicitly supported by the text that is currently there, but is unsafe in general (is there a "safe" variant of float64 -> float32, or is it always unsafe? Either way, this would be value based casting, which I thought we were trying to avoid).

Activity

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions