Skip to content

Remove arg that is only ever used as NPY_UNSAFE_CASTING #18546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions pandas/_libs/src/datetime.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ from cpython cimport PyUnicode_Check, PyUnicode_AsASCIIString
cdef extern from "numpy/ndarrayobject.h":
ctypedef int64_t npy_datetime

ctypedef enum NPY_CASTING:
NPY_NO_CASTING
NPY_EQUIV_CASTING
NPY_SAFE_CASTING
NPY_SAME_KIND_CASTING
NPY_UNSAFE_CASTING

cdef extern from "numpy/npy_common.h":
ctypedef unsigned char npy_bool

Expand Down Expand Up @@ -45,7 +38,6 @@ cdef extern from "datetime/np_datetime.h":

cdef extern from "datetime/np_datetime_strings.h":
int parse_iso_8601_datetime(char *str, int len, PANDAS_DATETIMEUNIT unit,
NPY_CASTING casting,
pandas_datetimestruct *out,
int *out_local, int *out_tzoffset,
PANDAS_DATETIMEUNIT *out_bestunit,
Expand Down Expand Up @@ -75,7 +67,6 @@ cdef inline int _cstring_to_dts(char *val, int length,
int result

result = parse_iso_8601_datetime(val, length, PANDAS_FR_ns,
NPY_UNSAFE_CASTING,
dts, out_local, out_tzoffset,
&out_bestunit, &special)
return result
38 changes: 0 additions & 38 deletions pandas/_libs/src/datetime/np_datetime.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,44 +679,6 @@ int convert_datetimestruct_to_datetime(pandas_datetime_metadata *meta,
return 0;
}

/*
* This provides the casting rules for the DATETIME data type units.
*
* Notably, there is a barrier between 'date units' and 'time units'
* for all but 'unsafe' casting.
*/
npy_bool can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
PANDAS_DATETIMEUNIT dst_unit,
NPY_CASTING casting) {
switch (casting) {
/* Allow anything with unsafe casting */
case NPY_UNSAFE_CASTING:
return 1;

/*
* Only enforce the 'date units' vs 'time units' barrier with
* 'same_kind' casting.
*/
case NPY_SAME_KIND_CASTING:
return (src_unit <= PANDAS_FR_D && dst_unit <= PANDAS_FR_D) ||
(src_unit > PANDAS_FR_D && dst_unit > PANDAS_FR_D);

/*
* Enforce the 'date units' vs 'time units' barrier and that
* casting is only allowed towards more precise units with
* 'safe' casting.
*/
case NPY_SAFE_CASTING:
return (src_unit <= dst_unit) &&
((src_unit <= PANDAS_FR_D && dst_unit <= PANDAS_FR_D) ||
(src_unit > PANDAS_FR_D && dst_unit > PANDAS_FR_D));

/* Enforce equality with 'no' or 'equiv' casting */
default:
return src_unit == dst_unit;
}
}

/*
* Converts a datetime based on the given metadata into a datetimestruct
*/
Expand Down
11 changes: 0 additions & 11 deletions pandas/_libs/src/datetime/np_datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,6 @@ int cmp_pandas_datetimestruct(const pandas_datetimestruct *a,
void
add_minutes_to_datetimestruct(pandas_datetimestruct *dts, int minutes);

/*
* This provides the casting rules for the TIMEDELTA data type units.
*
* Notably, there is a barrier between the nonlinear years and
* months units, and all the other units.
*/
npy_bool
can_cast_datetime64_units(PANDAS_DATETIMEUNIT src_unit,
PANDAS_DATETIMEUNIT dst_unit,
NPY_CASTING casting);


int
convert_datetime_to_datetimestruct(pandas_datetime_metadata *meta,
Expand Down
Loading