modelx v0.15.0 (19 May 2021)

This release fixes bugs and introduces enhancements as follows.

Enhancements

Introduction of precedents method for tracing Reference values

A new method precedents() is introduced. The existing preds() method returns a list of nodes that the specified node depends on for calculating its value. The preds() only lists nodes of Cells and Spaces. The newly introduced precedents() method enhances preds(). In addition to the nodes of Cells and Spaces returned by preds(), the precedents() also includes nodes of Reference values that are used by the specified node’s calculation. Here’s an example.

import modelx as mx

space = mx.new_space()
space.new_space('Child')
space.Child.new_space('GrandChild')

space.x = 1
space.Child.y = 2
space.Child.GrandChild.z = 3

@mx.defcells(space=space)
def foo(t):
    return t

@mx.defcells(space=space)
def bar(t):
    return foo(t) + x + Child.y + Child.GrandChild.z

The bar Cells depends on one Cells foo, and 3 References, x, Child.y, and Child.GrandChild.z. Below, bar.preds(3) returns a list containing foo(3), which is the only Cells element that bar(3) depends on:

>>> bar(3)
9

>>> bar.preds(3)
[Model1.Space1.foo(t=3)=3]

The precedents() method returns a list containing not only Cells elements, but also References that the Cells depends on when calculating its value:

>>> bar.precedents(3)
[Model1.Space1.foo(t=3)=3,
 Model1.Space1.x=1,
 Model1.Space1.Child.GrandChild.z=3,
 Model1.Space1.Child.y=2]

Similarly to Cells.precedents, Space.precedents is also introduced, which extends the Space.preds in the same way.

Improved Multi-line repr of nodes

The elements of lists returned by precedents(), succs() and preds() are Node objects and can have numpy arrays and pandas DataFrames as their values. These values have multi-line representation strings (repr). To print such reprs nicely, a line break is inserted between the = and the value’s repr:

Model1.Space1.Cells1()=
array([[1, 2],
       [3, 4]])

Backward Incompatible Changes

Bug Fixes

MacOS incompatibility

Recent MacOS does not seem to allow changing stack size at runtime. To avoid error on changing the stack size at modelx invocation, modelx is refactored to use an executor in the main thread for Linux and MaxOS. Because of this change, the maximum number of recursion on MacOS is made significantly lower than that of Linux’s and Windows’.