Skip to content

Fix builder metadata copies and Number power checks - #101

Merged
suleman-uzair merged 2 commits into
mainfrom
fix/compose-builder-gaps
Nov 5, 2026
Merged

suleman-uzair merged 2 commits into
mainfrom
fix/compose-builder-gaps

Conversation

@suleman-uzair

Copy link
Copy Markdown
Member

This PR fixes three gaps in the composite unit builder and corrects the README where it described behaviour the code does not have.

Changes

  • #name, #quantity_reference and #multiplier return a deep copy, so changing the result no longer changes the original formula.
  • Unit.new, Dimension.new and power_numerator= reject a Unitsml::Number power that does not hold a number (e.g. Number.new("abc")), including inside a Fenced.
  • Dividing by a unit with power 0 keeps the power at 0 instead of writing -0.
  • README: composing further drops metadata, an unknown quantity: leaves out <Quantity>, norm_text writes a square root as its exponent, and a dimension quantity is built with Unitsml.compose(dimensions:).

suleman-uzair added 2 commits November 5, 2026 16:36
Fluent #name, #quantity_reference and #multiplier now return a deep copy,
so changing the result no longer changes the original formula.

Unit.new, Dimension.new and the power_numerator setter reject a Number
(or fenced Number) power that does not hold a number, instead of
rendering it as m^abc and emitting a broken unit id.

Dividing by a unit with power 0 keeps the power at 0 rather than
writing -0.
State that composing further drops metadata (parsed comma metadata
too), that an unknown quantity: is skipped rather than raised, that
norm_text writes a square root as its exponent, and how to build a
dimension quantity.
@suleman-uzair
suleman-uzair marked this pull request as ready for review November 5, 2026 12:45
@suleman-uzair
suleman-uzair merged commit 7b99eed into main Nov 5, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant