Message Boards Message Boards

0
|
17412 Views
|
14 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Why doesn't Quantity[] and related functions work for me?

14 Replies
POSTED BY: Gustavo Delfino
Posted 9 years ago
POSTED BY: Dana DeLouis
Posted 9 years ago
POSTED BY: Dana DeLouis

It is probably worth clarifying that this is presumably a sporadic issue--I have never encountered it (Mac installation) and the various folks that I work with who are using a similar installation have not encountered it. As in all cases where something is not working that clearly should work, it's best to contact Wolfram technical support to get the inside track as Dana DeLouis did.

POSTED BY: David Reiss

"Any port in a storm." I'm glad it's working now!

POSTED BY: David Reiss

In fact, I just checked by trying to load Units, and got a "Cannot open "Units`" $Failed result. So whatever I did earlier seems to have provoked a proper upgrade of the installation.

For some reason, the old behavior of the Units package no longer persists after I did what I described. Convert[ ] no longer is recognized as a function, but UnitConvert[ ] now is. So I think that the automatic(?) upload from the Wolfram site, triggered by the restart after addition to the init.m file, updated the program properly.

I'm glad you noticed that it wasn't my doing.

I did try adding Needs["Units"] to the startup file, and what happened when I restarted MMA is that a fair bit of code was imported from the Wolfram site. Now everything seems to work properly. It seems that the initial setup was missing a component (perhaps the Units package itself), and that was detected and remedied automatically, without the intervention of a Wolfram employee. when I added Needs["Units`"].

But note that, as I mention above, the Needs["Units`"] causes an outdated component to be used instead of the new updated and expanded version for interpreting units that is now contained within Mathematica's default codebase. So as I mentioned above, you should remove that from the init.m file. If then, upon restarting Mathematica, you still have the same problem, I would suggest that you contact Wolfram support for advice on resolving this issue.

POSTED BY: David Reiss
POSTED BY: David Reiss

It is not clear why you are trying to use things in the

QuantityUnits`Private` 

context like

QuantityUnits`Private`ToQuantity

That is certainly not the correct way to proceed--almost always avoid using undocumented functions and always avoid using anything in a Private context. For your particular example the correct syntax is

UnitConvert[Quantity[12, ("Meters")/("Seconds")], ("Miles")/("Hours")]

And I would suggest removing Needs["Units`"] from the initi.m file as it will load a legacy pacage that was superceeded by internal Mathematica functionality as of version 9. See

http://reference.wolfram.com/language/Compatibility/tutorial/Units.html

POSTED BY: David Reiss

I don't know the reason why it does not work by default. The code you posted works fine for my Mathematica. However if you'd like to work it around, editing the init.m file in C:\ProgramData\Mathematica\Kernel should do the trick. Simply add

Needs["Units`"]

at the end of the file.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract