Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify and clean code style and docstring #68

Merged
merged 35 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
51eceb8
Add reference of modules indices
dachengx Jul 30, 2023
ada2cdc
Update docstring of StatisticalModel
dachengx Jul 30, 2023
274be84
Update docstring of BlueiceExtendedModel
dachengx Jul 30, 2023
8e69318
Update docstring of GaussianModel
dachengx Jul 30, 2023
fe72dc9
Update docstring of Parameters
dachengx Jul 30, 2023
3c6f281
Update docstring of BlueiceExtendedModel
dachengx Jul 30, 2023
ee0da2f
More code style change
dachengx Jul 31, 2023
de83227
Try simplified name
dachengx Jul 31, 2023
2e4c06c
Change it back
dachengx Jul 31, 2023
0237c1f
Add codes to placeholder.ipynb
dachengx Jul 31, 2023
617fa8b
Recover symbolic link
dachengx Jul 31, 2023
e9515c4
Minor change
dachengx Jul 31, 2023
6772eca
Try plot the logpdf
dachengx Jul 31, 2023
d4e0f20
Update odcstring of utils
dachengx Jul 31, 2023
7de6852
Use napoleon and todo as sphinx extension
dachengx Jul 31, 2023
908b49d
Update model.py docstring to Google style
dachengx Jul 31, 2023
7bc1389
Update docstring of Parameters and GaussianModel
dachengx Jul 31, 2023
6c303f0
Update docstring of BlueiceExtendedModel
dachengx Jul 31, 2023
81069f6
Update utils and BlueiceDataGenerator docstring
dachengx Jul 31, 2023
02273ea
Happier code style
dachengx Jul 31, 2023
ca54caa
Happier code style
dachengx Jul 31, 2023
c4fdf7b
Minor change
dachengx Jul 31, 2023
714fb7e
Fix some docstring as suggested
dachengx Jul 31, 2023
f1b33a5
Minor change
dachengx Jul 31, 2023
d834e81
Update docstrings
dachengx Jul 31, 2023
0311397
Minor change
dachengx Jul 31, 2023
90b86c2
Minor change, drop DAR105
dachengx Jul 31, 2023
0588fe9
Minor change
dachengx Jul 31, 2023
7f5657b
Only check code style when PR opened
dachengx Jul 31, 2023
10b8d97
Minor fix
dachengx Aug 1, 2023
4529a7f
Update docstring to tell the relation between public and private method
dachengx Aug 1, 2023
01bb5ed
Remove kwargs from make_objective
dachengx Aug 1, 2023
702353b
Update docstrings of GaussianModel, remove minus argument of Statisti…
dachengx Aug 1, 2023
42e4d7f
Debug
dachengx Aug 1, 2023
2682d9f
Minor change
dachengx Aug 1, 2023
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ __pycache__
build
docs/build
docs/source/_build
docs/source/build
debug.py
docs/source/reference/*
docs/source/reference/release_notes.rst
36 changes: 29 additions & 7 deletions alea/examples/gaussian_model.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,54 @@
from typing import Optional

from scipy import stats
import numpy as np
from scipy import stats

from alea.model import StatisticalModel


class GaussianModel(StatisticalModel):
"""
dachengx marked this conversation as resolved.
Show resolved Hide resolved
A model of a gaussian measurement, where the model has parameters mu and sigma.
For illustration, we show how required nominal parameters can be added
to the init sigma is fixed in this example.

:param parameter_definition: definition of the parameters of the model
:type parameter_definition: dict or list
"""

def __init__(
self,
parameter_definition: Optional[dict or list] = None,
**kwargs,
):
"""
Initialise a model of a gaussian measurement (hatmu),
where the model has parameters mu and sigma
For illustration, we show how required nominal parameters can be added to the init
sigma is fixed in this example.
"""
"""Initialise a gaussian model."""
if parameter_definition is None:
parameter_definition = ["mu", "sigma"]
super().__init__(parameter_definition=parameter_definition, **kwargs)

def _ll(self, mu=None, sigma=None):
"""
dachengx marked this conversation as resolved.
Show resolved Hide resolved
dachengx marked this conversation as resolved.
Show resolved Hide resolved
Log-likelihood of the model.

:param mu: mean of the gaussian
:type mu: float
:param sigma: standard deviation of the gaussian
:type sigma: float
"""
hat_mu = self.data[0]['hat_mu'][0]
return stats.norm.logpdf(x=hat_mu, loc=mu, scale=sigma)

def _generate_data(self, mu=None, sigma=None):
"""
dachengx marked this conversation as resolved.
Show resolved Hide resolved
dachengx marked this conversation as resolved.
Show resolved Hide resolved
Generate data from the model.

:param mu: mean of the gaussian
:type mu: float
:param sigma: standard deviation of the gaussian
:type sigma: float
:return: data generated from the model
:rtype: list
"""
hat_mu = stats.norm(loc=mu, scale=sigma).rvs()
data = [np.array([(hat_mu,)], dtype=[('hat_mu', float)])]
return data
Loading