Skip to content

Commit 9943b9b

Browse files
[pre-commit.ci] pre-commit autoupdate (#1942)
1 parent 6b30c10 commit 9943b9b

37 files changed

+162
-160
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- --exclude=scripts/
1414
- --start-year=2022
1515
- repo: https://github.com/astral-sh/ruff-pre-commit
16-
rev: v0.12.12
16+
rev: v0.13.0
1717
hooks:
1818
- id: ruff-check
1919
types_or: [python, pyi, jupyter]
@@ -23,7 +23,7 @@ repos:
2323
types_or: [python, pyi, jupyter]
2424
exclude: ^docs/source/notebooks/clv/dev/
2525
- repo: https://github.com/pre-commit/mirrors-mypy
26-
rev: v1.17.1
26+
rev: v1.18.1
2727
hooks:
2828
- id: mypy
2929
args: [--ignore-missing-imports]

docs/source/notebooks/mmm/mmm_lift_test.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@
617617
},
618618
{
619619
"cell_type": "code",
620-
"execution_count": 17,
620+
"execution_count": null,
621621
"id": "302995b6",
622622
"metadata": {
623623
"tags": [
@@ -678,7 +678,7 @@
678678
" original_scale=True\n",
679679
" )\n",
680680
"\n",
681-
" fig, ax = plt.subplots(\n",
681+
" _, ax = plt.subplots(\n",
682682
" nrows=2,\n",
683683
" figsize=(15, 8),\n",
684684
" ncols=1,\n",

docs/source/notebooks/mmm/mmm_tvp_example.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
},
274274
{
275275
"cell_type": "code",
276-
"execution_count": 4,
276+
"execution_count": null,
277277
"metadata": {},
278278
"outputs": [
279279
{
@@ -293,7 +293,7 @@
293293
}
294294
],
295295
"source": [
296-
"fig, ax = plt.subplots()\n",
296+
"_, ax = plt.subplots()\n",
297297
"DATA.set_index(\"Weeks\").plot(ax=ax)\n",
298298
"ax.set_title(\"Time series of the data\")\n",
299299
"ax.set_ylabel(\"Spending\")\n",
@@ -320,7 +320,7 @@
320320
},
321321
{
322322
"cell_type": "code",
323-
"execution_count": 5,
323+
"execution_count": null,
324324
"metadata": {},
325325
"outputs": [
326326
{
@@ -374,7 +374,7 @@
374374
" target = pm.draw(true_model.y, random_seed=SEED)\n",
375375
"\n",
376376
" # Plot the simulated target series\n",
377-
" fig, ax = plt.subplots()\n",
377+
" _, ax = plt.subplots()\n",
378378
" ax.set_title(\"Target\")\n",
379379
" ax.plot(DATA.Weeks, target, label=\"Sales\")\n",
380380
" ax.plot(DATA.Weeks, synthetic_intercept, label=\"Synthetic intercept\")\n",
@@ -531,7 +531,7 @@
531531
},
532532
{
533533
"cell_type": "code",
534-
"execution_count": 8,
534+
"execution_count": null,
535535
"metadata": {},
536536
"outputs": [
537537
{
@@ -610,7 +610,7 @@
610610
" mmm.y = target_series.values\n",
611611
"\n",
612612
" # Plot the posterior predictive\n",
613-
" fig, ax = plt.subplots()\n",
613+
" _, ax = plt.subplots()\n",
614614
" mmm.plot_posterior_predictive(original_scale=True, add_mean=False, ax=ax)\n",
615615
" split_index = DATA.shape[0] - SPLIT_N\n",
616616
" ax.axvline(\n",
@@ -727,7 +727,7 @@
727727
},
728728
{
729729
"cell_type": "code",
730-
"execution_count": 10,
730+
"execution_count": null,
731731
"metadata": {},
732732
"outputs": [
733733
{
@@ -761,7 +761,7 @@
761761
" )\n",
762762
"\n",
763763
" # Plot posterior intercept versus actual\n",
764-
" fig, ax = plt.subplots()\n",
764+
" _, ax = plt.subplots()\n",
765765
" ax.set_title(\"Posterior intercept vs actual\")\n",
766766
" ax.plot(\n",
767767
" mmm.posterior_predictive.date, intercept_posterior_mean, label=\"Posterior mean\"\n",

pymc_marketing/customer_choice/nested_logit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ def make_exp_nest(
536536
lambda_lkup = self.lambda_lkup
537537
N = U.shape[0]
538538
if "_" in nest:
539-
parent, child = nest.split("_")
539+
parent, _ = nest.split("_")
540540
else:
541541
parent = None
542542
y_nest = U[:, nest_indices[level][nest]]
@@ -707,7 +707,7 @@ def make_model(self, X, W, y) -> pm.Model:
707707

708708
for idx, n in enumerate(middle_nests):
709709
is_last = idx == len(middle_nests) - 1
710-
parent, child = n.split("_")
710+
parent, _ = n.split("_")
711711
P_nest = nest_prob_m[n]
712712
P_y_given_nest = cond_prob_m[n]["P_y_given"]
713713
prod = pm.Deterministic(

pymc_marketing/mmm/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def create_basis_matrix(df_events: pd.DataFrame, model_dates: np.ndarray):
118118
BasisMeta = create_registration_meta(BASIS_TRANSFORMATIONS)
119119

120120

121-
class Basis(Transformation, metaclass=BasisMeta): # type: ignore[misc]
121+
class Basis(Transformation, metaclass=BasisMeta): # type: ignore[metaclass]
122122
"""Basis transformation associated with an event model."""
123123

124124
prefix: str = "basis"

scripts/data_generators/multidimensional_data_generation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def main(
357357
rng = np.random.default_rng(seed)
358358

359359
# Generate dates
360-
dates, n_dates = get_dates(start_date, end_date)
360+
dates, _ = get_dates(start_date, end_date)
361361

362362
# Generate initial dataframe
363363
df = generate_dataframe(dates, geo_index, rng)

tests/clv/models/test_basic.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def test_fit_advi_with_wrong_chains_advi_kwargs(self, mocker):
143143

144144
with pytest.warns(
145145
UserWarning,
146-
match="The 'chains' parameter must be 1 with 'advi'. Sampling only 1 chain despite the provided parameter.",
146+
match=r"The 'chains' parameter must be 1 with 'advi'. Sampling only 1 chain despite the provided parameter.", # noqa: E501
147147
):
148148
model.fit(
149149
method="advi",
@@ -220,7 +220,7 @@ def mock_property(self):
220220
monkeypatch.setattr(CLVModelTest, "id", property(mock_property))
221221
with pytest.raises(
222222
DifferentModelError,
223-
match="The file 'test_model'",
223+
match=r"The file 'test_model'",
224224
):
225225
CLVModelTest.load("test_model")
226226
os.remove("test_model")
@@ -244,7 +244,7 @@ def test_model_config_warns(self) -> None:
244244
model_config = {
245245
"x": {"dist": "StudentT", "kwargs": {"mu": 0, "sigma": 5, "nu": 15}},
246246
}
247-
with pytest.warns(DeprecationWarning, match="x is automatically"):
247+
with pytest.warns(DeprecationWarning, match=r"x is automatically"):
248248
model = CLVModelTest(model_config=model_config)
249249

250250
assert model.model_config == {
@@ -274,7 +274,7 @@ def test_deprecation_warning_on_old_config(self):
274274
"x_prior": {"dist": "Normal", "kwargs": {"mu": 0, "sigma": 1}}
275275
}
276276
with pytest.warns(
277-
DeprecationWarning, match="The key 'x_prior' in model_config is deprecated"
277+
DeprecationWarning, match=r"The key 'x_prior' in model_config is deprecated"
278278
):
279279
model = CLVModelTest(model_config=old_model_config)
280280

tests/clv/models/test_beta_geo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ def test_customer_id_duplicate(self):
183183
)
184184

185185
with pytest.raises(
186-
ValueError, match="Column customer_id has duplicate entries"
186+
ValueError, match=r"Column customer_id has duplicate entries"
187187
):
188188
BetaGeoModel(
189189
data=data,
@@ -340,7 +340,7 @@ def test_model_convergence(self, method, rtol, model_config):
340340

341341
def test_fit_result_without_fit(self, mocker, model_config):
342342
model = BetaGeoModel(data=self.data, model_config=model_config)
343-
with pytest.raises(RuntimeError, match="The model hasn't been fit yet"):
343+
with pytest.raises(RuntimeError, match=r"The model hasn't been fit yet"):
344344
model.fit_result
345345

346346
mocker.patch("pymc.sample", mock_sample)

tests/clv/models/test_beta_geo_beta_binom.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def test_missing_cols(self):
208208

209209
def test_customer_id_duplicate(self):
210210
with pytest.raises(
211-
ValueError, match="Column customer_id has duplicate entries"
211+
ValueError, match=r"Column customer_id has duplicate entries"
212212
):
213213
data = pd.DataFrame(
214214
{
@@ -224,7 +224,7 @@ def test_customer_id_duplicate(self):
224224
)
225225

226226
def test_T_homogeneity(self):
227-
with pytest.raises(ValueError, match="Column T has non-homogeneous entries"):
227+
with pytest.raises(ValueError, match=r"Column T has non-homogeneous entries"):
228228
data = pd.DataFrame(
229229
{
230230
"customer_id": np.asarray([1, 2]),
@@ -312,7 +312,7 @@ def test_model_convergence(self, method, rtol, model_config):
312312

313313
def test_fit_result_without_fit(self, mocker, model_config):
314314
model = BetaGeoBetaBinomModel(data=self.pred_data, model_config=model_config)
315-
with pytest.raises(RuntimeError, match="The model hasn't been fit yet"):
315+
with pytest.raises(RuntimeError, match=r"The model hasn't been fit yet"):
316316
model.fit_result
317317

318318
mocker.patch("pymc.sample", mock_sample)

tests/clv/models/test_modified_beta_geo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_missing_cols(self, missing_column):
152152

153153
def test_customer_id_duplicate(self):
154154
with pytest.raises(
155-
ValueError, match="Column customer_id has duplicate entries"
155+
ValueError, match=r"Column customer_id has duplicate entries"
156156
):
157157
data = pd.DataFrame(
158158
{
@@ -239,7 +239,7 @@ def test_model_convergence(self, method, rtol, model_config):
239239

240240
def test_fit_result_without_fit(self, mocker, model_config):
241241
model = ModifiedBetaGeoModel(data=self.data, model_config=model_config)
242-
with pytest.raises(RuntimeError, match="The model hasn't been fit yet"):
242+
with pytest.raises(RuntimeError, match=r"The model hasn't been fit yet"):
243243
model.fit_result
244244

245245
mocker.patch("pymc.sample", mock_sample)
@@ -283,7 +283,7 @@ def tests_expected_probability_no_purchases_raises_exception(self):
283283

284284
with pytest.raises(
285285
NotImplementedError,
286-
match="The MBG/NBD model does not support this method.",
286+
match=r"The MBG/NBD model does not support this method.",
287287
):
288288
mbg_model.expected_probability_no_purchase(t=test_t, data=data)
289289

0 commit comments

Comments
 (0)