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. 34
      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,7 +116,13 @@ 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
exit(-2) exit(-2)
@ -207,15 +213,17 @@ 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
for l in self.layers: N = max([x.N for x in self.layers])
l.make_matrices(self.N) self.N = N + 1
l.num_layer = n for l in self.layers:
n += 1 l.make_matrices(self.N)
self.M = len(self.layers) l.num_layer = n
n += 1
self.M = len(self.layers)
except ( IOError): except ( IOError):
print "Unable to find/open file %s -- Exiting!!!" % layer_file print "Unable to find/open file %s -- Exiting!!!" % layer_file
exit(-2) exit(-2)

Loading…
Cancel
Save