Skip to content

Commit

Permalink
Instantiate all distributions
Browse files Browse the repository at this point in the history
Required because testing select boxes when the options are not easily convertible to strings seems very difficult.
  • Loading branch information
fcooper8472 committed Jan 3, 2024
1 parent e1b25f7 commit 102c73d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions distribution_zoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

dist_mapping = {
DistributionClass('Continuous Univariate', 'cont_uni'): [
Normal,
Gamma,
Normal(),
Gamma(),
],
DistributionClass('Discrete Univariate', 'disc_uni'): [
],
Expand Down
3 changes: 3 additions & 0 deletions distribution_zoo/base_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def __init__(self):
def get_class_name(cls):
return cls.__name__

def __str__(self):
return self.display_name

def display(self):
self.title()
st.sidebar.header('Parameters:')
Expand Down
5 changes: 2 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,15 @@
selected_dist = st.sidebar.selectbox(
label='Select a distribution',
options=available_dists,
format_func=lambda _dist: _dist.display_name,
index=selected_dist_index,
placeholder='Select a distribution',
label_visibility='collapsed',
key='dist',
)

if selected_dist:
selected_dist_inst = selected_dist()
selected_dist_inst.display()
selected_dist.display()

else:

with st.container():
Expand Down

0 comments on commit 102c73d

Please sign in to comment.