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

Flexible fullSimplify #35

Closed
wants to merge 1 commit into from
Closed

Conversation

abaco
Copy link
Contributor

@abaco abaco commented Sep 28, 2018

fullSimplify attempts to simplify the unit of a quantity, except degrees and radians. With this PR I've added fullSimplify', which takes an array of units the shouldn't be simplified.

I need this for percentages, which I defined as a "dimensionless" unit.

In the process I've also added steradian to the units that aren't simplified - is that fine or was it left out on purpose?

Copy link
Owner

@sharkdp sharkdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution. Looks good to me. I have added two inline-comments.

I'm curious: what do you use purescript-quantities for?

@@ -136,12 +137,16 @@ toStandard (num .*. du) =
case U.toStandardUnit du of
Tuple du' conversion → (conversion * num) ..* du'

-- | Attempt to simplify the unit of a quantity.
-- | Attempt to simplify the unit of a quantity, except angles.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be precise, the docstring should be something like:

Attempt to simplify the unit of a quantity. Quantities with units that be completely cancelled will be reduced to scalar values (except for angle-units)

.. and similar for the fullSimplify' function below.

fullSimplify = fullSimplify' [SI.degree, SI.radian, SI.steradian]

-- | Attempt to simplify the unit of a quantity, except the given units.
fullSimplify' ∷ Array DerivedUnit → Quantity → Quantity
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use this function, it should be exported(?)

@sharkdp
Copy link
Owner

sharkdp commented Oct 19, 2018

@abaco Ping on this

@sharkdp sharkdp closed this Oct 23, 2018
@sharkdp
Copy link
Owner

sharkdp commented Oct 23, 2018

Feel free to comment here if you want to pick this up again. Going to close this for now to clean up my open-PR list.

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.

None yet

2 participants