How to use the pyabc.storage.save_dict_to_json function in pyabc

To help you get started, we’ve selected a few pyabc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ICB-DCM / pyABC / test / test_storage.py View on Github external
def test_dict_from_and_to_json():
    dct = {1: 0.5, 2: 42, 3: [1, 2, 0.1]}
    file_ = tempfile.mkstemp()[1]
    pyabc.storage.save_dict_to_json(dct, file_)
    re_dct = pyabc.storage.load_dict_from_json(file_)
    assert dct == re_dct
github ICB-DCM / pyABC / pyabc / acceptor / acceptor.py View on Github external
def log(self, t):
        logger.debug(f"pdf_norm={self.pdf_norms[t]:.4e} for t={t}.")

        if self.log_file:
            save_dict_to_json(self.pdf_norms, self.log_file)
github ICB-DCM / pyABC / pyabc / epsilon / temperature.py View on Github external
fallback = self.temperatures[t-1] \
            if t-1 in self.temperatures else np.inf
        temperature = self.aggregate_fun(temps)
        # also a value lower than 1.0 does not make sense
        temperature = max(min(temperature, fallback), 1.0)

        if not np.isfinite(temperature):
            raise ValueError("Temperature must be finite.")
        # record found value
        self.temperatures[t] = temperature

        # logging
        logger.debug(f"Proposed temperatures for {t}: {temps}.")
        self.temperature_proposals[t] = temps
        if self.log_file:
            save_dict_to_json(self.temperature_proposals, self.log_file)
github ICB-DCM / pyABC / pyabc / distance / distance.py View on Github external
def log(self, t: int) -> None:
        logger.debug(f"updated weights[{t}] = {self.weights[t]}")

        if self.log_file:
            save_dict_to_json(self.weights, self.log_file)
github ICB-DCM / pyABC / pyabc / distance / distance.py View on Github external
def log(self, t: int) -> None:
        logger.debug(f"updated weights[{t}] = {self.weights[t]}")

        if self.log_file:
            save_dict_to_json(self.weights, self.log_file)