Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias units in contextUnits.pl #1193

Open
pstaabp opened this issue Feb 12, 2025 · 1 comment · Fixed by #1194
Open

Alias units in contextUnits.pl #1193

pstaabp opened this issue Feb 12, 2025 · 1 comment · Fixed by #1194

Comments

@pstaabp
Copy link
Member

pstaabp commented Feb 12, 2025

Writing some new problems using the new context Units and have a possible bug with plurals (aliases). Here's an MWE:

DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'contextUnits.pl');

Context('Units')->withUnitsFor('volume');

$vol = Compute("100 ml");

BEGIN_PGML
Convert [$vol] to cups. [_]{$vol->toUnits('cups')->with(sameUnits =>1)}
END_PGML

ENDDOCUMENT();

Entering the correct answer "0.42267 cups" gives the right answer, but "0.42267 cup" does not give credit for the units. Is this intended?

@dpvc
Copy link
Member

dpvc commented Feb 12, 2025

I've made a PR that should address the issue for you. Aliased units were not considered the same for sameUnits => 1, as you have pointed out, but they should be, and the PR should make that happen.

Thanks for the careful testing!

drgrice1 added a commit that referenced this issue Feb 25, 2025
Mark units that are aliases, and use alias string for uString comparisons so sameUnits will allow plurals, etc. (#1193)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants