Closed dhilsen closed 6 months ago
I don't know if there has actually been a unit called lb
in the system. But now the system is much more careful about what things are units.
The system expects that it would be defined here.
Or alternatively in the security-map.json
, but that would not be the correct route for units. Maybe Chris will add it, are there any others that would not conflict with SI-units too much.
Thanks Matti, the English unit lb
may have never been in the system. Is there a method by which a unit can be locally defined within a question?
David, Sorry about this. I'm almost certain this is a side effect of the "better" parser, so I've added in this unit. Please let me know what else you need (even though adding imperial units gives me some pain....). I'll also be in touch re. issue #401.
No, there is no mechanism for local units currently.
Thanks Chris. We generally use imperial units for unit conversion questions, unfortunately many people in the United States still think in terms of these units.
It would also be helpful to add in the distance unit yard yd
I'll add in yards. What about rods, poles and perches? ;-)
Thank you for adding yards. Thankfully we have not gone so far as to use rods, poles and perches!
Furlongs and some others for those of us that play with the FFF-system. Naturally, once we figure out the way for customising units and declaring the system one wants to use we do have quite a few systems to support. Subsystems that might be used in specific fields...
Chris, I went through a fairly exhaustive list of units along with testing of existing units:
1) Please add the unit for horsepower: hp
2) The unit Btu
is defined in STACK, however, an error message is generated when it's used.
3) The unit Cal
is defined in STACK, however, it also generates an error message. It appears that 3 letter unit names with the first letter uppercase causes the error.
4) The compound unit kilowatt-hour kWh
generates an error message.
I've add in hp
but not given it a conversion factor, as there are a variety of options: https://en.wikipedia.org/wiki/Horsepower#:~:text=Horsepower%20(hp)%20is%20a%20unit,standards%20and%20types%20of%20horsepower.
Sorry about Btu
, Cal
(and mmHg
) which I've fixed.
Matti, how should we deal with kWh
in the new parser context?
Well, kWh
is a bit of a problem. Primarily due to the way it behaves with the single-char vars now:
kWh
=> kW*h
, but as Maxima orders the terms around => h*kW
makes much less sense.It is not the parser that needs to care about this. Unless you want to repeat the old days of kgs
handling, which is now something that only happens when you use the single-char vars logic and is otherwise left as an error. Personally, I would not want to see that kind of logic coming back.
What I would recommend is to define a new base-level "SI" unit Wh
(just like VA
) so that the prefix system can handle the other cases as well, kWh
is a pretty inconvenient size when your phone battery tends to talk about mWh
or when your industrial-plants eat MWh
and GWh
sized values. The conversion logic can then turn the starred or starless values to same.
But for those that know where to place stars that first problem kW*h
=> h*kW
would need to be handled and to do that some logic needs to turn simp:false
or do the processing very carefully indeed. And I think it is the stackunits_make()
which leads to this, that seems a bit too complex to deal with. Would almost be simpler to do the stackunits_make()
(in an AST-filter) on the PHP-side in the Units-input.
Chris, related to the recent issue with MCQ, do check how the input validation with units works if question-variables leaks simp:false
, maybe the input validation should ensure that it has the correct simplification to function.
I'm tidying up issues. If anyone anywhere is still inching towards complete adoption of metric units, and wants additional units in STACK, please open a new issue!
In STACK 4.3.3 the unit
lb
does not appear to be recognized for units input-type questions. The error message states "Your answer must have units, and you must use multiplication to attach the units to a value", even though the unit is indeed being entered as*lb
. Thelb
unit was supported in previous versions of STACK, perhaps it was inadvertently removed?