You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was using Grid as a base class for a class (in cosmology). For now let's call this CosmoGrid. But I ran into some issues.
First, the arithmetic operations (add etc) return Grid. I am not a OOP ninja, but I think if you have them return self.__class__(...) instead, then they will return an instance of the same subclass (CosmoGrid).
Second, one might want to wish to pass into Grid, not an ndarray but a subclass of an ndarray: for example an array of "Quantities" (that have astropy.units units attached, or a masked array). Will not the line self.grid = numpy.asarray(grid) convert this into a normal ndarray? (the docs say: Returns out: ... If a is a subclass of ndarray, a base class ndarray is returned.) The alternative might be numpy.asanyarray, for which the docs say "Convert the input to an ndarray, but pass ndarray subclasses through."
The text was updated successfully, but these errors were encountered:
@AstroMike a PR would be most welcome – developer bandwidth is a bit limited at the moment. We're currently mostly occupied with getting a 1.0 of MDAnalysis out. This will likely be of 0% importance to you ;-). But we're very happy to make GridDataFormats better/more correct/more useful to anyone who finds a use for it.
@richardjgowers do you want to knock this one out? I want to do a 0.4.1 today or tomorrow – there were a whole bunch of bug fixes that should have been pushed out long ago
I was using Grid as a base class for a class (in cosmology). For now let's call this CosmoGrid. But I ran into some issues.
First, the arithmetic operations (add etc) return Grid. I am not a OOP ninja, but I think if you have them return
self.__class__(...)
instead, then they will return an instance of the same subclass (CosmoGrid).Second, one might want to wish to pass into Grid, not an ndarray but a subclass of an ndarray: for example an array of "Quantities" (that have astropy.units units attached, or a masked array). Will not the line
self.grid = numpy.asarray(grid)
convert this into a normal ndarray? (the docs say: Returns out: ... If a is a subclass of ndarray, a base class ndarray is returned.) The alternative might be numpy.asanyarray, for which the docs say "Convert the input to an ndarray, but pass ndarray subclasses through."The text was updated successfully, but these errors were encountered: