{"action":"created","issue":{"url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/613","repository_url":"https://api.github.com/repos/Unidata/netcdf4-python","labels_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/613/labels{/name}","comments_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/613/comments","events_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/613/events","html_url":"https://github.com/Unidata/netcdf4-python/issues/613","id":194184526,"number":613,"title":"Setting variables with array-like objects","user":{"login":"skinny121","id":7391596,"avatar_url":"https://avatars.githubusercontent.com/u/7391596?v=3","gravatar_id":"","url":"https://api.github.com/users/skinny121","html_url":"https://github.com/skinny121","followers_url":"https://api.github.com/users/skinny121/followers","following_url":"https://api.github.com/users/skinny121/following{/other_user}","gists_url":"https://api.github.com/users/skinny121/gists{/gist_id}","starred_url":"https://api.github.com/users/skinny121/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skinny121/subscriptions","organizations_url":"https://api.github.com/users/skinny121/orgs","repos_url":"https://api.github.com/users/skinny121/repos","events_url":"https://api.github.com/users/skinny121/events{/privacy}","received_events_url":"https://api.github.com/users/skinny121/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-07T22:05:13Z","updated_at":"2016-12-08T16:31:03Z","closed_at":null,"body":"We have an array-like object which acts like a multidimensional array but internally ravels some of the dimensions to save on memory for intermediate operations. These object defines the 'ndim' attribute which is causing netCDF4 to think this object itself is a numpy array and will fail as it isn't a numpy array. These objects define the \\_\\_array\\_\\_ method which mean numpy.array()/numpyy.asarray() methods work. The current workaround is to call np.asarray() when ever setting netCDF variables. \r\n\r\nI think the check([source](https://github.com/Unidata/netcdf4-python/blob/4d1cb6293d9f098c5051aa96bbf0f8f5823cbdbb/netCDF4/_netCDF4.pyx#L4046)) if the data is a numpy array is insufficient as non numpy objects may define a 'ndim' attribute and probably should instead call numpy.asarray() to possibly convert the data to a numpy array. Does anyone else agree?\r\n\r\nThanks\r\nBen Lewis\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/comments/265785207","html_url":"https://github.com/Unidata/netcdf4-python/issues/613#issuecomment-265785207","issue_url":"https://api.github.com/repos/Unidata/netcdf4-python/issues/613","id":265785207,"user":{"login":"jswhit","id":579593,"avatar_url":"https://avatars.githubusercontent.com/u/579593?v=3","gravatar_id":"","url":"https://api.github.com/users/jswhit","html_url":"https://github.com/jswhit","followers_url":"https://api.github.com/users/jswhit/followers","following_url":"https://api.github.com/users/jswhit/following{/other_user}","gists_url":"https://api.github.com/users/jswhit/gists{/gist_id}","starred_url":"https://api.github.com/users/jswhit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jswhit/subscriptions","organizations_url":"https://api.github.com/users/jswhit/orgs","repos_url":"https://api.github.com/users/jswhit/repos","events_url":"https://api.github.com/users/jswhit/events{/privacy}","received_events_url":"https://api.github.com/users/jswhit/received_events","type":"User","site_admin":false},"created_at":"2016-12-08T16:31:03Z","updated_at":"2016-12-08T16:31:03Z","body":"see pull request #613"}}
{"actor":{"display_login":"jswhit"}}