Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ jobs:
- name: Install the project and dependencies
run: uv sync --all-extras

# - uses: astral-sh/ruff-action@v3
- uses: astral-sh/ruff-action@v3

- name: Run tests with coverage
run: uv run pytest tests
run: uv run coverage run -m pytest

# TODO: figure out how to use this
# - name: Produce coverage report
# run: uv run coverage report -m
- name: Produce coverage report
run: uv run coverage report -m
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Homepage = "https://github.com/tmcclintock/ConditionalGMM"
Issues = "https://github.com/tmcclintock/ConditionalGMM/issues"

[tool.coverage.run]
include = ["./ConditionalGMM/*"]
include = ["./src/ConditionalGMM/*"]
omit = [
"*tests*",
"*__init__*"
Expand All @@ -52,3 +52,8 @@ exclude_lines = [
"if __name__ == .__main__.:",
"@tf.function"
]

[dependency-groups]
dev = [
"ruff>=0.11.9",
]
5 changes: 3 additions & 2 deletions src/ConditionalGMM/UnivariateGMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ def ppf(self, q):
(float or array-like) quantile corresponding to `q`

"""
f = lambda x: self.cdf(x) - q
return sp.optimize.newton(func=f, x0=self.mean(), fprime=self.pdf)
return sp.optimize.newton(
func=lambda x: self.cdf(x) - q, x0=self.mean(), fprime=self.pdf
)

def mean(self):
"""Mean of the RV for the GMM.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cGMM.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_cGMM_basic():
means = [[0.5, -0.2]]
covs = [[[2.0, 0.3], [0.3, 0.5]]]
fixed_inds = [1]
cGMM = CondGMM(weights, means, covs, fixed_inds)
CondGMM(weights, means, covs, fixed_inds)

# 2d - 2 component
weights = [0.5, 0.5]
Expand Down
5 changes: 2 additions & 3 deletions tests/test_cMVN.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ def test_cMN_basic():
means = [0.5, -0.2]
cov = [[2.0, 0.3], [0.3, 0.5]]
ind = [0]
cMN = CondMNorm(means, cov, ind)
CondMNorm(means, cov, ind)

# 3D
means = [0.5, -0.2, 1.0]
cov = [[2.0, 0.3, 0.0], [0.3, 0.5, 0.0], [0.0, 0.0, 1.0]]
inds = [1, 2]
cMN = CondMNorm(means, cov, inds)
CondMNorm(means, cov, inds)


def test_cMN_exceptions():
# 3D
means = [0.5, -0.2, 1.0]
cov = [[2.0, 0.3, 0.0], [0.3, 0.5, 0.0], [0.0, 0.0, 1.0]]
inds = [1, 2]

with pytest.raises(AssertionError):
CondMNorm(means, cov, [-1])
Expand Down
Loading