From f4e5518d98ee6274764529c6c5895dbb7c7e488d Mon Sep 17 00:00:00 2001 From: businessglitch Date: Wed, 31 Oct 2018 20:23:49 -0400 Subject: [PATCH] Code crashes on mapsize[0] * mapsize[1] This needs to be changed to self.mapsize[0]* self.mapsize[1] If one value is passed to the mapsize eg: mapsize[1000], this indicates the number of nodes _size = [1, mapsize[0]] this creates a new array , [1,1000] self.mapsize = _size assigns newarray to self.mapsize. self.nnodes = mapsize[0]*mapsize[1].. here mapsize is still the old array that was passed as a parameter [1000] * outof bound index, throws error --- sompy/codebook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sompy/codebook.py b/sompy/codebook.py index 1195347..1376562 100644 --- a/sompy/codebook.py +++ b/sompy/codebook.py @@ -41,7 +41,7 @@ def __init__(self, mapsize, lattice='rect'): "Mapsize is expected to be a 2 element list or a single int") self.mapsize = _size - self.nnodes = mapsize[0]*mapsize[1] + self.nnodes = self.mapsize[0]*self.mapsize[1] self.matrix = np.asarray(self.mapsize) self.initialized = False