Skip to content

Commit

Permalink
STY: Boolean values for bint variables (#33008)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaharNaveh authored Mar 26, 2020
1 parent 8786e02 commit 218cc30
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
27 changes: 14 additions & 13 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def ints_to_pydatetime(
const int64_t[:] arr,
object tz=None,
object freq=None,
bint fold=0,
bint fold=False,
str box="datetime"
):
"""
Expand Down Expand Up @@ -288,7 +288,8 @@ def format_array_from_datetime(
cdef:
int64_t val, ns, N = len(values)
ndarray[int64_t] consider_values
bint show_ms = 0, show_us = 0, show_ns = 0, basic_format = 0
bint show_ms = False, show_us = False, show_ns = False
bint basic_format = False
ndarray[object] result = np.empty(N, dtype=object)
object ts, res
npy_datetimestruct dts
Expand Down Expand Up @@ -576,10 +577,10 @@ cpdef array_to_datetime(
ndarray[object] oresult
npy_datetimestruct dts
bint utc_convert = bool(utc)
bint seen_integer = 0
bint seen_string = 0
bint seen_datetime = 0
bint seen_datetime_offset = 0
bint seen_integer = False
bint seen_string = False
bint seen_datetime = False
bint seen_datetime_offset = False
bint is_raise = errors=='raise'
bint is_ignore = errors=='ignore'
bint is_coerce = errors=='coerce'
Expand All @@ -606,7 +607,7 @@ cpdef array_to_datetime(
iresult[i] = NPY_NAT

elif PyDateTime_Check(val):
seen_datetime = 1
seen_datetime = True
if val.tzinfo is not None:
if utc_convert:
_ts = convert_datetime_to_tsobject(val, None)
Expand All @@ -622,17 +623,17 @@ cpdef array_to_datetime(
check_dts_bounds(&dts)

elif PyDate_Check(val):
seen_datetime = 1
seen_datetime = True
iresult[i] = pydate_to_dt64(val, &dts)
check_dts_bounds(&dts)

elif is_datetime64_object(val):
seen_datetime = 1
seen_datetime = True
iresult[i] = get_datetime64_nanos(val)

elif is_integer_object(val) or is_float_object(val):
# these must be ns unit by-definition
seen_integer = 1
seen_integer = True

if val != val or val == NPY_NAT:
iresult[i] = NPY_NAT
Expand All @@ -651,7 +652,7 @@ cpdef array_to_datetime(

elif isinstance(val, str):
# string
seen_string = 1
seen_string = True

if len(val) == 0 or val in nat_strings:
iresult[i] = NPY_NAT
Expand Down Expand Up @@ -693,7 +694,7 @@ cpdef array_to_datetime(
raise TypeError("invalid string coercion to datetime")

if tz is not None:
seen_datetime_offset = 1
seen_datetime_offset = True
# dateutil timezone objects cannot be hashed, so
# store the UTC offsets in seconds instead
out_tzoffset_vals.add(tz.total_seconds())
Expand All @@ -709,7 +710,7 @@ cpdef array_to_datetime(
# where we left off
value = dtstruct_to_dt64(&dts)
if out_local == 1:
seen_datetime_offset = 1
seen_datetime_offset = True
# Store the out_tzoffset in seconds
# since we store the total_seconds of
# dateutil.tz.tzoffset objects
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/window/aggregations.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def roll_median_c(ndarray[float64_t] values, ndarray[int64_t] start,
ndarray[int64_t] end, int64_t minp, int64_t win):
cdef:
float64_t val, res, prev
bint err = 0
bint err = False
int ret = 0
skiplist_t *sl
Py_ssize_t i, j
Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/writers.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def convert_json_to_lines(arr: object) -> str:
"""
cdef:
Py_ssize_t i = 0, num_open_brackets_seen = 0, length
bint in_quotes = 0, is_escaping = 0
bint in_quotes = False, is_escaping = False
ndarray[uint8_t, ndim=1] narr
unsigned char val, newline, comma, left_bracket, right_bracket, quote
unsigned char backslash
Expand Down

0 comments on commit 218cc30

Please sign in to comment.