UserSpace.precedents#
- UserSpace.precedents(*args, **kwargs)#
Return a list of the precedents.
This is a method of Cells and Space types, and returns a list of
Node
objects that are precedents of the object’s node specified by the arguments passed to the method.The
preds()
method is similar to this method, butpreds()
only lists nodes of Cells and Spaces. This method also lists nodes of Reference values in addition to the nodes of Cells and Spaces returned bypreds()
.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 Cellsfoo
, and 3 References,x
,Child.y
, andChild.GrandChild.z
. Below,bar.preds(3)
returns a list containingfoo(3)
, which is the only Cells element thatbar(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 thatbar(3)
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]
References whose values are modelx objects, such as
Cells
andSpaces
, are not included in the lists returned by this method.Added in version 0.15.0.