Corrected a glitch in layer.__init__, which could cause problems with

layers having different number of nodes
master
KatolaZ 10 years ago
parent 103290dd44
commit 0e27ea5ba7
  1. 20
      python/multired.py

@ -103,10 +103,10 @@ class layer:
d = int(elems[1]) d = int(elems[1])
self._ii.append(s) self._ii.append(s)
self._jj.append(d) self._jj.append(d)
if s > self.N: #if s > self.N:
self.N = s # self.N = s
if d > self.N: #if d > self.N:
self.N = d # self.N = d
if s < min_N: if s < min_N:
min_N = s min_N = s
if d < min_N: if d < min_N:
@ -116,6 +116,12 @@ class layer:
self._ww.append(float(val)) self._ww.append(float(val))
else: else:
self._ww.append(int(1)) self._ww.append(int(1))
m1 = max(self._ii)
m2 = max(self._jj)
if m1 > m2:
self.N = m1
else:
self.N = m2
except (IOError): except (IOError):
print "Unable to find/open file %s -- Exiting!!!" % layerfile print "Unable to find/open file %s -- Exiting!!!" % layerfile
@ -207,10 +213,12 @@ class multiplex_red:
if (self.verb): if (self.verb):
sys.stderr.write("Loading layer %d from file %s" % (len(self.layers), l)) sys.stderr.write("Loading layer %d from file %s" % (len(self.layers), l))
A = layer(l.strip(" \n")) A = layer(l.strip(" \n"))
if A.N > self.N: #if A.N > self.N:
self.N = A.N+1 # self.N = A.N+1
self.layers.append(A) self.layers.append(A)
n = 0 n = 0
N = max([x.N for x in self.layers])
self.N = N + 1
for l in self.layers: for l in self.layers:
l.make_matrices(self.N) l.make_matrices(self.N)
l.num_layer = n l.num_layer = n

Loading…
Cancel
Save