Skip to content

Commit

Permalink
add ruff linter and formater
Browse files Browse the repository at this point in the history
  • Loading branch information
juanitorduz authored and twiecki committed Nov 6, 2023
1 parent fb938bf commit 5e1a69f
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 37 deletions.
17 changes: 4 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: [--profile, black]
types: [python]
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.2.0
hooks:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
![Build](https://github.com/pymc-labs/pymc-marketing/workflows/ci/badge.svg)
[![codecov](https://codecov.io/gh/pymc-labs/pymc-marketing/branch/main/graph/badge.svg?token=OBV3BS5TYE)](https://codecov.io/gh/pymc-labs/pymc-marketing)
[![docs](https://readthedocs.org/projects/pymc-marketing/badge/?version=latest)](https://docs.readthedocs.io/en/latest/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![PyPI Version](https://img.shields.io/pypi/v/pymc-marketing.svg)](https://pypi.python.org/pypi/pymc-marketing)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Expand Down
2 changes: 2 additions & 0 deletions pymc_marketing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
from pymc_marketing import clv, mmm
from pymc_marketing.version import __version__

__all__ = ["clv", "mmm", "__version__"]
3 changes: 3 additions & 0 deletions pymc_marketing/clv/distributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ class ContNonContract(PositiveContinuous):
the easy way: An alternative to the Pareto/NBD model." Marketing science
24.2 (2005): 275-284.
"""

rv_op = continuous_non_contractual

@classmethod
Expand Down Expand Up @@ -210,6 +211,7 @@ class ContContract(PositiveContinuous):
======== ===============================================
"""

rv_op = continuous_contractual

@classmethod
Expand Down Expand Up @@ -387,6 +389,7 @@ class ParetoNBD(PositiveContinuous):
"A Note on Deriving the Pareto/NBD Model and Related Expressions."
http://brucehardie.com/notes/009/pareto_nbd_derivations_2005-11-05.pdf
"""

rv_op = pareto_nbd

@classmethod
Expand Down
14 changes: 14 additions & 0 deletions pymc_marketing/mmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,17 @@
preprocessing_method_y,
)
from pymc_marketing.mmm.validating import validation_method_X, validation_method_y

__all__ = [
"base",
"delayed_saturated_mmm",
"preprocessing",
"validating",
"MMM",
"BaseMMM",
"DelayedSaturatedMMM",
"preprocessing_method_X",
"preprocessing_method_y",
"validation_method_X",
"validation_method_y",
]
1 change: 0 additions & 1 deletion pymc_marketing/mmm/budget_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def budget_allocator(
parameters: Dict[str, Tuple[float, float]],
budget_ranges: Optional[Dict[str, Tuple[float, float]]],
) -> DataFrame:

optimal_budget = optimize_budget_distribution(
method=method,
total_budget=total_budget,
Expand Down
24 changes: 6 additions & 18 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pymc-marketing"
description = "Marketing Statistical Models in PyMC"
requires-python = ">=3.9"
readme = "README.md"
license = {file = "LICENSE"}
license = { file = "LICENSE" }
dynamic = ["version"]
maintainers = [{ name = "PyMC Labs", email = "[email protected]" }]

Expand Down Expand Up @@ -35,22 +35,15 @@ docs = [
"sphinx-autodoc-typehints",
"sphinxext-opengraph",
"sphinx-notfound-page",
"sphinx-design"
"sphinx-design",
]
lint = [
"black>=22.3.0",
"flake8>=4.0.1",
"isort>=5.10.1",
"mypy",
"pandas-stubs",
"pre-commit>=2.19.0",
"pylint"
]
test = [
"lifetimes==0.11.3",
"pytest==7.0.1",
"pytest-cov==3.0.0"
"ruff>=0.1.4",
]
test = ["lifetimes==0.11.3", "pytest==7.0.1", "pytest-cov==3.0.0"]

[tool.setuptools]
packages = [
Expand All @@ -61,7 +54,7 @@ packages = [
]

[tool.setuptools.dynamic]
version = {file = "pymc_marketing/version.txt"}
version = { file = "pymc_marketing/version.txt" }

[project.urls]
repository = "https://github.com/pymc-labs/pymc-marketing"
Expand All @@ -70,9 +63,6 @@ repository = "https://github.com/pymc-labs/pymc-marketing"
#documentation = ""
#changelog = ""

[tool.isort]
profile = "black"

[tool.pytest.ini_options]
addopts = [
"-v",
Expand All @@ -82,7 +72,5 @@ addopts = [
"--cov-report=term-missing",
"--color=yes",
]
filterwarnings = [
"ignore::DeprecationWarning:bokeh.core.property.primitive:37"
]
filterwarnings = ["ignore::DeprecationWarning:bokeh.core.property.primitive:37"]
testpaths = "tests"
1 change: 0 additions & 1 deletion tests/clv/models/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def test_wrong_fit_method(self):
ValueError,
match=r"Fit method options are \['mcmc', 'map'\], got: wrong_method",
):

model.fit(fit_method="wrong_method")

def test_sample_wihtout_build(self):
Expand Down
1 change: 0 additions & 1 deletion tests/clv/models/test_pareto_nbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ def test_expected_purchase_probability(self, test_n, test_t):
],
)
def test_posterior_distributions(self, fake_fit, T) -> None:

rng = np.random.default_rng(42)
rtol = 0.45
dim_T = 2357 if T is None else len(T)
Expand Down
2 changes: 0 additions & 2 deletions tests/mmm/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ def test_init(
toy_X,
toy_y,
) -> None:

validate_channel_columns.configure_mock(_tags={"validation_X": True})
validate_date_col.configure_mock(_tags={"validation_X": True})
validate_target.configure_mock(_tags={"validation_y": True})
Expand Down Expand Up @@ -208,7 +207,6 @@ def transform(self, X):


def test_validate_and_preprocess(toy_X, toy_y, test_mmm):

test_mmm

test_mmm.validate("X", toy_X)
Expand Down

0 comments on commit 5e1a69f

Please sign in to comment.