modelx v0.31.0 (17 May 2026)#

This release introduces the following enhancements, backward-incompatible changes and bug fixes.

To update modelx to the latest version, use the following command:

>>> pip install modelx --upgrade

Anaconda users should use the conda command instead:

>>> conda update modelx

Enhancements#

  • Macros are now saved and loaded together with the model by write_model() and read_model() (GH229).

  • A pseudo-Python header is now added to serialized Python files for better editor and IDE integration (GH217).

Backward Incompatible Changes#

  • This release introduces a new version of the model serializer (serializer version 7). Models saved by this version of modelx cannot be read by previous versions of modelx. To save a model in a format that earlier versions (modelx v0.30.x and before) can read, pass version=6 to write_model() or zip_model():

    >>> modelx.write_model(model, "model_dir", version=6)
    

Bug Fixes#

  • Docstrings containing special characters (backslashes, embedded or trailing quotes) now round-trip correctly during serialization (GH228).

  • preds, succs and precedents now raise a clear ValueError instead of an internal NetworkXError when no value is cached for the given arguments.

  • read_model() now raises a clear error when the given path is not a modelx model, instead of a confusing FileNotFoundError.

  • Fixed a crash in the exporter when spaces inherit model-level (global) references.

  • Fixed a crash when formatting formula errors for uncached cells called with unhashable arguments.