Message Boards Message Boards

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

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

I'm a new user of MMA ver. 10.3.0 Home Edition. I'm trying to learn how to use Units, but it's not working. For example

In[47]:= UnitConvert[Quantity[12, "Meters"/"Seconds"], "Miles"/"Hours"]

Out[47]= UnitConvert[
 QuantityUnits`Private`ToQuantity[
  QuantityUnits`Private`UnknownQuantity[12, ("Meters")/(
   "Seconds")]], ("Miles")/("Hours")]

If I load the Units` package I get the answer I seek:

In[48]:= << Units`

Convert[12  Meter/Second, Mile/Hour]

Out[49]= (37500 Mile)/(1397 Hour)

But starting with ver 9 I shouldn't have had to do that. Any ideas about what's going on?

14 Replies

I often see this problem where units stop working but I have not been able to produce a sequence of commands to reproduce it. However, I have found this commands fixes the issue:

<<QuantityUnitsLoader`

This does not prevent the issue from hapening again in the future but at least fixes it when it happens.

POSTED BY: Gustavo Delfino
Posted 9 years ago

Hi. It sounds like your version is working. What I had to do for the Mac, and it appears to work, was the following...

Get["EntityFramework`"]

However, entering that command now doesn't seem to do anything for me at the moment. Perhaps it is because it's working. Perhaps when it was broken/missing, it triggered a refresh. I don't know.

Then, when I entered the following, it rebuilt the data interface.

EntityValue[]

Support told me they are aware of the issue, at least for the Mac. I'm not sure of Windows versions.

POSTED BY: Dana DeLouis

Thanks, that's helpful. I've got the Units stuff working OK now, but I was playing around with sounds (Play, EmitSound, etc.) and had to quit and restart MMA before it would actually make noise. At one point in the process, just as with Units, it appeared that something was being loaded from the Wolfram site. On the other hand, the few Entity things that I've tried from the Help examples (e.g., Entity["Mythology"]["Properties"]) have worked OK.

How do you reset Paclet data? Via PacletUpdate, or ...?

Posted 9 years ago
POSTED BY: Dana DeLouis
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.

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

Actually I see now that you were getting as a result the Private context expression -- my mistake. ;-)

My comment about not using the Needs["Units`"] package still holds, but there is something wrong with your setup which a bona fide Wolfram employee may comment on. One thing to try is to execute

RebuildPacletData[] 

as well as restart Mathematica.

Sorry for the confusion!

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

That seems to have done the trick. Thanks.

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