Skip to content

Commit 218cc30

Browse files
authored
STY: Boolean values for bint variables (#33008)
1 parent 8786e02 commit 218cc30

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

pandas/_libs/tslib.pyx

+14-13
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def ints_to_pydatetime(
114114
const int64_t[:] arr,
115115
object tz=None,
116116
object freq=None,
117-
bint fold=0,
117+
bint fold=False,
118118
str box="datetime"
119119
):
120120
"""
@@ -288,7 +288,8 @@ def format_array_from_datetime(
288288
cdef:
289289
int64_t val, ns, N = len(values)
290290
ndarray[int64_t] consider_values
291-
bint show_ms = 0, show_us = 0, show_ns = 0, basic_format = 0
291+
bint show_ms = False, show_us = False, show_ns = False
292+
bint basic_format = False
292293
ndarray[object] result = np.empty(N, dtype=object)
293294
object ts, res
294295
npy_datetimestruct dts
@@ -576,10 +577,10 @@ cpdef array_to_datetime(
576577
ndarray[object] oresult
577578
npy_datetimestruct dts
578579
bint utc_convert = bool(utc)
579-
bint seen_integer = 0
580-
bint seen_string = 0
581-
bint seen_datetime = 0
582-
bint seen_datetime_offset = 0
580+
bint seen_integer = False
581+
bint seen_string = False
582+
bint seen_datetime = False
583+
bint seen_datetime_offset = False
583584
bint is_raise = errors=='raise'
584585
bint is_ignore = errors=='ignore'
585586
bint is_coerce = errors=='coerce'
@@ -606,7 +607,7 @@ cpdef array_to_datetime(
606607
iresult[i] = NPY_NAT
607608

608609
elif PyDateTime_Check(val):
609-
seen_datetime = 1
610+
seen_datetime = True
610611
if val.tzinfo is not None:
611612
if utc_convert:
612613
_ts = convert_datetime_to_tsobject(val, None)
@@ -622,17 +623,17 @@ cpdef array_to_datetime(
622623
check_dts_bounds(&dts)
623624

624625
elif PyDate_Check(val):
625-
seen_datetime = 1
626+
seen_datetime = True
626627
iresult[i] = pydate_to_dt64(val, &dts)
627628
check_dts_bounds(&dts)
628629

629630
elif is_datetime64_object(val):
630-
seen_datetime = 1
631+
seen_datetime = True
631632
iresult[i] = get_datetime64_nanos(val)
632633

633634
elif is_integer_object(val) or is_float_object(val):
634635
# these must be ns unit by-definition
635-
seen_integer = 1
636+
seen_integer = True
636637

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

652653
elif isinstance(val, str):
653654
# string
654-
seen_string = 1
655+
seen_string = True
655656

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

695696
if tz is not None:
696-
seen_datetime_offset = 1
697+
seen_datetime_offset = True
697698
# dateutil timezone objects cannot be hashed, so
698699
# store the UTC offsets in seconds instead
699700
out_tzoffset_vals.add(tz.total_seconds())
@@ -709,7 +710,7 @@ cpdef array_to_datetime(
709710
# where we left off
710711
value = dtstruct_to_dt64(&dts)
711712
if out_local == 1:
712-
seen_datetime_offset = 1
713+
seen_datetime_offset = True
713714
# Store the out_tzoffset in seconds
714715
# since we store the total_seconds of
715716
# dateutil.tz.tzoffset objects

pandas/_libs/window/aggregations.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def roll_median_c(ndarray[float64_t] values, ndarray[int64_t] start,
846846
ndarray[int64_t] end, int64_t minp, int64_t win):
847847
cdef:
848848
float64_t val, res, prev
849-
bint err = 0
849+
bint err = False
850850
int ret = 0
851851
skiplist_t *sl
852852
Py_ssize_t i, j

pandas/_libs/writers.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def convert_json_to_lines(arr: object) -> str:
8282
"""
8383
cdef:
8484
Py_ssize_t i = 0, num_open_brackets_seen = 0, length
85-
bint in_quotes = 0, is_escaping = 0
85+
bint in_quotes = False, is_escaping = False
8686
ndarray[uint8_t, ndim=1] narr
8787
unsigned char val, newline, comma, left_bracket, right_bracket, quote
8888
unsigned char backslash

0 commit comments

Comments
 (0)