Skip to content

Commit

Permalink
lint doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
gsheni committed May 1, 2024
1 parent bbfa127 commit 0602305
Show file tree
Hide file tree
Showing 38 changed files with 40 additions and 73 deletions.
4 changes: 1 addition & 3 deletions copulas/multivariate/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ def probability_density(self, X):
self.check_fit()
transformed = self._transform_to_normal(X)

return stats.multivariate_normal.pdf(
transformed, cov=self.correlation, allow_singular=True
)
return stats.multivariate_normal.pdf(transformed, cov=self.correlation, allow_singular=True)

def cumulative_distribution(self, X):
"""Compute the cumulative distribution value for each point in X.
Expand Down
20 changes: 11 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ filename = 'copulas/__init__.py'
search = "__version__ = '{current_version}'"
replace = "__version__ = '{new_version}'"


[tool.ruff]
preview = true
line-length = 99
src = ["copulas"]
line-length = 100
indent-width = 4
src = ["rdt"]
target-version = "py312"
exclude = [
"docs",
Expand All @@ -201,19 +201,21 @@ ignore = [
"D417", # Missing argument descriptions in the docstring, this is a bug from pydocstyle: https://github.com/PyCQA/pydocstyle/issues/449
]

[tool.ruff.format]
quote-style = "single"
indent-style = "space"
preview = true
docstring-code-format = true
docstring-code-line-length = "dynamic"

[tool.ruff.lint.pep8-naming]
extend-ignore-names = ["X", "C", "X_padded", "Y", "Y_padded"]

[tool.ruff.lint.isort]
known-first-party = ["copulas"]
known-first-party = ["rdt"]

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401", "E402", "F403", "F405", "E501", "I001"]

[tool.ruff.format]
quote-style = "single"
indent-style = "space"
preview = true

[tool.ruff.lint.pydocstyle]
convention = "google"
1 change: 0 additions & 1 deletion tests/end-to-end/bivariate/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pytest

from copulas.bivariate import Bivariate


Expand Down
1 change: 0 additions & 1 deletion tests/end-to-end/multivariate/test_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
import pytest

from copulas.datasets import sample_trivariate_xyz
from copulas.multivariate import GaussianMultivariate, VineCopula

Expand Down
1 change: 0 additions & 1 deletion tests/end-to-end/multivariate/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import numpy as np
import pandas as pd

from copulas.datasets import sample_trivariate_xyz
from copulas.multivariate import GaussianMultivariate
from copulas.univariate import BetaUnivariate, GaussianKDE, ParametricType, Univariate
Expand Down
1 change: 0 additions & 1 deletion tests/end-to-end/test___init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from copulas import random_state


Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import beta

from copulas.univariate import BetaUnivariate
from scipy.stats import beta


class TestGaussian(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import gamma

from copulas.univariate import GammaUnivariate
from scipy.stats import gamma


class TestGaussian(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import norm

from copulas.univariate import GaussianUnivariate
from scipy.stats import norm


class TestGaussian(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_gaussian_kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from unittest import TestCase

import numpy as np
from scipy.stats import ks_2samp, norm, randint

from copulas.datasets import sample_univariate_bimodal
from copulas.multivariate import GaussianMultivariate
from copulas.univariate.gaussian_kde import GaussianKDE
from scipy.stats import ks_2samp, norm, randint


class TestGaussian(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_student_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import t

from copulas.univariate import StudentTUnivariate
from scipy.stats import t


class TestStudentT(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/end-to-end/univariate/test_truncated_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import truncnorm

from copulas.univariate import TruncatedGaussian
from scipy.stats import truncnorm


class TestGaussian(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/large_scale_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
import tabulate
from botocore import UNSIGNED
from botocore.client import Config
from scipy.stats import ks_2samp

from copulas import get_instance
from copulas.multivariate import GaussianMultivariate, VineCopula
from copulas.univariate import GaussianUnivariate
from scipy.stats import ks_2samp

LOGGER = logging.getLogger(__name__)

Expand Down
1 change: 0 additions & 1 deletion tests/numerical/cdf/test_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np
import pandas as pd
import pytest

from copulas import get_instance

BASE = os.path.dirname(__file__)
Expand Down
1 change: 0 additions & 1 deletion tests/numerical/fit/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np
import pandas as pd
import pytest

from copulas import get_instance

BASE = os.path.dirname(__file__)
Expand Down
1 change: 0 additions & 1 deletion tests/numerical/pdf/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import numpy as np
import pandas as pd
import pytest

from copulas import get_instance

BASE = os.path.dirname(__file__)
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/bivariate/test___init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import numpy as np
from scipy import stats

from copulas.bivariate import select_copula
from copulas.bivariate.frank import Frank
from scipy import stats


def test_select_copula_negative_tau():
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/bivariate/test_base.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from unittest import TestCase, mock

import numpy as np

from copulas.bivariate.base import Bivariate, CopulaTypes

from tests import compare_nested_dicts


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/bivariate/test_clayton.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from unittest import TestCase

import numpy as np

from copulas.bivariate.clayton import Clayton

from tests import copula_single_arg_not_one, copula_zero_if_arg_zero


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/bivariate/test_frank.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import numpy as np

from copulas.bivariate.frank import Frank

from tests import compare_nested_iterables, copula_single_arg_not_one, copula_zero_if_arg_zero


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/bivariate/test_gumbel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
from unittest.mock import patch

import numpy as np

from copulas.bivariate.gumbel import Gumbel

from tests import compare_nested_iterables, copula_single_arg_not_one, copula_zero_if_arg_zero


Expand Down
1 change: 0 additions & 1 deletion tests/unit/bivariate/test_independence.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest import TestCase

import numpy as np

from copulas.bivariate.independence import Independence


Expand Down
1 change: 0 additions & 1 deletion tests/unit/multivariate/test_base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np

from copulas.multivariate.base import Multivariate


Expand Down
5 changes: 1 addition & 4 deletions tests/unit/multivariate/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import numpy as np
import pandas as pd

from copulas import get_qualified_name
from copulas.multivariate.gaussian import GaussianMultivariate
from copulas.univariate import GaussianUnivariate
Expand Down Expand Up @@ -309,9 +308,7 @@ def test_fit_distribution_selector(self):
def test_fit_numpy_array(self):
"""Fit should work indistinctly with numpy arrays and pandas dataframes"""
# Setup
copula = GaussianMultivariate(
distribution='copulas.univariate.gaussian.GaussianUnivariate'
)
copula = GaussianMultivariate(distribution='copulas.univariate.gaussian.GaussianUnivariate')

# Run
copula.fit(self.data.to_numpy())
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/multivariate/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
import numpy as np
import pandas as pd
import pytest

from copulas import EPSILON
from copulas.bivariate import CopulaTypes
from copulas.multivariate.tree import Edge, Tree, TreeTypes, get_tree
from copulas.univariate.gaussian_kde import GaussianKDE

from tests import compare_nested_dicts, compare_nested_iterables, compare_values_epsilon


Expand Down
6 changes: 2 additions & 4 deletions tests/unit/multivariate/test_vine.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
import pandas as pd
import pytest

from copulas.multivariate.tree import TreeTypes
from copulas.multivariate.vine import VineCopula

from tests import compare_nested_dicts, compare_nested_iterables


Expand Down Expand Up @@ -203,9 +203,7 @@ def test_sample_random_state(self):
X = pd.DataFrame([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])
vine.fit(X)

expected_result = pd.DataFrame(
[[0.101933, 0.527734, 0.080266, 0.078328]], columns=range(4)
)
expected_result = pd.DataFrame([[0.101933, 0.527734, 0.080266, 0.078328]], columns=range(4))

# Run
result = vine.sample(1)
Expand Down
1 change: 0 additions & 1 deletion tests/unit/optimize/test___init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest import TestCase

import numpy as np

from copulas.optimize import bisect, chandrupatla


Expand Down
5 changes: 2 additions & 3 deletions tests/unit/test___init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
from unittest import TestCase
from unittest.mock import MagicMock, call, patch

import copulas
import numpy as np
import pandas as pd
import pytest
from numpy.testing import assert_array_equal

import copulas
from copulas import (
_find_addons,
check_valid_values,
Expand All @@ -18,6 +16,7 @@
vectorize,
)
from copulas.multivariate import GaussianMultivariate
from numpy.testing import assert_array_equal


class TestVectorize(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/univariate/test_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from unittest.mock import patch

import numpy as np

from copulas.univariate.base import BoundedType, ParametricType, Univariate
from copulas.univariate.beta import BetaUnivariate
from copulas.univariate.gamma import GammaUnivariate
Expand All @@ -11,6 +10,7 @@
from copulas.univariate.student_t import StudentTUnivariate
from copulas.univariate.truncated_gaussian import TruncatedGaussian
from copulas.univariate.uniform import UniformUnivariate

from tests import compare_nested_iterables


Expand Down
3 changes: 1 addition & 2 deletions tests/unit/univariate/test_beta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
from unittest.mock import patch

import numpy as np
from scipy.stats import beta

from copulas.univariate import BetaUnivariate
from scipy.stats import beta


class TestBetaUnivariate(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/univariate/test_gamma.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import gamma

from copulas.univariate import GammaUnivariate
from scipy.stats import gamma


class TestGammaUnivariate(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/univariate/test_gaussian.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from unittest import TestCase

import numpy as np
from scipy.stats import norm

from copulas.univariate.gaussian import GaussianUnivariate
from scipy.stats import norm


class TestGaussianUnivariate(TestCase):
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/univariate/test_gaussian_kde.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

import numpy as np
import pytest
from scipy.stats import gaussian_kde

from copulas.datasets import sample_univariate_bimodal
from copulas.univariate.gaussian_kde import GaussianKDE
from scipy.stats import gaussian_kde


class TestGaussianKDE(TestCase):
Expand Down
Loading

0 comments on commit 0602305

Please sign in to comment.