Skip to content

Add base units to some quantities (first steps) #601

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

Merged
merged 29 commits into from
Mar 1, 2019

Conversation

tmilnthorp
Copy link
Collaborator

@tmilnthorp tmilnthorp commented Feb 4, 2019

UnitSystem constructors (#547)

@tmilnthorp
Copy link
Collaborator Author

And no, it doesn't work on WRC 😄 I did it quick. Have to pull code and do locally without WRC to see it.

@angularsen
Copy link
Owner

Probably a good idea to merge in #607 first.

@tmilnthorp
Copy link
Collaborator Author

More of a proof of concept. Not ready to merge :)

@angularsen angularsen changed the title Adding base units to all base quantities, and base units for area as … Adding base units to all base quantities (WIP) Feb 15, 2019
Merge master into GenericMultiply
Regen after WRC split
Cleanup
Add test for SI unit system constructor for Area
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

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

I just took a fresh look at this, been a while since last time. I now finally get how it's supposed to work when specifying say Feet as default Length unit in a UnitSystem. Nice!
From what I can tell, the major things missing is prefix units and derived units/quantities, is there a complication with derived units or is it simply a matter of adding JSON definitions?

@tmilnthorp
Copy link
Collaborator Author

I can't reply directly to your comments so here we go:

  • DefaultUnit would probably be a better name!
  • The only derived unit is area right now. The others just need adding!
  • Yes it is quite verbose. I should
    • Skip adding any BaseUnits if they're all undefined (make it null)
    • Use the default values or object initializers to skip the undefined base units.
  • We can add something for imperial units, but what I'm not sure. I'm open to suggestions. There's so real imperial system in the sense of default units. Even restricting it to the US customary units has inches, feet, yards, and miles for length! No standard like SI.

@angularsen angularsen mentioned this pull request Feb 25, 2019
Regen
Doc fix
Renaming method to ExistsIn and simplifying. Adding test.
Only use arguments that are not undefined for BaseUnits in UnitInfo.
Showing example BaseUnits for Joule (energy)
Adding BaseUnits for Acceleration units
@tmilnthorp tmilnthorp changed the title Adding base units to all base quantities (WIP) Adding some base units to quantities (WIP) Feb 26, 2019
@tmilnthorp
Copy link
Collaborator Author

tmilnthorp commented Feb 26, 2019

I'm actually pretty happy with this now if you'd like to take a look! Not all of them are there, but we can work on adding derived quantity base units as we wish. There's a lot... 😄

Add null check and add tests for GetBaseUnit
Add null test
Null tests for UnitSystem/BaseUnits constructor
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

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

Phew, this is a lot to take in. I don't think I grok all of it yet, especially the ExistsIn() logic and how it is used, but I'll let you go through my second impression comments first before I read it again.

PR suggestions
PR suggestions
PR suggestions
Rename IsSubsetOf
@tmilnthorp tmilnthorp changed the title Adding some base units to quantities (WIP) Adding base units to some quantities (first steps) Feb 28, 2019
Rename IsSubsetOf
Split tests
Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

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

A few more things and this should be ready to go!

Only expose quantity constructor for UnitSystem. Move getting of unit for base units to QuantityInfo (easier when working with generic types or static info).
@tmilnthorp
Copy link
Collaborator Author

I will add more tests for QuantityInfo.GetUnitInfoForBaseUnitsSubset before merging

Copy link
Owner

@angularsen angularsen left a comment

Choose a reason for hiding this comment

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

You might be in the middle of something here, but here are some comments regardless.

@tmilnthorp
Copy link
Collaborator Author

Ok, I think I got through it all! 🎉

}

[Fact]
public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperationException()
Copy link
Owner

Choose a reason for hiding this comment

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

Good test!

@angularsen
Copy link
Owner

I think so too :-) Looks good to me, great job on this one too!

@angularsen angularsen merged commit 7ae21c6 into angularsen:master Mar 1, 2019
@angularsen angularsen changed the title Adding base units to some quantities (first steps) Add base units to some quantities (first steps) Mar 1, 2019
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.

2 participants