Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When I evaluate this expression:

UnitConvert[Quantity[1920*1080, "Bytes"]*Quantity[24, "1/Seconds"] + 
     Quantity[44, "Kilohertz"]*Quantity[16, "Bits"], 
     Quantity["Megabytes"/"Seconds"]]

I get an error message:

UnitConvert::unkunit: Unable to interpret unit specification 1MB/s. >>

But the units should be compatible. FWIW, the old Units package has no problems with the equivalent:

Needs["Units`"]
Convert[1920*1080 Byte*24/Second + 44 Kilo Hertz*16 Bit, Mega Byte/Hour]

The only workaround I've found was to unit-convert the subexpressions myself:

UnitConvert[Quantity[1920*1080, "Bytes"]*Quantity[24, "1/Seconds"] + 
    UnitConvert[Quantity[44, "Kilohertz"], 1/"Seconds"]*
    UnitConvert[Quantity[16, "Bits"], "Bytes"], 
    Quantity["Megabytes"/"Seconds"]]

Is this a bug or am I using it wrong?

share|improve this question
1  
I get 31159/625 MB/s on 9.0 for Mac OS X x86 (64-bit) (November 20, 2012) –  rm -rf Nov 28 '12 at 21:25
    
UnitConvert[Quantity[89,"USCents"]/ Quantity[2,"Liters"],"USCents"/"FluidOunces"]//N gives: 1.31602per fluid ounce no "cents" per fluid ounce. This worked okay in the Units package prior to Mathematica 9 Also it converts 1 kilobytes to 1000 bytes (not 1024) –  user5353 Jan 10 '13 at 18:57
    
@Doug: I agree that that's probably a bug, but I'm not sure anyone from Wolfram Research will read about it here in a comment. You could ask in a new question if there's a workaround and you could mail the problem to Wolfram support directly. –  nikie Jan 11 '13 at 7:53
    
@Doug, it uses kilo and his family as standard 1000^something. Use "Kibibytes", mebi, etc –  Rojo May 12 '13 at 15:27
add comment

1 Answer

up vote 12 down vote accepted

That code should work and it does work on my machine. The problem could be the following. You have only one part that requires Wolfram|Alpha interpretation:

Quantity[24, "1/Seconds"]

It is not built in unit - so it goes to Wolfram|Alpha for interpretation (how cool is that? ;-) ). This works almost always - unless something is wrong with internet connection, or there is some sort of latency problem. It works for me at least. Now if you want this to be evaluated without rerouting to Wolfram|Alpha, use

Quantity[24, 1/"Seconds"]

with "Seconds" of course built in. Now try this whole thing - should work:

UnitConvert[
  Quantity[1920*1080, "Bytes"]*
  Quantity[24, 1/"Seconds"] +
  Quantity[44, "Kilohertz"]*
  Quantity[16, "Bits"],
  Quantity["Megabytes"/"Seconds"]]

Quantity[31159/625, ("Megabytes")/("Seconds")]

share|improve this answer
    
You're right. I've restarted the Kernel and now I get the expected result. Should I delete or close the question? –  nikie Nov 28 '12 at 21:45
3  
@nikie I think you should keep this - Wolfram|Alpha references and network latency - something that can happen to anyone and is useful to know. –  Vitaliy Kaurov Nov 28 '12 at 21:50
5  
Definitely don't delete. That's an interesting gotcha, well worth having a post about it on MSE. –  Daniel Lichtblau Nov 28 '12 at 22:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.