Skip to content

Commit 350171e

Browse files
author
Christopher Doris
committed
docs(numpydates): add NumpyDates reference and clarify unit docs
- Add NumpyDates section to pythoncall-reference with API docs - Update release notes with NumpyDates overview - Clarify docstrings: runtime vs inline units and memory layout
1 parent be62b3d commit 350171e

File tree

6 files changed

+30
-0
lines changed

6 files changed

+30
-0
lines changed

docs/src/pythoncall-reference.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,18 @@ PythonCall.getptr
255255
PythonCall.pydel!
256256
PythonCall.unsafe_pynext
257257
```
258+
259+
## NumpyDates
260+
261+
The submodule `PythonCall.NumpyDates` provides types corresponding to Numpy's `datetime64` and `timedelta64` types. Enables conversion of these Numpy types (either as scalars or in arrays) to native Julia types.
262+
263+
```@docs
264+
PythonCall.NumpyDates
265+
PythonCall.NumpyDates.AbstractDateTime64
266+
PythonCall.NumpyDates.InlineDateTime64
267+
PythonCall.NumpyDates.DateTime64
268+
PythonCall.NumpyDates.AbstractTimeDelta64
269+
PythonCall.NumpyDates.InlineTimeDelta64
270+
PythonCall.NumpyDates.TimeDelta64
271+
PythonCall.NumpyDates.Unit
272+
```

docs/src/releasenotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Release Notes
22

3+
## Unreleased
4+
* Added NumpyDates: NumPy-compatible DateTime64/TimeDelta64 types and units.
5+
36
## 0.9.27 (2025-08-19)
47
* Internal: Use heap-allocated types (PyType_FromSpec) to improve ABI compatibility.
58
* Minimum supported Python version is now 3.9.

src/NumpyDates/DateTime64.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
77
Construct an `DateTime64` with the given `value` and [`unit`](@ref Unit).
88
9+
The unit is stored as a run-time value. If the units in your code are known, using
10+
[`InlineDateTime64{unit}`](@ref InlineDateTime64) may be preferable. The memory layout
11+
is the same as for a `numpy.datetime64`.
12+
913
The value can be:
1014
- An `Integer`, in which case the `unit` is required.
1115
- A `Dates.Date` or `Dates.DateTime`.

src/NumpyDates/InlineDateTime64.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
99
Construct an `InlineDateTime64` with the given `value` and [`unit`](@ref Unit).
1010
11+
The unit is part of the type, so an instance just consists of one `Int64` for the value.
12+
1113
The `value` can be:
1214
- An `Integer`, in which case the `unit` is required.
1315
- A `Dates.Date` or `Dates.DateTime`.

src/NumpyDates/InlineTimeDelta64.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
77
Construct an `InlineTimeDelta64` with the given `value` and [`unit`](@ref Unit).
88
9+
The unit is part of the type, so an instance just consists of one `Int64` for the value.
10+
911
The value can be:
1012
- An `Integer`, in which case the `unit` is required.
1113
- `"NaT"` or `"NaN"` to make a not-a-time value.

src/NumpyDates/TimeDelta64.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
66
Construct a `TimeDelta64` with the given `value` and [`unit`](@ref Unit).
77
8+
The unit is stored as a run-time value. If the units in your code are known, using
9+
[`InlineTimeDelta64{unit}`](@ref InlineTimeDelta64) may be preferable. The memory layout
10+
is the same as for a `numpy.timedelta64`.
11+
812
The value can be:
913
- An `Integer`, in which case the `unit` is required.
1014
- `"NaT"` or `"NaN"` to make a not-a-time value.

0 commit comments

Comments
 (0)