Skip to content

Commit ca287cf

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a5e8bfa commit ca287cf

11 files changed

+32
-40
lines changed

patsy/build.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def _build_subterm(subterm, factor_infos, factor_values, out):
285285
contrast = subterm.contrast_matrices[factor]
286286
if np.any(factor_values[factor] < 0):
287287
raise PatsyError(
288-
"can't build a design matrix " "containing missing values",
288+
"can't build a design matrix containing missing values",
289289
factor,
290290
)
291291
out[:, i] *= contrast.matrix[factor_values[factor], column_idx]
@@ -929,9 +929,7 @@ def build_design_matrices(
929929
if isinstance(NA_action, str):
930930
NA_action = NAAction(NA_action)
931931
if return_type == "dataframe" and not have_pandas:
932-
raise PatsyError(
933-
"pandas.DataFrame was requested, but pandas " "is not installed"
934-
)
932+
raise PatsyError("pandas.DataFrame was requested, but pandas is not installed")
935933
if return_type not in ("matrix", "dataframe"):
936934
raise PatsyError(
937935
"unrecognized output type %r, should be "

patsy/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def categorical_to_int(data, levels, NA_action, origin=None):
354354
level_to_int = dict(zip(levels, range(len(levels))))
355355
except TypeError:
356356
raise PatsyError(
357-
"Error interpreting categorical data: " "all items must be hashable", origin
357+
"Error interpreting categorical data: all items must be hashable", origin
358358
)
359359

360360
# fastpath to avoid doing an item-by-item iteration over boolean arrays,

patsy/constraint.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _eval_binary_div(self, tree):
314314
right = self.eval(tree.args[1])
315315
if not self.is_constant(right):
316316
raise PatsyError(
317-
"Can't divide by a variable in a linear " "constraint", tree.args[1]
317+
"Can't divide by a variable in a linear constraint", tree.args[1]
318318
)
319319
return left / right[-1]
320320

@@ -327,7 +327,7 @@ def _eval_binary_multiply(self, tree):
327327
return left * right[-1]
328328
else:
329329
raise PatsyError(
330-
"Can't multiply one variable by another " "in a linear constraint", tree
330+
"Can't multiply one variable by another in a linear constraint", tree
331331
)
332332

333333
def _eval_binary_eq(self, tree):

patsy/desc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def _eval_binary_minus(evaluator, tree):
298298
def _check_interactable(expr):
299299
if expr.intercept:
300300
raise PatsyError(
301-
"intercept term cannot interact with " "anything else",
301+
"intercept term cannot interact with anything else",
302302
expr.intercept_origin,
303303
)
304304

@@ -392,7 +392,7 @@ def _eval_one(evaluator, tree):
392392

393393

394394
def _eval_number(evaluator, tree):
395-
raise PatsyError("numbers besides '0' and '1' are " "only allowed with **", tree)
395+
raise PatsyError("numbers besides '0' and '1' are only allowed with **", tree)
396396

397397

398398
def _eval_python_expr(evaluator, tree):
@@ -437,14 +437,14 @@ def eval(self, tree, require_evalexpr=True):
437437
key = (tree.type, len(tree.args))
438438
if key not in self._evaluators:
439439
raise PatsyError(
440-
"I don't know how to evaluate this " "'%s' operator" % (tree.type,),
440+
"I don't know how to evaluate this '%s' operator" % (tree.type,),
441441
tree.token,
442442
)
443443
result = self._evaluators[key](self, tree)
444444
if require_evalexpr and not isinstance(result, IntermediateExpr):
445445
if isinstance(result, ModelDesc):
446446
raise PatsyError(
447-
"~ can only be used once, and " "only at the top level", tree
447+
"~ can only be used once, and only at the top level", tree
448448
)
449449
else:
450450
raise PatsyError(

patsy/design_info.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ def __init__(self, factor, type, state, num_columns=None, categories=None):
8888
if self.type == "numerical":
8989
if not isinstance(num_columns, int):
9090
raise ValueError(
91-
"For numerical factors, num_columns " "must be an integer"
91+
"For numerical factors, num_columns must be an integer"
9292
)
9393
if categories is not None:
94-
raise ValueError("For numerical factors, categories " "must be None")
94+
raise ValueError("For numerical factors, categories must be None")
9595
else:
9696
assert self.type == "categorical"
9797
if num_columns is not None:
98-
raise ValueError("For categorical factors, num_columns " "must be None")
98+
raise ValueError("For categorical factors, num_columns must be None")
9999
categories = tuple(categories)
100100
self.num_columns = num_columns
101101
self.categories = categories
@@ -280,8 +280,7 @@ def __init__(self, column_names, factor_infos=None, term_codings=None):
280280

281281
if (factor_infos is None) != (term_codings is None):
282282
raise ValueError(
283-
"Must specify either both or neither of "
284-
"factor_infos= and term_codings="
283+
"Must specify either both or neither of factor_infos= and term_codings="
285284
)
286285

287286
self.factor_infos = factor_infos
@@ -304,17 +303,15 @@ def __init__(self, column_names, factor_infos=None, term_codings=None):
304303
term_factors = set(term.factors)
305304
for subterm in subterms:
306305
if not isinstance(subterm, SubtermInfo):
307-
raise ValueError("expected SubtermInfo, " "not %r" % (subterm,))
306+
raise ValueError("expected SubtermInfo, not %r" % (subterm,))
308307
if not term_factors.issuperset(subterm.factors):
309308
raise ValueError("unexpected factors in subterm")
310309

311310
all_factors = set()
312311
for term in self.term_codings:
313312
all_factors.update(term.factors)
314313
if all_factors != set(self.factor_infos):
315-
raise ValueError(
316-
"Provided Term objects and factor_infos " "do not match"
317-
)
314+
raise ValueError("Provided Term objects and factor_infos do not match")
318315
for factor, factor_info in self.factor_infos.items():
319316
if not isinstance(factor_info, FactorInfo):
320317
raise ValueError(
@@ -343,8 +340,7 @@ def __init__(self, column_names, factor_infos=None, term_codings=None):
343340
exp_cols *= cm.shape[1]
344341
if cat_factors != set(subterm.contrast_matrices):
345342
raise ValueError(
346-
"Mismatch between contrast_matrices "
347-
"and categorical factors"
343+
"Mismatch between contrast_matrices and categorical factors"
348344
)
349345
if exp_cols != subterm.num_columns:
350346
raise ValueError("Unexpected num_columns")
@@ -368,7 +364,7 @@ def __init__(self, column_names, factor_infos=None, term_codings=None):
368364
idx += term_columns
369365
if idx != len(self.column_names):
370366
raise ValueError(
371-
"mismatch between column_names and columns " "coded by given terms"
367+
"mismatch between column_names and columns coded by given terms"
372368
)
373369
self.term_name_slices = OrderedDict(
374370
[(term.name(), slice_) for (term, slice_) in self.term_slices.items()]

patsy/eval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def new_name_maker(token):
526526
# original code
527527
if has_bare_variable_reference(state["transforms"], self.code):
528528
raise PatsyError(
529-
"names of this form are reserved for " "internal use (%s)" % (token,),
529+
"names of this form are reserved for internal use (%s)" % (token,),
530530
token.origin,
531531
)
532532
# Pull out all the '_patsy_stobj0__center__.transform(x)' pieces

patsy/highlevel.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def iter_maker():
107107
raise PatsyError("bad formula-like object")
108108
if len(design_infos[0].column_names) > 0:
109109
raise PatsyError(
110-
"encountered outcome variables for a model " "that does not expect them"
110+
"encountered outcome variables for a model that does not expect them"
111111
)
112112
return design_infos[1]
113113

@@ -149,9 +149,7 @@ def incr_dbuilders(formula_like, data_iter_maker, eval_env=0, NA_action="drop"):
149149
# any object with a special method __patsy_get_model_desc__
150150
def _do_highlevel_design(formula_like, data, eval_env, NA_action, return_type):
151151
if return_type == "dataframe" and not have_pandas:
152-
raise PatsyError(
153-
"pandas.DataFrame was requested, but pandas " "is not installed"
154-
)
152+
raise PatsyError("pandas.DataFrame was requested, but pandas is not installed")
155153
if return_type not in ("matrix", "dataframe"):
156154
raise PatsyError(
157155
"unrecognized output type %r, should be "
@@ -219,7 +217,7 @@ def _regularize_matrix(m, default_column_prefix):
219217
if rhs_orig_index is not None and lhs_orig_index is not None:
220218
if not rhs_orig_index.equals(lhs_orig_index):
221219
raise PatsyError(
222-
"index mismatch: outcome and " "predictor have incompatible indexes"
220+
"index mismatch: outcome and predictor have incompatible indexes"
223221
)
224222
if return_type == "dataframe":
225223
if rhs_orig_index is not None and lhs_orig_index is None:
@@ -298,7 +296,7 @@ def dmatrix(formula_like, data={}, eval_env=0, NA_action="drop", return_type="ma
298296
)
299297
if lhs.shape[1] != 0:
300298
raise PatsyError(
301-
"encountered outcome variables for a model " "that does not expect them"
299+
"encountered outcome variables for a model that does not expect them"
302300
)
303301
return rhs
304302

patsy/mgcv_cubic_splines.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def _row_tensor_product(dms):
161161
for dm in dms:
162162
if dm.shape[0] != tp_nrows:
163163
raise ValueError(
164-
"Tensor product arguments should have " "same number of rows."
164+
"Tensor product arguments should have same number of rows."
165165
)
166166
tp_ncols *= dm.shape[1]
167167
tp = np.zeros((tp_nrows, tp_ncols))
@@ -624,7 +624,7 @@ def memorize_chunk(
624624
x = x[:, 0]
625625
if x.ndim > 1:
626626
raise ValueError(
627-
"Input to %r must be 1-d, " "or a 2-d column vector." % (self._name,)
627+
"Input to %r must be 1-d, or a 2-d column vector." % (self._name,)
628628
)
629629

630630
self._tmp.setdefault("xs", []).append(x)
@@ -649,7 +649,7 @@ def memorize_finish(self):
649649
else:
650650
constraints = np.atleast_2d(constraints)
651651
if constraints.ndim != 2:
652-
raise ValueError("Constraints must be 2-d array or " "1-d vector.")
652+
raise ValueError("Constraints must be 2-d array or 1-d vector.")
653653
n_constraints = constraints.shape[0]
654654

655655
n_inner_knots = None
@@ -704,7 +704,7 @@ def transform(
704704
x = x[:, 0]
705705
if x.ndim > 1:
706706
raise ValueError(
707-
"Input to %r must be 1-d, " "or a 2-d column vector." % (self._name,)
707+
"Input to %r must be 1-d, or a 2-d column vector." % (self._name,)
708708
)
709709
dm = _get_crs_dmatrix(
710710
x, self._all_knots, self._constraints, cyclic=self._cyclic
@@ -982,7 +982,7 @@ def memorize_finish(self):
982982
else:
983983
constraints = np.atleast_2d(constraints)
984984
if constraints.ndim != 2:
985-
raise ValueError("Constraints must be 2-d array or " "1-d vector.")
985+
raise ValueError("Constraints must be 2-d array or 1-d vector.")
986986

987987
self._constraints = constraints
988988

@@ -992,7 +992,7 @@ def transform(self, *args, **kwargs):
992992
arg = atleast_2d_column_default(arg)
993993
if arg.ndim != 2:
994994
raise ValueError(
995-
"Each tensor product argument must be " "a 2-d array or 1-d vector."
995+
"Each tensor product argument must be a 2-d array or 1-d vector."
996996
)
997997
args_2d.append(arg)
998998

@@ -1190,7 +1190,7 @@ def test_te_2smooths():
11901190
assert np.allclose(dmatrix_nocons, dmatrix_R_nocons, rtol=1e-12, atol=0.0)
11911191

11921192
builder = incr_dbuilder(
1193-
"te(cr(x1, df=5), cc(x2, df=6), " "constraints='center') - 1",
1193+
"te(cr(x1, df=5), cc(x2, df=6), constraints='center') - 1",
11941194
lambda: iter(data_chunked),
11951195
)
11961196
dmatrix_cons = build_design_matrices([builder], new_data)[0]

patsy/parse_formula.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _read_python_expr(it, end_tokens):
6969
return Token(token_type, Origin.combine(origins), extra=expr_text)
7070
else:
7171
raise PatsyError(
72-
"unclosed bracket in embedded Python " "expression", Origin.combine(origins)
72+
"unclosed bracket in embedded Python expression", Origin.combine(origins)
7373
)
7474

7575

patsy/splines.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def memorize_chunk(
171171
if x.ndim == 2 and x.shape[1] == 1:
172172
x = x[:, 0]
173173
if x.ndim > 1:
174-
raise ValueError("input to 'bs' must be 1-d, " "or a 2-d column vector")
174+
raise ValueError("input to 'bs' must be 1-d, or a 2-d column vector")
175175
# There's no better way to compute exact quantiles than memorizing
176176
# all data.
177177
self._tmp.setdefault("xs", []).append(x)

patsy/tokens.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def python_tokenize(code):
3838
origin = Origin(code, start, end)
3939
if pytype == tokenize.ERRORTOKEN:
4040
raise PatsyError(
41-
"error tokenizing input " "(maybe an unclosed string?)", origin
41+
"error tokenizing input (maybe an unclosed string?)", origin
4242
)
4343
if pytype == tokenize.COMMENT:
4444
raise PatsyError("comments are not allowed", origin)

0 commit comments

Comments
 (0)