Skip to content

Commit

Permalink
Replacing np.int usage with built-in int (EPFL-LCN#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwatts15 committed Jul 14, 2023
1 parent c1086e4 commit 81268fb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions neurodynex3/hopfield_network/pattern_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,25 +98,25 @@ def create_all_on(self):
Returns:
2d pattern, all pixels on
"""
return np.ones((self.pattern_length, self.pattern_width), np.int)
return np.ones((self.pattern_length, self.pattern_width), int)

def create_all_off(self):
"""
Returns:
2d pattern, all pixels off
"""
return -1 * np.ones((self.pattern_length, self.pattern_width), np.int)
return -1 * np.ones((self.pattern_length, self.pattern_width), int)

def create_checkerboard(self):
"""
creates a checkerboard pattern of size (pattern_length x pattern_width)
Returns:
checkerboard pattern
"""
pw = np.ones(self.pattern_length, np.int)
pw = np.ones(self.pattern_length, int)
# set every second value to -1
pw[1::2] = -1
pl = np.ones(self.pattern_width, np.int)
pl = np.ones(self.pattern_width, int)
# set every second value to -1
pl[1::2] = -1
t = linalg.toeplitz(pw, pl)
Expand All @@ -134,10 +134,10 @@ def create_L_pattern(self, l_width=1):
Returns:
an L shaped pattern.
"""
l_pat = -1 * np.ones((self.pattern_length, self.pattern_width), np.int)
l_pat = -1 * np.ones((self.pattern_length, self.pattern_width), int)
for i in range(l_width):
l_pat[-i - 1, :] = np.ones(self.pattern_length, np.int)
l_pat[:, i] = np.ones(self.pattern_length, np.int)
l_pat[-i - 1, :] = np.ones(self.pattern_length, int)
l_pat[:, i] = np.ones(self.pattern_length, int)
return l_pat

def reshape_patterns(self, pattern_list):
Expand Down

0 comments on commit 81268fb

Please sign in to comment.