Closed stas-g closed 1 year ago
Thanks for the message @stas-g, this looks like a bug. We will try to look at this asap.
Hey @stas-g, Sorry this took longer than I expected. I think I have solved the issue. Please try this:
from cana.boolean_network import BooleanNetwork
P = BooleanNetwork.from_file("/home/xxx.txt", type='logical', keep_constants=True)
P.set_constant(node=2, constant=True, state=0) # <this is NEW>
P.get_constants() # <this is NEW>
>>> {2: <cana.boolean_node.BooleanNode at 0xa1bc39b50>}
STG = P.state_transition_graph()
STG.number_of_nodes()
>>> 8
x0 = '1110'
P.attractor(initial=x0)
>>> [6]
P.trajectory_to_attractor(initial=x0)
>>> ['1110', '1101', '1100']
Just note that the STG is a variable that is stored internally on P
(for efficiency), so if you modify constants on the fly you need to make sure the STG is updated.
I haven't sent a build to pipy because I still want to do more testing on this with the other authors to make sure nothing broke elsewhere. But you can install the latest version pushed to github.
Again, thank for raising this issue! With kind regards,
excellent! thank you, will give this a try this upcoming week!
hi again,
just got about to properly test this and i don't think the changes you have made do not filter through as i get:
Traceback (most recent call last):
File "/tmp/ipykernel_19411/3364207077.py", line 1, in <module>
P.set_constant(node=2, constant=True, state=0) # <this is NEW>
TypeError: set_constant() got an unexpected keyword argument 'constant'
P.get_constants()
Traceback (most recent call last):
File "/tmp/ipykernel_19411/2667334193.py", line 1, in <module>
P.get_constants()
AttributeError: 'BooleanNetwork' object has no attribute 'get_constants'
i used both pip install git+git://github.com/rionbr/CANA
and pip install cana
in hope that if there are any changes to the module (which i know there have been), a newer version would be installed but clearly this doesn't happen.
i believe i run cana version 0.1.2.
hi Rion,
update: uninstalled and reinstalled cana and it all works now. many thanks for your help!
best, stas
I was able to reproduce the correct output above here. So I am marking this as resolved.
hello, i found some bad behaviour. adding constants seem to be breaking
state_transition_graph
function and making attractor calculating functions to run ad infimum. additionally, i noticed that adding constants by hand does not add them to theconstants
attribute of a BN object. simple reproducible example:code: