View Source Measurements

Measurements is a library for computation of physical quantities (time, distances, etc.) in Elixir.

A quantity is represented by a struct with a value, a unit and a positive error.

Error is propagated through calculations, and unit prevent collision of unrelated quantities. Automatic conversion of unit (in scale) is supported.

Conversion of unit, across dimension, could ultimately be supported. But is a very large endaevour and the package API is not stable enough just yet.

See https://en.wikipedia.org/wiki/Dimensional_analysis as reference.

Dimensions supported:

  • [X] Time (T)
  • [X] Length (L)
  • [ ] Mass (M)
  • [ ] Electric Current (I)
  • [ ] Absolute Temperature (Θ)
  • [ ] Amount of Substance (N)
  • [ ] Luminous Intensity (J)

installation

Installation

If available in Hex, the package can be installed by adding measurements to your list of dependencies in mix.exs:

def deps do
  [
    {:measurements, "~> 0.1.2"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/measurements.

testing-in-iex

Testing in Iex

$ mix test --trace

Or for a more interactive approach:

$ iex -S mix

testing-in-livebook

Testing in Livebook

Install livebook as an escript and start it:

livebook server

From there you can open DEMO.livemd to see measurements in action, and try it for yourself !

how-to-develop

How to develop

Optionally, setup direnv with asdf. This will allow to work with another elixir version than your system's one.

Then:

Want to change something ?