Skip to content

Invalid filename for chain history #19

@mbraakhekke

Description

@mbraakhekke

Hi,

I'm getting an error because the filename generated for the chain history file contains a colon (:), as part of the timestamp.

My code and error message (for one thread) are added below.

cheers,
Maarten

from pydream.core import run_dream
from pydream.parameters import FlatParam
import numpy as np
from scipy.stats import norm, uniform

mu = 0
var = 1

def Latin_hypercube(minn, maxn, N):
    y = np.random.rand(N, len(minn))
    x = np.zeros((N, len(minn)))
    
    for j in range(len(minn)):
        idx = np.random.permutation(N)
        P = (idx - y[:,j])/N
        x[:,j] = minn[j] + P * (maxn[j] - minn[j])
    
    return x

if __name__ == '__main__':
    history_seed = Latin_hypercube([-1],[1],50)
    np.save('history_seed.npy',history_seed)
    param = FlatParam(np.array(0))
    sampled_params, log_ps = run_dream(param, likelihood, 
              start = np.array(0), 
              start_random = False, 
              niterations = 1000,
              verbose = False,
              history_file = 'history_seed.npy')
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\multiprocessing\pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\multiprocessing\pool.py", line 44, in mapstar
    return list(map(*args))
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\core.py", line 127, in _sample_dream
    raise e
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\core.py", line 114, in _sample_dream
    sampled_params[iteration], log_prior , log_like = step_fxn(q0)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\Dream.py", line 421, in astep
    raise e
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\Dream.py", line 362, in astep
    self.record_history(self.nseedchains, self.total_var_dimension, q_new, self.len_history)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\Dream.py", line 945, in record_history
    self.save_history_to_disc(np.frombuffer(Dream_shared_vars.history.get_obj()), prefix)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\pydream\Dream.py", line 959, in save_history_to_disc
    np.save(filename, history)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\numpy\lib\npyio.py", line 517, in save
    fid = open(file, "wb")
OSError: [Errno 22] Invalid argument: '2020_04_26_18:58:29_DREAM_chain_history.npy'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions