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
10 changes: 5 additions & 5 deletions netomaton/evolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def _get_input_function(timesteps=None, input=None):


def _is_indexable(obj):
return isinstance(obj, collections.Sequence)
return isinstance(obj, collections.abc.Sequence)


class _TimestepInputFunction:
Expand All @@ -441,7 +441,7 @@ def __call__(self, t, activities, network):
return self._input_list[t-1]


def init_simple(size, val=1, dtype=np.int):
def init_simple(size, val=1, dtype=int):
"""
Returns an array initialized with zeroes, with its center value set to the specified value, or 1 by default.
:param size: the size of the array to be created
Expand All @@ -454,7 +454,7 @@ def init_simple(size, val=1, dtype=np.int):
return x.tolist()


def init_random(size, k=2, n_randomized=None, empty_value=0, dtype=np.int):
def init_random(size, k=2, n_randomized=None, empty_value=0, dtype=int):
"""
Returns a randomly initialized array with values consisting of numbers in {0,...,k - 1}, where k = 2 by default.
If dtype is not an integer type, then values will be uniformly distributed over the half-open interval [0, k - 1).
Expand All @@ -480,7 +480,7 @@ def init_random(size, k=2, n_randomized=None, empty_value=0, dtype=np.int):
return np.array(np.pad(np.array(rand_nums), (pad_left, pad_right), 'constant', constant_values=empty_value)).tolist()


def init_simple2d(rows, cols, val=1, dtype=np.int):
def init_simple2d(rows, cols, val=1, dtype=int):
"""
Returns a list initialized with zeroes, with its center value set to the specified value, or 1 by default, when the
list is reshaped according to the given number of rows and columns.
Expand All @@ -497,5 +497,5 @@ def init_simple2d(rows, cols, val=1, dtype=np.int):

def check_np(obj):
if isinstance(obj, np.generic):
return np.asscalar(obj)
return obj.item()
return obj
2 changes: 1 addition & 1 deletion netomaton/hopfield_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def train(self, P):
adjacency matrix. Therefore, before the network can be used to evaluate a pattern, it must be trained.
:param P: the set of training patterns, as a list of lists
"""
self._adjacency_matrix = np.zeros((len(P[0]), len(P[0])), dtype=np.int)
self._adjacency_matrix = np.zeros((len(P[0]), len(P[0])), dtype=int)
for p in P:
for i in range(len(p)):
for j in range(len(p)):
Expand Down
2 changes: 1 addition & 1 deletion netomaton/langtons_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def init_loops(self, n, row, col):
:return: the initial conditions
"""

initial_conditions = np.zeros(self._dim, dtype=np.int)
initial_conditions = np.zeros(self._dim, dtype=int)
for i in range(n):
row_i = row[i]
col_i = col[i]
Expand Down
2 changes: 1 addition & 1 deletion netomaton/rule_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def random_rule_table(k, r, lambda_val=None, quiescent_state=None, strong_quiesc
if lambda_val is None:
lambda_val = 1. - (1. / k)
if quiescent_state is None:
quiescent_state = np.random.randint(k, dtype=np.int)
quiescent_state = np.random.randint(k, dtype=int)
if not (0 <= quiescent_state <= k - 1):
raise Exception("quiescent state must be a number in {0,...,k - 1}")
other_states = [x for x in range(0, k) if x != quiescent_state]
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools>=64.0"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion tests/resources/small_world_density_classification.ca

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tests/rule_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _convert_to_matrix(self, filename, dtype=int):
content = content.replace('{', '')
content = content.replace('},', ';')
content = [[dtype(i) for i in x.split(',')] for x in content.split(';')]
return np.array(content, dtype=np.int)
return np.array(content, dtype=int)

def _convert_to_matrix2d(self, filename, dtype=int):
with open(os.path.join(THIS_DIR, 'resources', filename), 'r') as content_file:
Expand All @@ -30,7 +30,7 @@ def _convert_to_matrix2d(self, filename, dtype=int):
content = [x.split('},') for x in content.split('}},')]
content = [[h.split(',') for h in x] for x in content]
content = [[[dtype(i) for i in h] for h in x] for x in content]
return np.array(content, dtype=np.int)
return np.array(content, dtype=int)

def _convert_to_list_of_lists(self, filename, strings=False, dtype=int):
with open(os.path.join(THIS_DIR, 'resources', filename), 'r') as content_file:
Expand Down