gempy icon indicating copy to clipboard operation
gempy copied to clipboard

buffering the theano printed to access them later on.

Open Leguark opened this issue 6 years ago • 1 comments

Here there is an example for pymc3 where they do exactly that.

https://docs.pymc.io/notebooks/howto_debugging.html

Leguark avatar Jul 24 '19 10:07 Leguark

Cleaning buffer

old_stdout = sys.stdout mystdout = sys.stdout = StringIO()

Computing model

gp.compute_model(geo_data)

Black magic update

sys.stdout = old_stdout

Split print strings

output = mystdout.getvalue().split('\n')

Init parameters

n_surface_op_float_sigmoid = [] n_surface_0 = [] n_surface_1 = [] a = [] b = [] drift = []

for s in output: if 'n_surface_op_float_sigmoid str' in s: n_surface_op_float_sigmoid.append(np.fromstring(s[s.find('[[')+2:-2], dtype='float', sep=' ')) if 'n_surface_0 str' in s: n_surface_0.append(np.fromstring(s[s.find('[[')+2:-2], dtype='float', sep=' ')) if 'n_surface_1 str' in s: n_surface_1.append(np.fromstring(s[s.find('[[')+2:-2], dtype='float', sep=' ')) if 'a str' in s: a.append(float(s[s.find('= ')+2:])) if 'b str' in s: b.append(float(s[s.find('= ')+2:])) if 'drift[slice_init:slice_init+1][0] str' in s: drift.append(np.fromstring(s[s.find('[[')+2:-2], dtype='float', sep=' '))

a, b, n_surface_0, n_surface_1, drift

Leguark avatar Aug 01 '19 13:08 Leguark