Skip to content

PyAutoLabs/PyAutoConf

PyAutoConf

PyAutoConf (package autoconf) is the configuration, serialization, and I/O foundation of the PyAuto ecosystem. It provides a layered configuration system with workspace overrides, dict / JSON / CSV serialization of arbitrary objects, and FITS I/O.

PyAutoFit, PyAutoArray, PyAutoGalaxy, and PyAutoLens all depend on autoconf: it supplies their packaged default config, the object-serialization used to persist models and results, and shared utilities (test_mode, jax_wrapper). Centralising these here keeps a single, consistent config and I/O layer beneath every library.

Install

pip install autoconf

Examples

Layered config — read a directory of YAML into a queryable Config:

from autoconf.conf import Config

config = Config("path/to/config")          # directory of YAML files
value = config["general"]["model"]["section"]["value"]

JSON serialization — round-trip arbitrary Python objects:

from autoconf.dictable import output_to_json, from_json

data = {"sersic_index": 4.0, "centre": [0.0, 0.0]}
output_to_json(data, "model.json")
restored = from_json("model.json")         # == data

FITS I/O — write and read a NumPy array:

import numpy as np
from autoconf.fitsable import output_to_fits, ndarray_via_fits_from

arr = np.arange(12.0).reshape(3, 4)
output_to_fits(values=arr, file_path="demo.fits", overwrite=True)
loaded = ndarray_via_fits_from(file_path="demo.fits", hdu=0)   # np.allclose(arr, loaded)

Links

About

Configuration parsing for the PyAuto* family

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages