orbit.utils package

Submodules

orbit.utils.general module

orbit.utils.general.expand_grid(base)

Given a base key values span, expand them into a dataframe covering all combinations :param base: dictionary with keys equal columns name and value equals key values :type base: dict

Returns

pd.DataFrame

Return type

dataframe generate based on user specified base

orbit.utils.general.get_parent_path(current_file_path)
Parameters
  • current_file_path (str) – The given file path, should be an absolute path

  • Returns

  • ------- – str : The parent path of give file path

orbit.utils.general.is_empty_dataframe(df)

A simple function to tell whether the passed in df is an empty dataframe or not. :param df: given input dataframe :type df: pd.DataFrame

Returns

bool

Return type

True if df is none, or if df is an empty dataframe; False otherwise.

orbit.utils.general.is_even_gap_datetime(array)

Returns True if array is evenly distributed

orbit.utils.general.is_ordered_datetime(array)

Returns True if array is ordered and non-repetitive

orbit.utils.general.regenerate_base_df(df, time_col, key_col, val_cols=[], fill_na=None)

Given a dataframe, key column, time column and value column, re-generate multiple time-series to cover full range date-time with all the keys. This can be a useful utils for working multiple time-series.

Parameters
  • df (pd.DataFrame) –

  • time_col (str) –

  • key_col (str) –

  • val_cols (List[str]; values column considered to be imputed) –

  • fill_na (Optional[float]; values to fill when there are missing values of the row) –

orbit.utils.general.update_dict(original_dict, append_dict)

orbit.utils.pyro module

orbit.utils.pyro.get_pyro_model(model_name)

orbit.utils.stan module

orbit.utils.stan.compile_stan_model(stan_model_name)

Compile stan model and save as pkl

orbit.utils.stan.compile_stan_model_simplified(path)

A more flexible way to load compile stan model with a path provided :param path:

orbit.utils.stan.get_compiled_stan_model(stan_model_name)

Load compiled Stan model

orbit.utils.stan.get_compiled_stan_model_simplified(path)

A more flexible way to load pre-compiled model :param path:

orbit.utils.stan.set_compiled_stan_path(parent, child='stan_compiled')

Set the path for compiled stan models.

parent: the primary directory level child: the secondary directory level

class orbit.utils.stan.suppress_stdout_stderr

Bases: object

A context manager for doing a “deep suppression” of stdout and stderr in Python, i.e. will suppress all print, even if the print originates in a compiled C/Fortran sub-function.

This will not suppress raised exceptions, since exceptions are printed

to stderr just before a script exits, and after the context manager has exited (at least, I think that is why it lets exceptions through).

Module contents