-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scalar FileVariable as data for createVariable() #1325
Comments
While you’re fixing this one could you please make TransientVariables pickable? They currently throw a number of exceptions if you try to pickle/unpickle them. Being able to pickle these objects would greatly facilitate the parallelization of cdms. — Tom From: Jeffrey Painter <notifications@github.commailto:notifications@github.com> Suppose you have a scalar FileVariable fv, i.e. fv.shape==(). You want to create a scalar TransientVariable from it, so you call cdms2.createVariable( fv ). It throws an exception! The reason is that TransientVariable.init() calls data.subSlice() as almost the first thing it does, and assumes that the result is a TransientVariable with a getDomain() method. It isn't, subSlice() on a scalar FileVariable is a numpy scalar (numpy.int32 in my case) and hence has no such method. My workaround is to supply as data fv.subSlice() rather than fv. But this is a bug - either in TransientVariable.init() or in FileVariable.subSlice(), your choice (or my choice if I'm the one to fix it). — |
Charles asked for more detail, so here it is: >>> bb=cdms2.createVariable( nbd, id=nbd.id ) >>> nbd.shape And Charles asked why anyone would want a scalar FileVariable? I'm reading in all the variables of a large file; as FileVariable because most have to be changed in the file. Sometimes I also need to create a TransientVariable from them. A couple scalars are among the hundreds of variables. |
Suppose you have a scalar FileVariable fv, i.e. fv.shape==(). You want to create a scalar TransientVariable from it, so you call cdms2.createVariable( fv ). It throws an exception! The reason is that TransientVariable.init() calls data.subSlice() as almost the first thing it does, and assumes that the result is a TransientVariable with a getDomain() method. It isn't, subSlice() on a scalar FileVariable is a numpy scalar (numpy.int32 in my case) and hence has no such method.
My workaround is to supply as data fv.subSlice() rather than fv. But this is a bug - either in TransientVariable.init() or in FileVariable.subSlice(), your choice (or my choice if I'm the one to fix it).
The text was updated successfully, but these errors were encountered: