@@ -64,65 +64,75 @@ def test(self, expr) -> bool:
6464
6565class Quantity (Builtin ):
6666 """
67- <url>
68- :WMA link:
69- https://reference.wolfram.com/language/ref/Quantity.html</url>
67+ <url>
68+ :WMA link:
69+ https://reference.wolfram.com/language/ref/Quantity.html</url>
7070
71- <dl>
72- <dt>'Quantity'[$magnitude$, $unit$]
73- <dd>represents a quantity with size $magnitude$ and unit specified by $unit$.
71+ <dl>
72+ <dt>'Quantity'[$magnitude$, $unit$]
73+ <dd>represents a quantity with size $magnitude$ and unit specified by $unit$.
7474
75- <dt>'Quantity'[$unit$]
76- <dd>assumes the magnitude of the specified $unit$ to be 1.
77- </dl>
75+ <dt>'Quantity'[$unit$]
76+ <dd>assumes the magnitude of the specified $unit$ to be 1.
77+ </dl>
7878
79- >> Quantity["Kilogram"]
80- = 1 kilogram
79+ >> Quantity["Kilogram"]
80+ = 1 kilogram
8181
82- >> Quantity[10, "Meters"]
83- = 10 meter
82+ >> Quantity[10, "Meters"]
83+ = 10 meter
8484
85- If the first argument is an array, then the unit is distributed on each element
86- >> Quantity[{10, 20}, "Meters"]
87- = {10 meter, 20 meter}
85+ If the first argument is an array, then the unit is distributed on each element
86+ >> Quantity[{10, 20}, "Meters"]
87+ = {10 meter, 20 meter}
8888
89- If the second argument is a number, then the expression is evaluated to
90- the product of the magnitude and that number
91- >> Quantity[2, 3/2]
92- = 3
89+ If the second argument is a number, then the expression is evaluated to
90+ the product of the magnitude and that number
91+ >> Quantity[2, 3/2]
92+ = 3
9393
94- Notice that units are specified as Strings. If the unit is not a Symbol or a Number,
95- the expression is not interpreted as a Quantity object:
94+ Notice that units are specified as Strings. If the unit is not a Symbol or a Number,
95+ the expression is not interpreted as a Quantity object:
9696
97- >> QuantityQ[Quantity[2, Second]]
98- : Unable to interpret unit specification Second.
99- = False
97+ >> QuantityQ[Quantity[2, Second]]
98+ : Unable to interpret unit specification Second.
99+ = False
100100
101- Quantities can be multiplied and raised to integer powers:
102- >> Quantity[3, "centimeter"] / Quantity[2, "second"]^2
103- = 3 / 4 centimeter / second ^ 2
101+ Quantities can be multiplied and raised to integer powers:
102+ >> Quantity[3, "centimeter"] / Quantity[2, "second"]^2
103+ = 3 / 4 centimeter / second ^ 2
104104
105- ## TODO: Allow to simplify producs:
106- ## >> Quantity[3, "centimeter"] Quantity[2, "meter"]
107- ## = 600 centimeter ^ 2
105+ ## TODO: Allow to simplify producs:
106+ ## >> Quantity[3, "centimeter"] Quantity[2, "meter"]
107+ ## = 600 centimeter ^ 2
108108
109- Quantities of the same kind can be added:
110- >> Quantity[6, "meter"] + Quantity[3, "centimeter"]
111- = 603 centimeter
109+ Quantities of the same kind can be added:
110+ >> Quantity[6, "meter"] + Quantity[3, "centimeter"]
111+ = 603 centimeter
112112
113113
114- Quantities of different kind can not:
115- >> Quantity[6, "meter"] + Quantity[3, "second"]
116- : second and meter are incompatible units.
117- = 3 second + 6 meter
114+ Quantities of different kind can not:
115+ >> Quantity[6, "meter"] + Quantity[3, "second"]
116+ : second and meter are incompatible units.
117+ = 3 second + 6 meter
118+
119+ ## TODO: Implement quantities with composed units:
120+ ## >> UnitConvert[Quantity[2, "Ampere" * "Second"], "Coulomb"]
121+ ## = Quantity[2, Coulomb]
122+
123+ See also <url>
124+ :'QuantityQ':
125+ /doc/reference-of-built-in-symbols/units-and-quantities
126+ /quantityq/</url>.
118127
119- ## TODO: Implement quantities with composed units:
120- ## >> UnitConvert[Quantity[2, "Ampere" * "Second"], "Coulomb"]
121- ## = Quantity[2, Coulomb]
122128 """
123129
124130 attributes = A_HOLD_REST | A_N_HOLD_REST | A_PROTECTED | A_READ_PROTECTED
125131
132+ # Set checking that the number of arguments.
133+ eval_error = Builtin .generic_argument_error
134+ expected_args = 1 # In 14.1 this is (1, 2)
135+
126136 messages = {
127137 "unkunit" : "Unable to interpret unit specification `1`." ,
128138 "compat" : "`1` and `2` are incompatible units." ,
@@ -299,22 +309,27 @@ def eval_quantity_unit(self, quantity, targetUnit, evaluation: Evaluation):
299309
300310class QuantityQ (Test ):
301311 """
302- <url>
303- :WMA link:
304- https://reference.wolfram.com/language/ref/QuantityQ.html</url>
305- <dl>
306- <dt>'QuantityQ'[$expr$]
307- <dd>return True if $expr$ is a valid Association object, and False otherwise.
308- </dl>
309-
310- >> QuantityQ[Quantity[3, "Meters"]]
311- = True
312-
313- >> QuantityQ[Quantity[3, "Maters"]]
314- : Unable to interpret unit specification Maters.
315- = False
312+ <url>
313+ :WMA link:
314+ https://reference.wolfram.com/language/ref/QuantityQ.html</url>
315+ <dl>
316+ <dt>'QuantityQ'[$expr$]
317+ <dd>return 'True' if $expr$ is a valid <url>:'Quantity':/doc/reference-of-built-in-symbols/units-and-quantities
318+ /quantity/</url> with valid arguments, and 'False' otherwise.
319+ </dl>
320+
321+ >> QuantityQ[Quantity[3, "Meters"]]
322+ = True
323+
324+ >> QuantityQ[Quantity[3, "Maters"]]
325+ : Unable to interpret unit specification Maters.
326+ = False
316327 """
317328
329+ # Set checking that the number of arguments required is one.
330+ eval_error = Builtin .generic_argument_error
331+ expected_args = 1
332+
318333 summary_text = "tests whether its the argument is a quantity"
319334
320335 def test (self , expr ) -> bool :
0 commit comments