-
Notifications
You must be signed in to change notification settings - Fork 95
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
Clarify concepts and casting rules of quantity kinds and types #567
Comments
@burnpanck, it is great to hear that you are moving to V2. Unfortunately, it is hard for me to understand your use case without a concrete code example, so maybe you could provide a simplified example in the Compiler Explorer? Also, maybe this example will help you: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2024/p3045r0.html#user-defined-quantities-and-units. |
Regarding Hz, here is the rationale for constraining it to frequency: Although, indeed, "periodic phenomena" might not necessarily imply frequency. However, there is no "periodic phenomena" quantity type in ISQ. |
I'm fine with the current choice and rationale of constraining
As I write this however I notice the So ultimately, I think the library users would benefit from rigorous description of the concept of "kind". Can we now use a mental model of a hierarchy of quantity types? What does the |
@burnpanck, do you need any more support here, or can we close that one? |
I am good, thanks! |
I'm finally refactoring our production code to units v2. Unfortunately, I have lost track of the previous discussion over interconvertibility of quantity kinds. There were concepts "quantity kind" and "quantity type", and potential hierarchies of those, but I currently fail to understand to what rules the library has settled.
The specific case where I was wondering this was here: In our code, we mostly use untyped quantities, with the exception of two custom quantity types. One of them is an inverse duration (dimension T^-1). Our embedded system measures statistical properties of the separatioon of events happening repeatedly (not related to radionucleides), and so we invented a new quantity type for quantities related to the "frequency" of those events - as in the statistician's sense of frequency, not the one from the ISQ. However, now I'm struggling to properly cast the measured values based on a real ISQ frequency and a count to that custom quantity-type:
quantity_cast
refuses the cast becausehertz
is associated with a quantity-type of it's own, but not related to our own event "frequency" type. So basically it seems thatquantity_cast
currently prohibits "horizontal casts". Is this intended?I had declared that "frequency" type to be of inverse duration, rather than a refinement of frequency, because it seems that the library currently disallows restricting units to anything else than the "root of a kind-tree" (?). It is not entirely clear to me what that would be, or why there would be a need for such a restriction. If that restriction weren't there, then those casts would be "vertical".
The text was updated successfully, but these errors were encountered: