rhayes777 / PyAutoFit

PyAutoFit: Classy Probabilistic Programming
https://pyautofit.readthedocs.io/
MIT License
60 stars 11 forks source link

Cannot output `initializer` with start point #1031

Closed Jammy2211 closed 1 month ago

Jammy2211 commented 3 months ago

On the following MLE PR:

https://github.com/rhayes777/PyAutoFit/pull/1029

The following example:

https://github.com/Jammy2211/autofit_workspace/blob/release/scripts/searches/start_point.py

Gives the following error:

2024-07-31 20:16:17,444 - autofit.non_linear.search.abstract_search - INFO - Starting non-linear search with 1 cores.
2024-07-31 20:16:17,445 - start_point - INFO - The output path of this fit is /mnt/c/Users/Jammy/Code/PyAuto/autofit_workspace/output/searches/start_point/c08aea3aa8a5f449fb0fe25f0063eed2
2024-07-31 20:16:17,446 - start_point - INFO - Outputting pre-fit files (e.g. model.info, visualization).
Traceback (most recent call last):
  File "/mnt/c/Users/Jammy/Code/PyAuto/autofit_workspace/scripts/searches/start_point.py", line 148, in <module>
    result = search.fit(model=model, analysis=analysis)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoFit/autofit/non_linear/search/abstract_search.py", line 590, in fit
    self.pre_fit_output(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoFit/autofit/non_linear/search/abstract_search.py", line 665, in pre_fit_output
    self.paths.save_all(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoFit/autofit/non_linear/paths/directory.py", line 358, in save_all
    self.save_json("search", to_dict(self.search))
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/output.py", line 61, in wrapper
    return func(self, name, *args, **kwargs)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoFit/autofit/non_linear/paths/directory.py", line 81, in save_json
    json.dump(object_dict, f, indent=4)
  File "/usr/lib/python3.10/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib/python3.10/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.10/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  [Previous line repeated 2 more times]
  File "/usr/lib/python3.10/json/encoder.py", line 376, in _iterencode_dict
    raise TypeError(f'keys must be str, int, float, bool or None, '
TypeError: keys must be str, int, float, bool or None, not UniformPrior

This is because starting points use priors in a dict, which are not supporrted by autoconf.