Skip to content

Conditional priors are not pickleable

Attempting to pickle conditional priors fails with

AttributeError: Can't pickle local object 'conditional_prior_factory.<locals>.ConditionalPrior'

Pickling priors is essential to work with bilby_pipe.

This SO question suggests that we need to set the __qualname__ of the new class. I've tested this locally and it looks like it will work.

__qualname__ was introduced in Python 3.3. This would potentially make the conditional priors incompatible with Python 2. Personally, this seems like an obvious time to explicitly drop Python 2 support.

Any thoughts?