UltraNest icon indicating copy to clipboard operation
UltraNest copied to clipboard

ReactiveNestedCalibrator dos not work well

Open Lowerce opened this issue 1 year ago • 4 comments

  • UltraNest version: 4.3.2
  • Python version: 3.9
  • Operating System: macOS 14.6.1

Description

I follow the command recommended in ReactiveNestedCalibrator. But it seems nothing output.

What I Did

sampler = ReactiveNestedCalibrator(my_param_names, my_loglike, my_transform) 
sampler.stepsampler = SliceSampler(nsteps=10, generate_direction=region_oriented_direction)
sampler.run(min_num_livepoints=400)

Lowerce avatar Aug 29 '24 08:08 Lowerce

That is very strange! Is this in a python script or a notebook? Can you rerun it from scratch?

JohannesBuchner avatar Aug 29 '24 09:08 JohannesBuchner

That is very strange! Is this in a python script or a notebook? Can you rerun it from scratch?

In a python script. The corresponding one could work well:

sampler = ReactiveNestedSampler(my_param_names, my_loglike, my_transform)
sampler.stepsampler = SliceSampler(nsteps=10, generate_direction=region_oriented_direction)
sampler.run(min_num_livepoints=400)

How could I "return it from scratch"? I would like to try. ReactiveNestedCalibrator seems behavior different with ReactiveNestedSampler for I can't get the return value of sampler.run from ReactiveNestedCalibrator. It will return an <generator object ReactiveNestedCalibrator.run at 0x1467de3c0>.

By the way, the plot method implemented in ReactiveNestedCalibrator could not work well too. The following issue is raised:

self.sampler.stepsampler.plot(os.path.join(self.sampler.logs['plots'], 'stepsampler.pdf'))
AttributeError: 'ReactiveNestedCalibrator' object has no attribute 'sampler'

Lowerce avatar Aug 29 '24 11:08 Lowerce

I'm quite confused. if you call run() then you should at least get to the first print here: https://github.com/JohannesBuchner/UltraNest/blob/master/ultranest/calibrator.py#L97

JohannesBuchner avatar Aug 29 '24 12:08 JohannesBuchner

sorry for interjecting here, this is something i also faced.

ReactiveNestedCalibrator returns generator of list of [nstep, result]. Only when you access, the actual sampling is performed.

i am running it like

for nstep, results in sampler:
    print(f" {nstep:d}", results, sep='\n')

shiningsurya avatar Sep 03 '24 08:09 shiningsurya

Please propose a fix -- maybe run_iter (which gives the iterator) and run (which returns the list), like ReactiveNestedSampler.

JohannesBuchner avatar Nov 17 '25 10:11 JohannesBuchner