modelx v0.2.0 (13 January 2020)

This release includes enhancements in reading and writing models, as well as some spec changes.


Enhanced model serializer

The API functions write_model() and read_model() are based on an updated and improved serializer.

Dynamic spaces assigned to references are also serialized by write_model() and deserialized by read_model() (GH25), as well as input values of cells in dynamic spaces if any:

import modelx as mx
m = mx.new_model()
SpaceA = m.new_space('SpaceA', formula=lambda t: None)

def foo(x):
    return x

m.new_space('SpaceB', refs={'RefA': m.SpaceA[0]})
SpaceA[1].foo[2] = 3

mx.write_model(m, "testdir")
m2 = mx.read_model("testdir")

m2.SpaceB.RefA is m2.SpaceA[0]   # => True
m2.SpaceA[1].foo[2]              # => 3

Models written by modelx v0.1.0 or modelx v0.0.25 can still be read by this version.

Simplified serialization

The previous serializer stores the object IDs of pickled references in separate files. The updated serializer writes the object IDs directly in the output files of the parent spaces.

Option to activate dependent cells recalculation

Recalculation of dependent cells introduced in modelx v0.1.0 is deactivated at modelx startup due to user request (GH24). Instead, two API functions, set_recalc() and get_recalc(), are introduced for the users to explicitly set and get recalculation mode.

Double-quoted strings in CellNode repr

Strings in CellNode’s repr, whether as arguments or values, are double-quoted, as in m.s.a(name="World")="Hello World" (GH27).

Backward Incompatible Changes

  • Recalculation of dependent cells is deactivated at startup as explained in Enhancements section (GH24). The user needs to explicitly activate it by set_recalc().

  • static_spaces() is renamed to named_spaces(). static_spaces() is still available for backward compatibility, but is now deprecated and removed in future releases.

  • Dynamic spaces that are direct children of user spaces are now of the RootDynamicSpace type, which is a subclass of the DynamicSpace type.

Bug Fixes

  • Fix Model.write() method.

  • Fix error when writing spaces whose names are single characters.