Thank you Jason, I'll try it as soon as possible. By the way, have you got any idea about where in the code should I look at to let it work with SAGE numbers? Something like constructors or stuff like that?
Thanks Maurizio On 15 Mar, 02:29, Jason Grout <jason-s...@creativetrax.com> wrote: > Maurizio wrote: > > To be honest, I'd have thought that installing a python package and > > let it work with SAGE would have been easier, but one issue could be > > that I've been working on this in a Saturday night (after coming back > > home) from midnight to 1.30 am!! :) > > > I summarize the way I got "quantities" (http://pypi.python.org/pypi/ > > quantities) installed at the end (consider I'm using a VMWare virtual > > machine from XP): > > 1. login as manage > > 2. sudo su > > 3. type sage -sh to go into the sage environment > > 4. unpack and install quantities > > 5. run SAGE and python and test > > > The first test failed. I mean, I got it installed and running: > > 1) unpack the quantities-0.5b2.tar.gz > > 2) python setup.py install > > > The result is not satisfying me: > > > 1) if I run python from that sage -sh shell, I can use quantities in > > the same way they show in the tutorial (http://packages.python.org/ > > quantities/user/tutorial.html). They seem to clearly claim that > > quantities is still in an advanced beta development phase, so it's not > > fully documented, nor available for production (yet). > > I can confirm, the documentation seems missing: example > > > import quantities as pq > > pq.Quantity? > > > File: /usr/local/sage/local/lib/python2.5/site-packages/ > > quantities-0.5b2-py2.5.egg/quantities/quantity.py > > Type: <type 'type'> > > Definition: pq.Quantity( [noargspec] ) > > Docstring: > > x.__init__(...) initializes x; see x.__class__.__doc__ for signature > > > That's it! Seems poor... > > > 2) The biggest issue is that I can't get it to work within a SAGE > > notebook: > > > from numpy import * > > import quantities as pq > > res = 10*pq.ohm > > > Traceback (click to the left for traceback) > > ... > > TypeError: unsupported operand parent(s) for '*': 'Integer Ring' and > > '<class 'quantities.unitquantity.UnitQuantity'>' > > It sounds like the problems is the known issue that numpy does not > interact very well with Sage data types. Try this: > > from numpy import * > import quantities as pq > res = 10r*pq.ohm > > The 10r means to create a python integer, rather than a Sage integer. > > It sounds like there could/should be a small change in quantities made > to support Sage datatypes. My guess is that it would take just a few > minutes. > > Jason > > > > > I'm really not that good with all this stuff, but my understanding is > > that, whenever you try to define a new object like an integer or a > > float number times a "quantities" unit, it somehow forces the number > > to become a numpy array. This seems to fail within a SAGE notebook. > > > Any idea on how this could be fixed, or otherwise should be not? > > I am just talking out of couple of minutes working on it, I admit it. > > > Anyway, I'll try to get the other packages installed as well, although > > I am not sure when. Any other suggestion or comment is very well > > accepted! > > > Final comment: should I have done any other sage command to let it > > reload or synchronize the newly installed sage packages, before > > running the notebook? > > > Thank you > > > Maurizio > > > Maurizio > > > On 14 Mar, 09:21, Jason Grout <jason-s...@creativetrax.com> wrote: > >> Maurizio wrote: > >>> Hello, > >>> I'm forwarding this to sage-devel as well, maybe being the most > >>> appropriate group to address this issue. > >>> I'm a happy user of SAGE, and I won't stop thanking all you guys for > >>> this wonderful job! Although, I also try to encourage you in getting > >>> something better (from my point of view). > >>> It seems there has been some serious thinking about including a UNITS > >>> of MEASUREMENTS managing package in SAGE: > >>>http://groups.google.com/group/sage-devel/browse_frm/thread/8791448b7... > >>> From this, a SAGE trac ticket has been opened (#3852): > >>>http://trac.sagemath.org/sage_trac/ticket/3852 > >>> This is supposed to be a MAJOR priority ticket, and I think this is a > >>> very appropriate description! > >> I agree. I should also add that nearly every ticket in trac is marked > >> as major priority. Indeed, there are lots and lots of things to do on > >> Sage. That's why we really appreciate your help! > > >>> The ticket has a very good (although a bit old now) description of the > >>> different packages available to deal with units in Python. One of the > >>> options, was the units package included in Enthought. This had the > >>> issue of being under refactoring at that time. > >>> The actual situation seems to be that the Enthought package has not > >>> been changed (https://svn.enthought.com/enthought/ticket/1524) because > >>> of some priority issues in that community (very understandable!), but > >>> another interesting package was born from this Enthought discussion: > >>> the "quantities" package: > >>>http://packages.python.org/quantities/ > >>>http://dale.chess.cornell.edu/chess-wiki/Quantities > >> Thanks for tracking this down. I wondered if it would ever get > >> refactored. What do you think of the Quantities module? I browsed > >> through the documentation and it looked very interesting. On the plus > >> side, it's being actively developed now, which I think sets it apart > >> from any of the other solutions, right? > > >>> As I can see, this has already been mentioned in a comment to our trac > >>> ticket, but with no response. > >>> Honestly, I am not able to understand whether this is good enough to > >>> be included in SAGE, neither I am able of understanding how much > >>> refactoring this would need to make this compatible to all the > >>> wonderful symbolic capabilities of SAGE, but nonetheless I think that > >>> getting something working at least in the numeric domain, could be > >>> very useful > >>> With this, I'm not proposing this package over others (for example, > >>> Unum looks very mature, but outdated), I'm just asking if one of you > >>> can spend some minutes to review our trac ticket about units of > >>> measurement (#3852), and to take some other decision about it. > >> Which package do you prefer? I think at this point, someone needs to > >> just make a decision with one of the packages and justify it on > >> sage-devel. Preferably, that person would offer instructions to install > >> the top one or two (or three?) choices so that people could try them > >> out. They would probably also give examples of syntax so others could > >> see (and maybe compare that to the syntax of the other packages). > > >> Installation is easy if you are familiar with the command line. Just do: > > >> $ sage -sh > > >> Then follow whatever instructions the package gives for installation. > >> That will install the package into Sage's python library. > > >> 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 -~----------~----~----~----~------~----~------~--~---