Skip to content

Commit 466d515

Browse files
author
MarcoGorelli
committed
use enum
1 parent ee7f95e commit 466d515

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pandas/_libs/tslib.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ cnp.import_array()
2828

2929
from pandas._libs.tslibs.np_datetime cimport (
3030
NPY_DATETIMEUNIT,
31+
Exact,
3132
NPY_FR_ns,
3233
check_dts_bounds,
3334
get_datetime64_value,
@@ -411,7 +412,7 @@ cpdef array_to_datetime(
411412
bint utc=False,
412413
bint require_iso8601=False,
413414
format: str | None=None,
414-
bint exact=True,
415+
Exact exact=Exact.EXACT_MATCH,
415416
):
416417
"""
417418
Converts a 1D array of date-like values to a numpy array of either:

pandas/_libs/tslibs/np_datetime.pxd

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ from numpy cimport (
99
)
1010

1111

12+
cdef enum Exact:
13+
INEXACT_MATH
14+
EXACT_MATCH
15+
NO_MATCH
16+
1217
# TODO(cython3): most of these can be cimported directly from numpy
1318
cdef extern from "numpy/ndarrayobject.h":
1419
ctypedef int64_t npy_timedelta
@@ -96,7 +101,7 @@ cdef int string_to_dts(
96101
int* out_tzoffset,
97102
bint want_exc,
98103
format: str | None = *,
99-
int exact = *
104+
Exact exact = *
100105
) except? -1
101106

102107
cdef NPY_DATETIMEUNIT get_unit_from_dtype(cnp.dtype dtype)

pandas/_libs/tslibs/np_datetime.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ cdef int string_to_dts(
279279
int* out_tzoffset,
280280
bint want_exc,
281281
format: str | None=None,
282-
int exact=1,
282+
Exact exact=EXACT_MATCH,
283283
) except? -1:
284284
cdef:
285285
Py_ssize_t length
@@ -291,7 +291,7 @@ cdef int string_to_dts(
291291
if format is None:
292292
format_buf = b""
293293
format_length = 0
294-
exact = 2
294+
exact = NO_MATCH
295295
else:
296296
format_buf = get_c_string_buf_and_size(format, &format_length)
297297
return parse_iso_8601_datetime(buf, length, want_exc,

0 commit comments

Comments
 (0)