Skip to content

Commit

Permalink
docstring fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jrzkaminski committed Jul 5, 2024
1 parent 855b245 commit 9795fef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 25 deletions.
10 changes: 4 additions & 6 deletions bamt/core/node_models/continuous_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@ class ContinuousDistribution:
however, any custom continuous distribution can be used, as long as it implements
`scipy.stats` interface.
Example Usage:
```python
data = np.random.normal(0, 1, 1000)
dist = ContinuousDistribution()
dist.fit(data, distributions_pool=DistributionPool.SMALL)
samples = dist.sample(10)
```
>>> data = np.random.normal(0, 1, 1000)
>>> dist = ContinuousDistribution()
>>> dist.fit(data, distributions_pool=DistributionPool.SMALL)
>>> samples = dist.sample(10)
"""

SMALL_POOL: Tuple[Type[stats.rv_continuous], ...] = (
Expand Down
17 changes: 8 additions & 9 deletions bamt/core/node_models/empirical_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ class EmpiricalDistribution(Distribution):
This class fits an empirical distribution to the provided categorical or discrete data by calculating
the probabilities of unique values and allows sampling from it.
Usage example:
```python
data = ['apple', 'banana', 'apple', 'orange', 'banana', 'banana', 'orange', 'apple']
emp_dist = EmpiricalDistribution()
emp_dist.fit(data)
print(emp_dist)
samples = emp_dist.sample(10)
print(samples)
print(emp_dist.pmf('banana'))
```
>>> data = ['apple', 'banana', 'apple', 'orange', 'banana', 'banana', 'orange', 'apple']
>>> emp_dist = EmpiricalDistribution()
>>> emp_dist.fit(data)
>>> print(emp_dist)
>>> samples = emp_dist.sample(10)
>>> print(samples)
>>> print(emp_dist.pmf('banana'))
"""

def __init__(self) -> None:
Expand Down
19 changes: 9 additions & 10 deletions bamt/core/nodes/root_nodes/continuous_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@ class ContinuousNode(RootNode):
These distributions are wrapped in the `ContinuousDistribution` class.
Example Usage:
```python
data = np.random.normal(0, 1, 1000)
dist = ContinuousDistribution()
node = ContinuousNode(distribution=dist)
node.fit(data)
print(node)
samples = node.sample(10)
print(samples)
print(node.get_parents())
```
>>> data = np.random.normal(0, 1, 1000)
>>> dist = ContinuousDistribution()
>>> node = ContinuousNode(distribution=dist)
>>> node.fit(data)
>>> print(node)
>>> samples = node.sample(10)
>>> print(samples)
>>> print(node.get_parents())
"""

def __init__(self, distribution: Optional[ContinuousDistribution] = None):
Expand Down

0 comments on commit 9795fef

Please sign in to comment.