Skip to content

Commit

Permalink
rename FlexKnotLikelihood -> Likelihood, FlexKnotPrior -> Prior, Adap…
Browse files Browse the repository at this point in the history
…tiveKnotPrior -> AdaptivePrior
  • Loading branch information
AdamOrmondroyd committed Jan 25, 2024
1 parent 208bcc6 commit 097018f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
4 changes: 2 additions & 2 deletions flexknot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"""

from flexknot.core import AdaptiveKnot, FlexKnot
from flexknot.likelihoods import FlexKnotLikelihood
from flexknot.priors import AdaptiveKnotPrior, FlexKnotPrior
from flexknot.likelihoods import Likelihood
from flexknot.priors import AdaptivePrior, Prior

__all__ = [
"AdaptiveKnot", "FlexKnot",
Expand Down
2 changes: 1 addition & 1 deletion flexknot/likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from flexknot.core import AdaptiveKnot, FlexKnot


class FlexKnotLikelihood:
class Likelihood:
"""
Likelihood for a flex-knot, with data described by xs, ys, and sigma.
Expand Down
4 changes: 2 additions & 2 deletions flexknot/priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)


class FlexKnotPrior(UniformPrior):
class Prior(UniformPrior):
"""Interleaved uniform and sorted uniform priors for a flex-knot."""

def __init__(self, x_min, x_max, y_min, y_max):
Expand Down Expand Up @@ -50,7 +50,7 @@ def __call__(self, hypercube):
)


class AdaptiveKnotPrior(FlexKnotPrior):
class AdaptivePrior(Prior):
"""
Interleaved uniform and sorted uniform priors appropriate for a flex-knot.
Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[project]
name = "flexknot"
version = "1.2.1"
version = "1.3.0"
description = "Flex-Knot"
authors = [{name="Adam Neil Ormondroyd", email="[email protected]"}]
readme = "README.md"
dependencies = ["numpy", "scipy", "pypolychord"]

[project.urls]
repository = "https://github.com/Ormorod/flexknot"
repository = "https://github.com/adamormondroyd/flexknot"

[project.optional-dependencies]
dev = ["pytest", "flake8", "pydocstyle"]

10 changes: 4 additions & 6 deletions tests/test_likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import numpy as np
from scipy.special import erf
from flexknot import FlexKnotLikelihood
from flexknot import Likelihood
from flexknot.utils import create_theta


Expand All @@ -26,8 +26,7 @@ def test_likelihood():
y_data = np.array([0, 1])
sigma = 1

logl = FlexKnotLikelihood(x_min, x_max, x_data, y_data, sigma,
adaptive=False)
logl = Likelihood(x_min, x_max, x_data, y_data, sigma, adaptive=False)
assert logl(theta)[0] == -np.log(2 * np.pi)


Expand All @@ -42,8 +41,8 @@ def test_likelihood_sigma_x():
The value for the likelihood in this case should be
ln[(1/16π)(erf(1)-erf(0))(erf(0)-erf(-1))].
"""
"""
x_min, x_max = 0, 1
x_nodes = np.array([])
y_nodes = np.array([0, 1])
Expand All @@ -53,8 +52,7 @@ def test_likelihood_sigma_x():
y_data = np.array([0, 1])
sigma = np.array([1, 1])

logl = FlexKnotLikelihood(x_min, x_max, x_data, y_data, sigma,
adaptive=False)
logl = Likelihood(x_min, x_max, x_data, y_data, sigma, adaptive=False)
assert np.isclose(
logl(theta)[0], np.log((erf(1) - erf(0)) * (erf(0) - erf(-1))
/ (16 * np.pi))
Expand Down
8 changes: 4 additions & 4 deletions tests/test_prior.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Test that FlexKnotPrior sorts the x nodes.
Test that flexknot.Prior sorts the x nodes.
"""

import numpy as np
from flexknot import AdaptiveKnotPrior, FlexKnotPrior
from flexknot import AdaptivePrior, Prior
from flexknot.utils import get_x_nodes_from_theta

rng = np.random.default_rng()
Expand All @@ -20,7 +20,7 @@ def test_flexknotprior_x_nodes_are_sorted():
Test that the prior for the x_nodes is sorted.
"""
hypercube = rng.random(2 * N_max - 2)
prior = FlexKnotPrior(x_min, x_max, y_min, y_max)(hypercube)
prior = Prior(x_min, x_max, y_min, y_max)(hypercube)

assert np.all(np.diff(get_x_nodes_from_theta(prior, adaptive=False)) >= 0)

Expand All @@ -31,7 +31,7 @@ def test_adaptiveknotprior_x_nodes_are_sorted():
"""

hypercube = rng.random(2 * N_max - 1)
prior = AdaptiveKnotPrior(
prior = AdaptivePrior(
x_min, x_max, y_min, y_max, N_min, N_max
)(hypercube)

Expand Down

0 comments on commit 097018f

Please sign in to comment.