Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/Canalizing-Depth-Dynamics.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 19 additions & 1 deletion core/discrete_dynamical_system.pyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This is my boilerplate code.
"""

import math
import numpy as np

Expand Down Expand Up @@ -84,4 +85,21 @@ class Dynamical(object):

def placeholder(self):
""" Not enough public methods otherwise"""
pass
pass


def generate_boolean_functions(length):
rows = []
functionvalues = []
for j in range(2**length):
rows.append(list([int(i)for i in binary_fixed_length(j,length)]))
functionvalues.append(0)
rows.append(list([int(i)for i in binary_fixed_length(j,length)]))
functionvalues.append(1)
"""appended twice as it can be 0 or 1 """

return rows, functionvalues
"""ith element of functionvalues is the value for the ith element of row"""



1 change: 1 addition & 0 deletions core/find_attractors.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Find attractors using the other new method discussed at the meeting on 6/3/18"""

import numpy as np
import pyximport
pyximport.install()
Expand Down
3 changes: 3 additions & 0 deletions core/generate_k_canalyzing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def all_numbers_but(exceptions, maxn):
temp.append(i)
return temp

def find_canalizing_depth( ):


def random_k_canalyzing(num_vars, depth):
"""Method to generate a random k-canalyzing function"""
if depth == 0:
Expand Down
1 change: 1 addition & 0 deletions core/optimized_find_attractors.pyx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Find attractors using the other new method discussed at the meeting on 6/3/18"""

import numpy as np
import pyximport
pyximport.install()
Expand Down
23 changes: 22 additions & 1 deletion core/random_noncanalysing.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,34 @@ def overwrite_at(my_list, index, seq):
def is_canalizing(table, var):
"""Checks whether var (counting from the right) is a canalizing for a function given by the table"""
io_pairs_seen = {}
for i in xrange(len(table)):
for i in range(len(table)):
inp = (i >> var) % 2
io_pairs_seen[table[i] * 2 + inp] = 1
if len(io_pairs_seen) == 4:
return False
return len(io_pairs_seen) < 4

def is_canalizing_function(table):
for var in range(len(table)):
if is_canalizing(table, var):
return True
break
return False

def find_canalizing_depth(table):
depth = 0
for var in range(len(table)):
new_table = table[var:]
if is_canalizing(new_table, len(table)-1-var):
depth = depth +1
if is_canalizing_function(table[var+1:]) == False:
break
return depth





#Main function
def random_noncanalysing_func(num_vars):
"""Generates a random non-canalysing function on num_vars variables.
Expand Down
62 changes: 62 additions & 0 deletions tests/unit_tests/boolean_function&canalizing_depth_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import unittest
import pyximport
pyximport.install()
import numpy as np
from math import *
import sys
sys.path.insert(0, '../../core')
import discrete_dynamical_system as dds
import generate_k_canalyzing as gkc

def generate_boolean_functions(length):
rows = []
functionvalues = []
for j in range(2**length):
rows.append(list([int(i)for i in dds.binary_fixed_length(j,length)]))
functionvalues.append(0)
rows.append(list([int(i)for i in dds.binary_fixed_length(j,length)]))
functionvalues.append(1)
return rows, functionvalues


def find_canalizing_depth(table):
depth = 0
for var in range(len(table)):
new_table = table[var:]
if gkc.is_canalizing(new_table, len(table)-1-var):
depth = depth +1
if gkc.is_canalizing_function(table[var+1:]) == False:
break
return depth

class Test(unittest.TestCase):
def setUp(self):
pass

def test_boolean_functions(self):
n = 10
(rows, functionvalues) = generate_boolean_functions(n)

flag = True

if len(rows) != 2**(2**n):
flag = False

""" check whether number of boolean functions are correct """

self.assertEqual (flag, True)

def test_find_canalyzing_depth(self):
num_vars = 10
depth = 5

flag = True
table = gkc.random_k_canalyzing(num_vars,depth)

if find_canalizing_depth(table) != depth:
flag = False

self.assertEqual (flag, True)

if __name__ == '__main__':
unittest.main()