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

Unit registries #6

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Unit registries #6

wants to merge 14 commits into from

Conversation

rgm
Copy link
Member

@rgm rgm commented Apr 21, 2020

Every one of our projects seems to require a slightly different set of units. A central concept in Pint is user-definable registries. Let's bring that in, and make the make-quantity fn take a unit registry as its first argument so that the validation, etc. can vary per project.

Proposed API:

(require '[opengb.dram.core :as dram])

(def unit-reg (-> (dram/make-unit-registry)
                  (dram/define-unit "air-change = [airflow] =  ac")
                  (dram/define-unit "[airtightness] = [airflow] / [time]")))

(def Q_ (partial dram/make-quantity unit-registry))

rgm added 14 commits April 20, 2020 23:42
We'll need this to cope with pint's unit definition syntax.
We'll want to be line-for-line compatible to maximize our ability to
stand on Pint's shoulders, here.
Make a naive implementation that is just enough to test the construction
of record-type quantities with a partial in a separate project.
Currently this has zero protection against unregistered units, or
implementation of arithmetic or conversion.

Going down a record-based implementation to experiment with getting the
faster dispatch (that ought to be possible) over the older vector-based
tuple implementation.
Seems we need to implement IEquiv as well for node + browser repl
For kilo, milli, etc. Following pint's definition convention.
Just rely on the clojure one.
Without this guard, clojurescript equality checks can blow up.
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