Prototype of dynamic units and measurements algebra #217
No reviewers
Labels
No Label
bug
dependencies
discussion
documentation
duplicate
feature
good first issue
misc
performance
question
test
use case
wontfix
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: kscience/kmath#217
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "commandertvis/units-poc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -0,0 +84,4 @@
}
public fun divide(a: Measure, b: Measure): Measure =
multiply(a, b.copy(chain = b.chain.mapValues { (_, v) -> -v }))
should
.copy
also updatemultiplier
to1 / multiplier
?@ -0,0 +8,4 @@
/**
* Represents base units of International System of Units.
*/
public enum class BaseUnits {
Enums are not very extensible, so if the library will lack some base units, users will no have a choice rather than wait for an update in the library. What about converting
BaseUnits
into an interface, so any library client will be able to define their own base units, like:@ -0,0 +225,4 @@
"The units are incompatible. The chains are ${a.measure.chain} and ${b.measure.chain}"
}
return a.copy(value = algebra { a.value * a.measure.multiplier + b.value * b.measure.multiplier })
I think code should convert
b.value
from scale used inb
to scale used ina
so it be something likea.value + b.value * b.measure.multiplier / a.measure.multiplier
?test cases:
(2 * gramm) + (0 * gramm)
should be equals to(2 * gramm)
@ -0,0 +215,4 @@
public fun <T> Algebra<T>.measurement(): MeasurementAlgebra<T> = MeasurementAlgebra(this)
public open class MeasurementSpace<T, out A>(public override val algebra: A) : MeasurementAlgebra<T>(algebra),
What do you think about adding function to converting measurement from one unit to another, e.g.:
@knok16 Thank you for commenting, I'll revise this branch after finishing with #402.
Pull request closed