Skip to content

Commit

Permalink
docstrings and hints
Browse files Browse the repository at this point in the history
  • Loading branch information
ahouseholder committed Sep 28, 2023
1 parent b0726db commit 0768423
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
28 changes: 25 additions & 3 deletions vultron/cvd_states/hypercube.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def transitions_in_path(self, path: list) -> Tuple[str]:
return seq

@ensure_valid_state
def walk_from(self, start=None, end="VFDPXA"):
def walk_from(self, start:str=None, end:str="VFDPXA") -> tuple:
"""
Randomly walk from a given state to a given state
Expand Down Expand Up @@ -508,6 +508,9 @@ def _init_H_df(self) -> pd.DataFrame:
Returns:
a dataframe of histories and their scores
Raises:
CVDmodelError: if the history probabilities are uninitialized
"""
# make sure we have the info we need before proceeding
if self.H_prob is None:
Expand Down Expand Up @@ -547,7 +550,12 @@ def _init_H_df(self) -> pd.DataFrame:
df = pd.DataFrame(data)
return df

def _compute_f_d(self):
def _compute_f_d(self) -> dict:
"""
Returns:
a dict of desiderata: frequency
"""
_f_d = self.H_df[self.w_cols].sum()

f_d = {}
Expand All @@ -563,7 +571,18 @@ def _compute_f_d_orig(self):
f_d = self.H_df[self.d_cols].mean()
return f_d

def _assess_hist(self, h):
def _assess_hist(self, h) -> dict:
"""
Assess a history against the desiderata
Args:
h: the history to assess
Returns:
a dict of desiderata: is_met
Raises:
ScoringError: if the history is invalid
"""
try:
is_valid_history(h)
except HistoryValidationError:
Expand Down Expand Up @@ -778,6 +797,9 @@ def find_states(self, pat: str) -> list:
Returns:
a list of states that match the pattern
Raises:
CVDmodelError: if the pattern is invalid
"""
try:
is_valid_pattern(pat)
Expand Down
2 changes: 1 addition & 1 deletion vultron/cvd_states/validations.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def my_func(history, ...):
the decorated function
Raises:
HistoryValidationError if the history is invalid
HistoryValidationError: if the history is invalid
"""

def wrapper(*args, **kwargs):
Expand Down

0 comments on commit 0768423

Please sign in to comment.