Skip to content

Commit 62d16ab

Browse files
ShaharNavehsimonjayhawkins
authored andcommitted
STY: concat strings that should not be seperated (#30942)
1 parent 2c76d06 commit 62d16ab

File tree

8 files changed

+68
-49
lines changed

8 files changed

+68
-49
lines changed

pandas/_libs/algos.pyx

+3-6
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,7 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
914914
ranks[argsorted[j]] = i + 1
915915
elif tiebreak == TIEBREAK_FIRST:
916916
if rank_t is object:
917-
raise ValueError('first not supported for '
918-
'non-numeric data')
917+
raise ValueError('first not supported for non-numeric data')
919918
else:
920919
for j in range(i - dups + 1, i + 1):
921920
ranks[argsorted[j]] = j + 1
@@ -971,8 +970,7 @@ def rank_1d(rank_t[:] in_arr, ties_method='average',
971970
ranks[argsorted[j]] = i + 1
972971
elif tiebreak == TIEBREAK_FIRST:
973972
if rank_t is object:
974-
raise ValueError('first not supported for '
975-
'non-numeric data')
973+
raise ValueError('first not supported for non-numeric data')
976974
else:
977975
for j in range(i - dups + 1, i + 1):
978976
ranks[argsorted[j]] = j + 1
@@ -1137,8 +1135,7 @@ def rank_2d(rank_t[:, :] in_arr, axis=0, ties_method='average',
11371135
ranks[i, argsorted[i, z]] = j + 1
11381136
elif tiebreak == TIEBREAK_FIRST:
11391137
if rank_t is object:
1140-
raise ValueError('first not supported '
1141-
'for non-numeric data')
1138+
raise ValueError('first not supported for non-numeric data')
11421139
else:
11431140
for z in range(j - dups + 1, j + 1):
11441141
ranks[i, argsorted[i, z]] = z + 1

pandas/_libs/groupby.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,7 @@ def _group_ohlc(floating[:, :] out,
686686
raise ValueError('Output array must have 4 columns')
687687

688688
if K > 1:
689-
raise NotImplementedError("Argument 'values' must have only "
690-
"one dimension")
689+
raise NotImplementedError("Argument 'values' must have only one dimension")
691690
out[:] = np.nan
692691

693692
with nogil:

pandas/_libs/hashing.pyx

+7-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
5151
k = <bytes>key.encode(encoding)
5252
kb = <uint8_t *>k
5353
if len(k) != 16:
54-
raise ValueError("key should be a 16-byte string encoded, "
55-
f"got {k} (len {len(k)})")
54+
raise ValueError(
55+
f"key should be a 16-byte string encoded, got {k} (len {len(k)})"
56+
)
5657

5758
n = len(arr)
5859

@@ -77,8 +78,10 @@ def hash_object_array(object[:] arr, object key, object encoding='utf8'):
7778
hash(val)
7879
data = <bytes>str(val).encode(encoding)
7980
else:
80-
raise TypeError(f"{val} of type {type(val)} is not a valid type "
81-
"for hashing, must be string or null")
81+
raise TypeError(
82+
f"{val} of type {type(val)} is not a valid type for hashing, "
83+
"must be string or null"
84+
)
8285

8386
l = len(data)
8487
lens[i] = l

pandas/_libs/indexing.pyx

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ cdef class _NDFrameIndexerBase:
1818
if ndim is None:
1919
ndim = self._ndim = self.obj.ndim
2020
if ndim > 2:
21-
raise ValueError("NDFrameIndexer does not support "
22-
"NDFrame objects with ndim > 2")
21+
raise ValueError(
22+
"NDFrameIndexer does not support NDFrame objects with ndim > 2"
23+
)
2324
return ndim

pandas/_libs/sparse.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ cdef class IntIndex(SparseIndex):
7272
"""
7373

7474
if self.npoints > self.length:
75-
msg = (f"Too many indices. Expected "
76-
f"{self.length} but found {self.npoints}")
77-
raise ValueError(msg)
75+
raise ValueError(
76+
f"Too many indices. Expected {self.length} but found {self.npoints}"
77+
)
7878

7979
# Indices are vacuously ordered and non-negative
8080
# if the sequence of indices is empty.

pandas/_libs/testing.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ cpdef assert_almost_equal(a, b,
127127
# classes can't be the same, to raise error
128128
assert_class_equal(a, b, obj=obj)
129129

130-
assert has_length(a) and has_length(b), ("Can't compare objects without "
131-
"length, one or both is invalid: "
132-
f"({a}, {b})")
130+
assert has_length(a) and has_length(b), (
131+
f"Can't compare objects without length, one or both is invalid: ({a}, {b})"
132+
)
133133

134134
if a_is_ndarray and b_is_ndarray:
135135
na, nb = a.size, b.size

pandas/_libs/tslibs/timestamps.pyx

+47-27
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ def round_nsint64(values, mode, freq):
161161

162162
# if/elif above should catch all rounding modes defined in enum 'RoundTo':
163163
# if flow of control arrives here, it is a bug
164-
raise ValueError("round_nsint64 called with an unrecognized "
165-
"rounding mode")
164+
raise ValueError("round_nsint64 called with an unrecognized rounding mode")
166165

167166

168167
# ----------------------------------------------------------------------
@@ -324,8 +323,10 @@ class Timestamp(_Timestamp):
324323
325324
Function is not implemented. Use pd.to_datetime().
326325
"""
327-
raise NotImplementedError("Timestamp.strptime() is not implemented."
328-
"Use to_datetime() to parse date strings.")
326+
raise NotImplementedError(
327+
"Timestamp.strptime() is not implemented. "
328+
"Use to_datetime() to parse date strings."
329+
)
329330

330331
@classmethod
331332
def combine(cls, date, time):
@@ -381,8 +382,9 @@ class Timestamp(_Timestamp):
381382
if tzinfo is not None:
382383
if not PyTZInfo_Check(tzinfo):
383384
# tzinfo must be a datetime.tzinfo object, GH#17690
384-
raise TypeError(f'tzinfo must be a datetime.tzinfo object, '
385-
f'not {type(tzinfo)}')
385+
raise TypeError(
386+
f"tzinfo must be a datetime.tzinfo object, not {type(tzinfo)}"
387+
)
386388
elif tz is not None:
387389
raise ValueError('Can provide at most one of tz, tzinfo')
388390

@@ -393,8 +395,10 @@ class Timestamp(_Timestamp):
393395
# User passed a date string to parse.
394396
# Check that the user didn't also pass a date attribute kwarg.
395397
if any(arg is not None for arg in _date_attributes):
396-
raise ValueError('Cannot pass a date attribute keyword '
397-
'argument when passing a date string')
398+
raise ValueError(
399+
"Cannot pass a date attribute keyword "
400+
"argument when passing a date string"
401+
)
398402

399403
elif ts_input is _no_input:
400404
# User passed keyword arguments.
@@ -578,8 +582,10 @@ timedelta}, default 'raise'
578582
@tz.setter
579583
def tz(self, value):
580584
# GH 3746: Prevent localizing or converting the index by setting tz
581-
raise AttributeError("Cannot directly set timezone. Use tz_localize() "
582-
"or tz_convert() as appropriate")
585+
raise AttributeError(
586+
"Cannot directly set timezone. "
587+
"Use tz_localize() or tz_convert() as appropriate"
588+
)
583589

584590
def __setstate__(self, state):
585591
self.value = state[0]
@@ -598,9 +604,10 @@ timedelta}, default 'raise'
598604

599605
if self.tz is not None:
600606
# GH#21333
601-
warnings.warn("Converting to Period representation will "
602-
"drop timezone information.",
603-
UserWarning)
607+
warnings.warn(
608+
"Converting to Period representation will drop timezone information.",
609+
UserWarning,
610+
)
604611

605612
if freq is None:
606613
freq = self.freq
@@ -810,13 +817,13 @@ default 'raise'
810817
if ambiguous == 'infer':
811818
raise ValueError('Cannot infer offset with only one time.')
812819

813-
nonexistent_options = ('raise', 'NaT', 'shift_forward',
814-
'shift_backward')
820+
nonexistent_options = ('raise', 'NaT', 'shift_forward', 'shift_backward')
815821
if nonexistent not in nonexistent_options and not isinstance(
816822
nonexistent, timedelta):
817-
raise ValueError("The nonexistent argument must be one of 'raise', "
818-
"'NaT', 'shift_forward', 'shift_backward' or "
819-
"a timedelta object")
823+
raise ValueError(
824+
"The nonexistent argument must be one of 'raise', "
825+
"'NaT', 'shift_forward', 'shift_backward' or a timedelta object"
826+
)
820827

821828
if self.tzinfo is None:
822829
# tz naive, localize
@@ -833,8 +840,9 @@ default 'raise'
833840
value = tz_convert_single(self.value, UTC, self.tz)
834841
return Timestamp(value, tz=tz, freq=self.freq)
835842
else:
836-
raise TypeError('Cannot localize tz-aware Timestamp, use '
837-
'tz_convert for conversions')
843+
raise TypeError(
844+
"Cannot localize tz-aware Timestamp, use tz_convert for conversions"
845+
)
838846

839847
def tz_convert(self, tz):
840848
"""
@@ -857,17 +865,28 @@ default 'raise'
857865
"""
858866
if self.tzinfo is None:
859867
# tz naive, use tz_localize
860-
raise TypeError('Cannot convert tz-naive Timestamp, use '
861-
'tz_localize to localize')
868+
raise TypeError(
869+
"Cannot convert tz-naive Timestamp, use tz_localize to localize"
870+
)
862871
else:
863872
# Same UTC timestamp, different time zone
864873
return Timestamp(self.value, tz=tz, freq=self.freq)
865874

866875
astimezone = tz_convert
867876

868-
def replace(self, year=None, month=None, day=None,
869-
hour=None, minute=None, second=None, microsecond=None,
870-
nanosecond=None, tzinfo=object, fold=0):
877+
def replace(
878+
self,
879+
year=None,
880+
month=None,
881+
day=None,
882+
hour=None,
883+
minute=None,
884+
second=None,
885+
microsecond=None,
886+
nanosecond=None,
887+
tzinfo=object,
888+
fold=0,
889+
):
871890
"""
872891
implements datetime.replace, handles nanoseconds.
873892
@@ -910,8 +929,9 @@ default 'raise'
910929
def validate(k, v):
911930
""" validate integers """
912931
if not is_integer_object(v):
913-
raise ValueError(f"value must be an integer, received "
914-
f"{type(v)} for {k}")
932+
raise ValueError(
933+
f"value must be an integer, received {type(v)} for {k}"
934+
)
915935
return v
916936

917937
if year is not None:

pandas/_libs/window/aggregations.pyx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,7 @@ def ewmcov(float64_t[:] input_x, float64_t[:] input_y,
18711871
bint is_observation
18721872

18731873
if <Py_ssize_t>len(input_y) != N:
1874-
raise ValueError(f"arrays are of different lengths "
1875-
f"({N} and {len(input_y)})")
1874+
raise ValueError(f"arrays are of different lengths ({N} and {len(input_y)})")
18761875

18771876
output = np.empty(N, dtype=float)
18781877
if N == 0:

0 commit comments

Comments
 (0)