Skip to content

Commit 3eded25

Browse files
authored
Note that in-place operators should not change the dtype of the array (#166)
Also note that the Python scalar rules do apply to in-place operators in addition to normal operators. The broadcasting rule here is duplicated in the broadcasting section. I'm unsure if we should leave it duplicated or remove it so it is only mentioned once.
1 parent 0cbbfea commit 3eded25

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

spec/API_specification/array_object.md

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ an array object supporting the following in-place Python operators:
153153
- `<<=`. May be implemented via `__ilshift__`.
154154
- `>>=`. May be implemented via `__irshift__`.
155155

156+
An in-place operation must not change the dtype or shape of the in-place array
157+
as a result of {ref}`type-promotion` or {ref}`broadcasting`.
158+
156159
```{note}
157160
158161
In-place operators must be supported as discussed in {ref}`copyview-mutability`.

spec/API_specification/type_promotion.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ arrays must be supported for:
102102
- `array <op> scalar`
103103
- `scalar <op> array`
104104

105-
where `<op>` is a built-in operator (see {ref}`operators` for operators
106-
supported by the array object) and `scalar` has a compatible type and value
107-
to the array dtype:
105+
where `<op>` is a built-in operator, including in-place operators (see
106+
{ref}`operators` for operators supported by the array object) and `scalar` has
107+
a compatible type and value to the array dtype:
108108
- Python `bool` for a `bool` array dtype,
109109
- a Python `int` within the [bounds](data-types) of the given dtype for integer array dtypes,
110110
- a Python `int` or `float` for floating-point array dtypes

0 commit comments

Comments
 (0)