master-thesis/python/energy_flow_proper/utilities.py

14 lines
507 B
Python

import stg_helper
from types import ModuleType
from typing import Callable
def get_n_samples(stg: ModuleType) -> int:
"""Get the number of samples from ``stg``."""
with stg_helper.get_hierarchy_data(stg, read_only=True) as hd:
return hd.get_samples()
def has_all_samples(stg: ModuleType) -> bool:
return stg.__HI_number_of_samples == get_n_samples(stg)
def has_all_samples_checker(stg: ModuleType) -> Callable[..., bool]:
return "Has all samples?", lambda _: has_all_samples(stg)