{"action":"created","issue":{"url":"https://api.github.com/repos/nengo/nengo/issues/626","labels_url":"https://api.github.com/repos/nengo/nengo/issues/626/labels{/name}","comments_url":"https://api.github.com/repos/nengo/nengo/issues/626/comments","events_url":"https://api.github.com/repos/nengo/nengo/issues/626/events","html_url":"https://github.com/nengo/nengo/issues/626","id":54816509,"number":626,"title":"Potentially confusing Node behaviour","user":{"login":"drasmuss","id":1952220,"avatar_url":"https://avatars.githubusercontent.com/u/1952220?v=3","gravatar_id":"","url":"https://api.github.com/users/drasmuss","html_url":"https://github.com/drasmuss","followers_url":"https://api.github.com/users/drasmuss/followers","following_url":"https://api.github.com/users/drasmuss/following{/other_user}","gists_url":"https://api.github.com/users/drasmuss/gists{/gist_id}","starred_url":"https://api.github.com/users/drasmuss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drasmuss/subscriptions","organizations_url":"https://api.github.com/users/drasmuss/orgs","repos_url":"https://api.github.com/users/drasmuss/repos","events_url":"https://api.github.com/users/drasmuss/events{/privacy}","received_events_url":"https://api.github.com/users/drasmuss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-01-19T21:48:05Z","updated_at":"2015-01-20T22:25:03Z","closed_at":null,"body":"Pulling a Travis here and submitting bugs in my code as Nengo bugs, but just spent a little while tracking this down and thought I should document it.  Here's a minimal example:\r\n```python\r\nwith nengo.Network() as net:\r\n    class Test:\r\n        tmp = 0.0\r\n        \r\n        def __call__(self, t):\r\n            if t == 0.5:\r\n                self.tmp = t\r\n            print self.tmp\r\n            \r\n    a = nengo.Node(output=Test())\r\n    \r\nsim = nengo.Simulator(net, dt=0.25)\r\nsim.run(1.0)\r\n```\r\nI think most people would expect that to print out \"0.0, 0.0, 0.5, 0.5, 0.5, ...\", but in reality it prints out \"0.0, 0.0, 0.5, 0.75, 1.0, ...\".  Clearly (in hindsight) the problem is that `t` is an ndarray, not a float, so `tmp` and `t` get aliased.  But the problem is that `t` looks and acts, in basically all other respects, as if it is a float (e.g., `t == 0.5` passes, `t[0]` fails, etc.).\r\n\r\nPotential solutions\r\n1) cast `t` to a float before passing it to the `Node` function (cleanest solution, but pay the cost of type cast)\r\n2) document this clearly in `Node` (hope people read it)\r\n3) this is desired behaviour, make fun of Daniel for making CS 101 errors"},"comment":{"url":"https://api.github.com/repos/nengo/nengo/issues/comments/70747035","html_url":"https://github.com/nengo/nengo/issues/626#issuecomment-70747035","issue_url":"https://api.github.com/repos/nengo/nengo/issues/626","id":70747035,"user":{"login":"hunse","id":1952250,"avatar_url":"https://avatars.githubusercontent.com/u/1952250?v=3","gravatar_id":"","url":"https://api.github.com/users/hunse","html_url":"https://github.com/hunse","followers_url":"https://api.github.com/users/hunse/followers","following_url":"https://api.github.com/users/hunse/following{/other_user}","gists_url":"https://api.github.com/users/hunse/gists{/gist_id}","starred_url":"https://api.github.com/users/hunse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunse/subscriptions","organizations_url":"https://api.github.com/users/hunse/orgs","repos_url":"https://api.github.com/users/hunse/repos","events_url":"https://api.github.com/users/hunse/events{/privacy}","received_events_url":"https://api.github.com/users/hunse/received_events","type":"User","site_admin":false},"created_at":"2015-01-20T22:25:03Z","updated_at":"2015-01-20T22:25:03Z","body":"For arrays above 1000 elements, the copying time seems to become linear, and it quickly becomes much more efficient to make a read-only view. \r\n\r\n![test_arraycopy](https://cloud.githubusercontent.com/assets/1952250/5827543/3e5bc3a2-a0c9-11e4-83e1-f1fc1a6324e9.png)\r\n"}}