ioam / topographica

A general-purpose neural simulator focusing on topographic maps.
topographica.org
BSD 3-Clause "New" or "Revised" License
53 stars 32 forks source link

AttributeError: cos #496

Closed antolikjan closed 10 years ago

antolikjan commented 11 years ago

Context: fresh topographica install on Eddie (from git). Installed pillow,matplotlib and numpy into virtualenv (via pip).

When trying to run my simulation I am getting the error below.

Traceback (most recent call last): File "/exports/work/inf_ndtc/s0570140/NEW_ENVIRONMENT/topographica/topo/command/init.py", line 849, in call topo.sim.run(run_to - topo.sim.time()) File "/exports/work/inf_ndtc/s0570140/NEW_ENVIRONMENT/topographica/topo/base/simulation.py", line 1357, in run event(self) File "/exports/work/inf_ndtc/s0570140/NEW_ENVIRONMENT/topographica/topo/base/simulation.py", line 530, in call self.fn(_self.args,__self.kw) File "/exports/work/inf_ndtc/s0570140/NEW_ENVIRONMENT/topographica/topo/misc/generatorsheet.py", line 103, in generate self.activity[:] = self.input_generator() File "/exports/work/inf_ndtc/s0570140/NEW_ENVIRONMENT/topographica/contrib/CCLISSOM_push_pull_extra.py", line 71, in call return generator(xdensity=xdensity, ydensity=ydensity, bounds=bounds, x=self.x + self.jitter_magnitude * self.r(), y=self.y + self.jitter_magnitude * self.r(), orientation=self.inspect_value("orientation"), index=self.inspect_value("index")) File "/exports/home/s0570140/go_new/topographica/external/imagen/imagen/patterngenerator.py", line 140, in call self._setup_xy(p.bounds,p.xdensity,p.ydensity,p.x,p.y,p.orientation) File "/exports/home/s0570140/go_new/topographica/external/imagen/imagen/patterngenerator.py", line 166, in _setup_xy self.pattern_x, self.pattern_y = self._create_and_rotate_coordinate_arrays(x_points-x,y_points-y,orientation) File "/exports/home/s0570140/go_new/topographica/external/imagen/imagen/patterngenerator.py", line 193, in _create_and_rotate_coordinate_arrays pattern_y = subtract.outer(cos(orientation)_y, sin(orientation)*x) AttributeError: cos

jbednar commented 11 years ago

That's bizarre. In my copy of the code, line 11 of patterngenerator.py does "from numpy import add,subtract,cos,sin", which should clearly provide a definition for cos. Can you check that the same is true for your copy of the file? I can't run your CCLISSOM_push_pull_extra.py example, but everything works fine for tiny.ty at least, at my end.

One clue might be that your virtualenv directory is NEW_ENVIRONMENT/topographica, but it seems to be getting imagen from go_new/topographica; maybe you didn't install the submodules in the virtualenv version and it's finding some old version of imagen? Not sure, really.

antolikjan commented 11 years ago

Hello Jim,

On Tue, Dec 18, 2012 at 5:43 PM, James A. Bednar notifications@github.comwrote:

That's bizarre. In my copy of the code, line 11 of patterngenerator.py does "from numpy import add,subtract,cos,sin", which should clearly provide a definition for cos. Can you check that the same is true for your copy of the file? I can't run your CCLISSOM_push_pull_extra.py example, but everything works fine for tiny.ty at least, at my end.

One clue might be that your virtualenv directory is NEW_ENVIRONMENT/topographica, but it seems to be getting imagen from go_new/topographica; maybe you didn't install the submodules in the virtualenv version and it's finding some old version of imagen? Not sure, really.

That doesn't seem to be a problem bacause the go_new is in fact a symbolic link to the NEW_ENVIRONMENT directory (I even did a diff on the patterngenerator.py file with both version of the path and there is indeed no difference). I don't know why the trace switches between using the 'true' path and the one via the symbolic link, but I cannot imagine that to be a problem.

Reply to this email directly or view it on GitHubhttps://github.com/ioam/topographica/issues/496#issuecomment-11494477.

jbednar commented 11 years ago

Ok, so ignoring the strange but harmless go_new behavior, what's the answer to whether your copy of patterngenerator.py does in fact import cos before it's used?

antolikjan commented 11 years ago

line 11: from numpy import add,subtract,cos,sin

This is really bizarre.

On Wed, Dec 19, 2012 at 2:21 PM, James A. Bednar notifications@github.comwrote:

Ok, so ignoring the strange but harmless go_new behavior, what's the answer to whether your copy of patterngenerator.py does in fact import cos before it's used?

— Reply to this email directly or view it on GitHubhttps://github.com/ioam/topographica/issues/496#issuecomment-11529698.

jbednar commented 11 years ago

Inexplicable. It's strange that it's an AttributeError, as well. E.g. I just took my copy of patterngenerator.py, and removed the import of cos, in which case I get "NameError: global name 'cos' is not defined". The only way I can get an AttributeError is by doing x.a, where a is not the name of an attribute of x. Otherwise Python is looking for a global name, and raising a NameError when it doesn't find it.

I don't think I can do any further debugging without a runnable copy of the .ty file that led to the error; maybe one of them is redefining cos or something else crazy like that...

antolikjan commented 11 years ago

Hello Jim,

I am going to investigate this further. In any case, if you clone my topographica contrib repo:

https://github.com/antolikjan/topographica-contrib

you can run the model with this command:

./topographica/topographica -ac "ImageScale=0.45;AFF_lr=0.5;MUE=0.01;MUI=0.01;SETAE=0.004;SETAI=0.002;default_density=20;LGNStr=4.5;SEEStr=0.1;SEIStr=1.0;SIEStr=-2.0;SIIStr=-1.0;Inbalance=0.0;reset_period=40;SS=1;PP_lr=0.1" ./topographica/contrib/CCLISSOM_push_pull.ty -c "topo.sim.run(100)"

(assuming you cloned into the topographica directory)

I should stress that I seem to get this error only on eddie, not on my desktop installation.

Jan

On Wed, Dec 19, 2012 at 2:51 PM, James A. Bednar notifications@github.comwrote:

Inexplicable. It's strange that it's an AttributeError, as well. E.g. I just took my copy of patterngenerator.py, and removed the import of cos, in which case I get "NameError: global name 'cos' is not defined". The only way I can get an AttributeError is by doing x.a, where a is not the name of an attribute of x. Otherwise Python is looking for a global name, and raising a NameError when it doesn't find it.

I don't think I can do any further debugging without a runnable copy of the .ty file that led to the error; maybe one of them is redefining cos or something else crazy like that...

— Reply to this email directly or view it on GitHubhttps://github.com/ioam/topographica/issues/496#issuecomment-11530509.

jlstevens commented 10 years ago

This issue is quite old now - Philipp and I are currently using Topographica on Eddie regularly without any problem. If this is still an issue please reopen it!