Skip to content

Commit e8ebcea

Browse files
author
Christopher Doris
committed
Merge remote-tracking branch 'origin/main' into v1
2 parents 63b2801 + c886d48 commit e8ebcea

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

docs/src/conversion-to-julia.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ From Python, the arguments to a Julia function will be converted according to th
4747
| `ctypes.c_voidp` | `Ptr{Cvoid}`, `Ptr` |
4848
| `ctypes.c_char_p` | `Cstring`, `Ptr{Cchar}`, `Ptr` |
4949
| `ctypes.c_wchar_p` | `Cwstring`, `Ptr{Cwchar}`, `Ptr` |
50-
| `numpy.intXX`/`numpy.uintXX`/`numpy.floatXX` | `Integer`, `Rational`, `Real`, `Number` |
50+
| `numpy.bool_`/`numpy.intXX`/`numpy.uintXX`/`numpy.floatXX` | `Bool`, `Integer`, `Rational`, `Real`, `Number` |
5151
| Objects satisfying the buffer or array interface | `Array`, `AbstractArray` |
5252
| **Low priority (fallback to `Py`).** | |
5353
| Anything | `Py` |

docs/src/releasenotes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
## Unreleased
77
* `Serialization.serialize` can use `dill` instead of `pickle` by setting the env var `JULIA_PYTHONCALL_PICKLE=dill`.
8+
* `numpy.bool_` can now be converted to `Bool` and other number types.
89
* `datetime.timedelta` can now be converted to `Dates.Nanosecond`, `Microsecond`, `Millisecond` and `Second`. This behaviour was already documented.
910

1011
## 0.9.20 (2024-05-01)

src/Convert/numpy.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ function (::pyconvert_rule_numpysimplevalue{R,SAFE})(::Type{T}, x::Py) where {R,
1010
end
1111

1212
const NUMPY_SIMPLE_TYPES = [
13+
("bool_", Bool),
1314
("int8", Int8),
1415
("int16", Int16),
1516
("int32", Int32),
@@ -27,17 +28,18 @@ const NUMPY_SIMPLE_TYPES = [
2728
]
2829

2930
function init_numpy()
30-
for (t,T) in NUMPY_SIMPLE_TYPES
31-
isint = occursin("int", t)
32-
isuint = occursin("uint", t)
31+
for (t, T) in NUMPY_SIMPLE_TYPES
32+
isbool = occursin("bool", t)
33+
isint = occursin("int", t) || isbool
34+
isuint = occursin("uint", t) || isbool
3335
isfloat = occursin("float", t)
3436
iscomplex = occursin("complex", t)
3537
isreal = isint || isfloat
3638
isnumber = isreal || iscomplex
3739

3840
name = "numpy:$t"
39-
rule = pyconvert_rule_numpysimplevalue{T, false}()
40-
saferule = pyconvert_rule_numpysimplevalue{T, true}()
41+
rule = pyconvert_rule_numpysimplevalue{T,false}()
42+
saferule = pyconvert_rule_numpysimplevalue{T,true}()
4143

4244
pyconvert_add_rule(name, T, saferule, PYCONVERT_PRIORITY_ARRAY)
4345
isuint && pyconvert_add_rule(name, UInt, sizeof(T) sizeof(UInt) ? saferule : rule)

0 commit comments

Comments
 (0)