atmoos / quantities Goto Github PK
View Code? Open in Web Editor NEWLibrary that enables typesafe representation of quantities.
License: MIT License
Library that enables typesafe representation of quantities.
License: MIT License
Bump the core project Atmoos.Quantities
to .Net 8
Each quantity should implement:
These two interfaces would be required to truly allow for generic algorithm implementations using the Quantities library.
The values would be 1
for the multiplicative identity and 0
for the additive identity, each using the corresponding SI unit.
We had inconsistent creation behaviour of quantities:
Goal: Find a way to consistently create all quantities without allocations.
Please explain the relation between:
Update the core project Atmoos.Quantities
to .Net 8.
Currently there is a reasonably well defined .editorconfig in place. It's not consistently followed.
A dotnet format
is in order with some manual cleaning up here and there.
Add logo to repo and include in nuget packaging.
Currently, if I want to create say one meter, I always need to write: Length.Of(1, Si<Metre>())
.
This is semantically clean but a tad verbose. Hence create two convenience libraries
that would expose types that'd enable the following syntax:
Length oneMetre = 1 * m;
Velocity oneKpH = 1 * km/h;
// similary,
var oneSecond = 1 * s;
var threeOhm = 3 * Ω;
Add a Normalise(): String
method.
Scenario: Say you have a length instance of 78'167 μm
. This is an unwieldy representation for humans to read. More natural forms of the same length would be 78.167 mm
or 7.817 cm
, where the latter value has been rounded.
Tasks:
Note also the example in the readme: 3'456 Km/d => 40 m/s
Converting Knots to Kilometres per Hour results in catastrophic loss of precision. This must be fixed.
Release version 1.0 of the Quantities.Serialization.Newtonsoft library.
The ScalarBuilder used for serialization has quite a bit of copy paste code that is used together with reflection.
Find a better way to create and invoke the generic methods needed to create (inject) the scalar measures.
The concrete quantity structs would ideally not have any dependencies to any concrete units, only to unit interfaces.
I have no clue how to accomplish as this collides square on with #6 . Possibly a very interesting design problem to work on.
Each value should be able to be serialized and de-serialized.
Implementation properties:
24.23 feet
must retain it's representation of feetSome concepts are non-intuitive. Add How-To or best practices for following topic:
FooLengthPerBarTime
velocity unitFooLength
length unit and a BarTime
time unit, then use "Per" method to combine themRelease version 1.0 of the Quantities.Units library.
As I've started other projects in the Atmoos namespace, it's prudent to include the quantities too.
Release version 1.0 of the Quantities.Serialization.Text.Json library.
Enable continuos deployment to nuget on every merge to master/main.
We should strive for coverage >= 90%.
Release version 1.0 of the Quantities library.
Implement remaining overloads:
Celsius currently implements IMetric
, even though it is formally an si-derived unit. As it requires a transformation, we cannot implement it as an ISiUnit
and ISiDerivedUnit
has been deleted. This poses a dilemma: formally it is an si-derived unit, that currently "needs" to be implemented a metric unit.
Find a way to resolve this:
ISiDerivedUnit
.Since the introduction of generalised transformations for all units, we see a loss of precision for units involving some offset. This is likely due to cancellation during addition/subtraction. The most striking examples can be found in the TemperatureTest.
We have the ability to control cancellation and should find a way to deal with it.
Some options:
The file Measures.cs contains way too many measure implementations.
This concept needs to be revisited.
Currently a pair of methods have to be implemented on every implementation of a unit:
ToSi(in Double self)
FromSi(in Double value)
By definition FromSi
must be the inverse of ToSi
, rendering the former theoretically redundant.
Mathematically:
Idea: Make use of this and only require units to declare the ToSi
method, then let "Quantities" figure out the inverse itself.
Rationale:
Separate out the singular test project into two:
Quantities.Test
Quantities
library.Quantities.Units.Test
Quantities.Units
library.This is to ensure clean separation of concerns and also dependencies. It is also a precursor to #77 .
Serialization is broken for inverted quantities. As an elegant solution, we should change the format of non-compound quantities to something resembling:
{
"length": {
"value": 4.2,
"exponent": 1,
"si": {
"unit": "m"
}
}
}
The key being the added exponent
, which simplifies both power measures (m³, etc.) but also inverse measures.
There are a couple of Units and Quantities that are each other's inverse. Examples include:
Frequency
Time
Conductance
Resistance
In order to represent these relations consistently, the notion of inversion of units and measures is required.
The benchmark exporter crashes when run on a windows machine.
The culprit is an open file handle that prevents a temporary file being moved into the position of the file it should be overwriting.
Bumps all projects dependent on Atmoos.Quantities
to .Net8.0. These are:
Atmoos.Quantities.Units
Atmoos.Quantities.Serialization.Text.Json
Atmoos.Quantities.Serialization.Newtonsoft
Find better naming:
Repro:
Length nauticalMiles = Velocity.Of(4, NonStandard<Knot>()) * Time.Of(3, Si<Second>()); // 12 kn
Should be 12 nm (nautical miles)!
Add generation of the coverage report in the github action that runs the unit tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.