-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add more quantity types #6
Comments
@ianmackenzie Thanks for the call out... I've set aside some days this month to contribute to hacktoberfest. Not wishing to double up efforts with others - shall I have a go at Volume for starters? I think my maths will cope. |
@katjam Sure, sounds good, and thanks for checking first! Off the top of my head for volume units I'd suggest including (along with
Gotta love crazy non-metric units! In general I've tried to make all conversion constants in the It would be kinda nice to also include cooking units like teaspoons, tablespoons and cups, but those seem to vary wildly between countries without even standard names for the different versions, so I'd say leave them out. |
Perfect. I'm getting Errors regarding comparable type in Quantity module when I try to compile. Is that expected? e.g.
Yes - cooking units do seem to vary - maybe could identify differences by country code but I'll leave for now. |
That's interesting, I don't get that compile error myself (even if I explicitly call |
Oops! I'll upgrade. :) |
Huh, I always thought one teaspoon was 5ml and a tablespoon was 15ml. A quick wikipedia search tells me that:
😰 😰 😰 |
I'm kind of surprised it even started compiling in 0.18 (hence my skepticism that that was the issue), given that there's no |
@JoelQ yeah, that's the Wikipedia page I was looking at when I basically threw my hands up and said "forget it". Fortunately it would be easy enough for someone else to create separate |
If there is one thing I have learned when making this package, it is that anything other than an SI unit is very likely to have multiple slightly-different versions in common, modern use. Tablespoons, gallons, horsepower, tons... |
I made a little project that includes Yeah units are nuts. I guess cultures like to define their own standards. |
Ahhh OK, that makes sense - so you were just including |
I had a quick google before I asked you too - because I thought maybe it was an 0.18 to 0.19 thing - but nada. Anyway - all good now. Nearing supper time for me - but hopefully have something up tomorrow. I've taken scattered days off work this month so may be fits and starts. |
No rush! I may very well end up releasing 1.0 with just the existing modules (I was planning on an initial release this week), but it was always the plan to steadily add more modules in minor releases post-1.0. So if you finish in a week or two there's no reason we couldn't immediately publish a 1.1. |
Sounds good. 👍 |
Going to have trouble remembering to spell |
Hahaha fair point! I'm Canadian myself, and I do realize that 'metres' is the standard SI spelling of the unit. But it seems that American spelling (color etc.) is the de facto standard in programming, so I decided a long time ago to follow that for all my programming projects. It helps that American spellings tend to be a bit simpler (color vs colour) and more phonetic (meters vs metres), so it feels like an objectively reasonable choice and not just surrendering to the majority. |
It heartens me to find out that the American spellings were due to a considered, deliberate effort to make spelling simpler and more regular: https://www.businessinsider.com/spelling-american-vs-british-noah-webster-2018-3 I think as programmers we can all appreciate a nice simplifying refactor! |
Am I on the right track? Added cubed and cbrt to Quantity though not sure if you think it's helpful since not supported by Basics |
Looking pretty good! I have a few small thoughts/comments/questions but I think it would make sense to just open a pull request and we can discuss there - it's totally fine to open a pull request with partial work, you can keep pushing to your branch and those changes will show up in the pull request. But that way we can have a discussion there (and I can in fact go in and make small changes to your branch myself) without adding too many more comments to this issue. |
Do you have a next priority in mind for the others? I'm happy to tackle any - once #9 goes in. |
Awesome! I think I'm personally most excited about the photometric units (I'm working on a 3D rendering package and I'd love to be able to specify lights in physical units like |
I'll go for |
Sounds good! I'm a bit conflicted on naming there - |
I'll stick up a stub PR in a bit so we can continue the conversation there. |
Philosophically - I prefer revolutions to (taking) turns... |
I'll go for |
Sounds good! I think for |
#6 Add angular acceleration module
No promises on how fast I'll get to it, but I still have some time to take off work between now and Christmas... what's the next priority? |
I'd be inclined to look at #10 and/or #19 next...either immediately start in on refactoring to use a
Thanks so much for all your continued contributions! |
Thanks for letting me help. It's nice to have a project outside of work & personal to focus on. I guess it makes sense to do #19 with existing and then tidy it up with #10 if we need to alter anything? I'll let you know before I start - making an initial WIP PR so we don't double up. Until I do - which should be within the next couple of weeks, you can assume I've done nothing. |
Sounds good! I'll probably be focusing on |
@ianmackenzie - are |
Hi @lenards yes, certainly! And I'm not aware of anyone else working on them if you want to start a PR =) |
@lenards @ianmackenzie It's probably also a good time for me do some more stuff. Let me know where I can be most useful. |
I'll take a crack at |
I'll go for |
Thanks both! And yes it will be great to be able to close this one =) |
I will post a _provisional_ pull request of what I have for `Molarity`. I
did review of what NIST has for SI units (I'll link later), but it seems
like there might not be Imperial units for that module. And, beyond
"decimoles per cubic decimeter", for equivalence to _liters_, it seems like
it's just the constructor and `in*` function. So I have to be missing
something.
…On Mon, Oct 7, 2019 at 8:08 AM Ian Mackenzie ***@***.***> wrote:
Thanks both! And yes it will be great to be able to close this one =)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#6?email_source=notifications&email_token=AAABOI7UQSLMHRMMRZA63SDQNNGHDA5CNFSM4FXPRPOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAQWASA#issuecomment-539058248>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAABOI4UYYPTYI4M46WQXXDQNNGHDANCNFSM4FXPRPOA>
.
|
Is it ok if I take VolumetricFlow? That one looks unclaimed. It would be a great way for me to get into some Elm! |
@jamessral please do! I'll update the issue. @lenards you may not be missing anything - it's entirely possible that there really are only one or two common ways of specifying molarity, I haven't really looked into it myself. If you want to open a PR with the basic constructor and |
I'm progressing on |
See ianmackenzie#6. An SI unit, mole per cubic meter (mol/m3), `Molarity` is an amount of substance divided by the volume of the mixture. Values stored in number of mole per cubic meter. All `*PerLiter` definitions are defined in terms of `decimolesPerLiter`. Why? This was done because a liter equal to a cubic decimeter, and `mole per cubic meter` is a `Rate`. This may make the various `*PerLiter` definition appear off by a factor of 10 because the definitions are in terms of decimoles per cubic decimeter (same as `decimolesPerLiter`).
Defined missing centimoles & decimoles in SubstanceAmount module. Include in commit tests for fuzzing these and equal pair comparisons. See also ianmackenzie#6
See ianmackenzie#6. An SI unit, mole per cubic meter (mol/m3), `Molarity` is an amount of substance divided by the volume of the mixture. Values stored in number of mole per cubic meter. All `*PerLiter` definitions are defined in terms of `decimolesPerLiter`. Why? This was done because a liter equal to a cubic decimeter, and `mole per cubic meter` is a `Rate`. This may make the various `*PerLiter` definition appear off by a factor of 10 because the definitions are in terms of decimoles per cubic decimeter (same as `decimolesPerLiter`).
Defined missing centimoles & decimoles in SubstanceAmount module. Include in commit tests for fuzzing these and equal pair comparisons. See also ianmackenzie#6
@ianmackenzie Finally made some time to look at From my initial reading they are equally valid units - my simple understanding is that since Please don't feel the need to take time out to explain. I can read more if I need to - just wanted to know if you want me to reference the |
@katjam I think it's probably fine to leave out joules per radian for now (I think it's a different situation than angular speed - at least there everything is still conceptually "amount of rotation per unit time", just with different terminology). There's a broader question here about how to deal with different, equivalent forms of the same quantity type - see #32. |
Would it make sense to add hertz? I'm working on an audio package and hertz seems like an appropriate unit for describing the sample rate of a sound file. |
Interesting! What operations do you think you'd want to perform on a |
For me it would probably be used in In other words, for my use case I can just write ~10 lines of code and have everything I need. I figured it was worth bringing up though because Frequency/Hertz seems to be a commonly used unit and I was surprised to not see it included here. |
Would it work in your case to define something like type alias SamplesPerSecond =
Rate Samples Seconds
type alias SampleRate =
Quantity Float SamplesPerSecond ? Then I guess it just seems that in many cases (like this one) it makes sense to have a unit (like module Frequency exposing (Frequency)
type alias Frequency units =
Quantity Float (Rate units Seconds) but in a lot of ways it seems simpler just to treat it like a generic rate quantity. |
Yeah, that's what I meant by 10 lines. It's not that As you mention though, it seems like Frequency doesn't need to be a standalone quantity as it can be represented with |
Here's a list of modules that I'd like to add at some point - pull requests for any of these are welcome! (Take a look at existing modules for inspiration.) I've listed how I think each quantity's units should be defined, either as a base unit (
Moles
,Candelas
, etc.) or as a rate/product of other units (in which case the units type will be a type alias of the formRate x y
orProduct x y
). Note that there are some dependencies here - can't add theVolumetricFlow
modules without theVolume
module, orLuminousIntensity
withoutSolidAngle
!Kinematics/dynamics
AngularSpeed
(RadiansPerSecond = Rate Radians Seconds
) (thanks @katjam!)AngularAcceleration
(RadiansPerSecondSquared = Rate RadiansPerSecond Seconds
) (thanks @katjam!)Torque
(NewtonMeters = Product Newtons Meters
) (thanks @gampleman!)Volume
Volume
(Cubed Meters
) (thanks @katjam!)VolumetricFlow
(CubicMetersPerSecond = Rate CubicMeters Seconds
)Density
(KilogramsPerCubicMeter = Rate Kilograms CubicMeters
) (thanks @katjam!)SubstanceAmount
(Moles
) (thanks @ukarim!)Molarity
(MolesPerCubicMeter = Rate Moles CubicMeters
) (claimed by @lenards)Electromagnetism
Inductance
(Henries = Rate Volts (Rate Amperes Seconds)
) (thanks @ukarim!)Capacitance
(Farads = Rate Coulombs Volts
) (thanks @ukarim!)Photometry
SolidAngle
(Steradians
)LuminousFlux
(Lumens
)LuminousIntensity
(Candelas = Rate Lumens Steradians
)Illuminance
(Lux = Rate Lumens SquareMeters
)Luminance
(Nits = Rate Candelas SquareMeters
)The text was updated successfully, but these errors were encountered: