Maurizio wrote: > Hi Fergus, > > thank you for your comments! > So, do you consider working on a Quantity porting worthwhile? It seems > that you got some good experience by working on it, so you can > probably give some better advice about the structure of that package. > > Moreover, I'm wondering how much work would it require to try to allow > symbolic support for SAGE for Quantities or any other units package.
As far as the Quantities package goes, it seems to be the problems that we have always seen between numpy and sage types. I'm not quite sure what is going on. A Quantity is just a subclass of ndarray. Here are a few lines illustrating the line where the problem occurs. How come, in the first case, NotImplemented is returned? sage: import quantities as pq sage: other_sage=numpy.asarray(10).view(pq.Quantity) sage: super(pq.Quantity, pq.ohm).__mul__(other_sage) NotImplemented That is what causes the error. However, when we convert the numpy array representing other to a python integer array, we get something that we can use: sage: super(pq.Quantity, pq.ohm).__mul__(other_sage.astype(int)) array(10.0)*dimensionless Without the supers above, these two examples are: sage: import numpy sage: numpy.ndarray.__mul__(numpy.array(float(1.0)),other_sage) NotImplemented sage: numpy.ndarray.__mul__(numpy.array(float(1.0)),other_sage.astype(int)) array(10.0)*dimensionless Does anyone know what is going on here? I'm not sure where the source of numpy.ndarray.__mul__ is. Thanks, Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to sage-devel-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---