# Suppress connection to Wolfram|Alpha when making unit conversions

I want to speed up calculations with unit conversions. I suspect primarily that some units evaluate from Wolfram|Alpha. Any way to prevent this automatically, so that Mathematica throws errors/warnings instead of grabbing units from Wolfram|Alpha?

-
Set $AllowInternet to False? – R. M. Mar 6 '14 at 15:16 ## 4 Answers If you don't want Mathematica to use Wolfram | Alpha for correcting incorrect units, you can just set $AllowInternet = False. The downside of this is that it also blocks internet access for the curated data functions such as WeatherData, FinancialData, etc. You can also use Block to disallow internet only within your function.

-
this works, but could not get any speed up –  denfromufa Mar 6 '14 at 16:49
@denfromufa Well, you only asked about suppressing connection :) I doubt that you can speed up the Units functionality that easily... A lot of the slowdown has to do with the fact that the data with units is stored as unpacked arrays. Depending on your actual needs, you can avoid having to use any units (track them separately) and use efficient packed arrays for computations. –  R. M. Mar 6 '14 at 16:52
yep, removing units is the only option –  denfromufa Mar 6 '14 at 17:25

A properly formatted Quantity expression should work just fine, without trying to connect to WolframAlpha servers for conversion. For example,

Quantity[1, "Feet"] + Quantity[2, "Inches"]


should run with or without internet connectivity. In contrast,

Quantity[1, "Foot"] + Quantity[2, "Inches"]


will attempt to contact WA servers in an attempt to correct the malformed Quantity[1,"Foot"] expression.

-
yes, this my current solution, but not automated, since I have to go through each unit one by one to see if it is in offline unit set –  denfromufa Mar 6 '14 at 15:57

I have found it efficient to enter expressions with units using the "Inline free-form input", and then clicking the InputForm (the bottom line) to replace the entered text with a canonical input form. This gives me an easy-to-read notebook that computes without internet connectivity, at the expense of a mouse click when entering units, and a slight delay when moving away (with right-arrow) from the box.

The keyboard shortcut is Ctrl-= by default, I had to remap to Ctrl-+ to fit my Norwegian layout, by editing

\$InstallationDirectory\SystemFiles\FrontEnd\TextResources\Windows\MenuSetup.tr


as described here

-

I gave up trying to use Quantity and the units package in version 9 because of the drop in speed and the clumsy way of incorporating units that makes long expressions difficult to read. I have therefore stuck with Jon McLoone's package that works very well. It can found at http://blog.wolfram.com/2010/12/09/automatic-physical-units-in-mathematica/#comments

-
Please don't copy-paste the same answer repeatedly. You have already written that as an answer here, which is where it really belongs. –  R. M. Mar 12 '14 at 21:55
this package is not updated since 2012 according to the author: "This package is now largely obsolete as similar functionality is included in Mathematica 9. wolfram.com/mathematica/new-in-9/units It has also become incompatible with 9 due to a name conflict, though there is an easy fix: Open the file AutomaticUnits.m and do a search and replace on all occurrences of “CompatibleUnitQ” change it to a different word, I suggest “DimensionCompatibleUnitQ”. Replace the file with the modified version." –  denfromufa Mar 12 '14 at 22:56