Skip to content

Split neural_lam/utils.py into a utils/ package #681

Description

@Sir-Sloth-The-Lazy

neural_lam/utils.py has grown past 800 lines and mixes unrelated concerns graph loading/zero-indexing, MLP construction, plotting/LaTeX detection, training-logger setup, tensor math, and time conversion. New work (e.g. the latent encoder/decoder infra) adds more graph helpers and has had to introduce a TYPE_CHECKING, guarded BaseDatastore import to dodge a circular import.

Proposal

Turn utils.py into a utils/ package, mirroring the models/ layout, with one module per concern:

  • buffer_list.py : BufferList
  • graph.py : load_graph, zero_index_*
  • networks.py : make_mlp
  • plot.py : has_working_latex, fractional_plot_bundle
  • logging.py : setup_training_logger, init_training_logger_metrics, log_on_rank_zero
  • tensor.py : inverse_softplus, inverse_sigmoid
  • time.py : get_integer_time

utils/__init__.py re-exports the full public API so existing imports (from neural_lam import utils, from neural_lam.utils import load_graph, …) keep working unchanged. This should also let graph-related helpers sit next to BaseDatastoreaware code and remove the TYPE_CHECKING workaround.

Notes

Metadata

Metadata

Labels

maintenanceRefactoring codebase, no new behaviour

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions