Names to kotlin. Removed unnecessary abstractions in NameList
This commit is contained in:
parent
4b6fd59a5e
commit
3740c3f4f0
@ -76,7 +76,7 @@ class LambdaHub(context: Context, meta: Meta) : DeviceHub, AbstractDevice(contex
|
||||
}
|
||||
|
||||
override fun optDevice(name: Name): Optional<Device> =
|
||||
magnets.stream().filter { it.name == name.toUnescaped() }.map { it as Device }.findFirst()
|
||||
magnets.stream().filter { it.name == name.unescaped }.map { it as Device }.findFirst()
|
||||
|
||||
override val deviceNames: Stream<Name>
|
||||
get() = magnets.stream().map { Name.ofSingle(it.name) }
|
||||
|
@ -63,7 +63,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
|
||||
|
||||
|
||||
override fun optDevice(name: Name): Optional<Device> =
|
||||
Optional.ofNullable(sensors.find { it.name == name.toUnescaped() })
|
||||
Optional.ofNullable(sensors.find { it.name == name.unescaped })
|
||||
|
||||
override val deviceNames: Stream<Name>
|
||||
get() = sensors.stream().map { Name.ofSingle(it.name) }
|
||||
@ -142,7 +142,7 @@ class VacCollectorDevice(context: Context, meta: Meta, val sensors: Collection<S
|
||||
|
||||
private fun terminator(): Values {
|
||||
val p = ValueMap.Builder()
|
||||
deviceNames.forEach { n -> p.putValue(n.toUnescaped(), Value.NULL) }
|
||||
deviceNames.forEach { n -> p.putValue(n.unescaped, Value.NULL) }
|
||||
return p.build()
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class NumassDataFactory : DataFactory<NumassSet>(NumassSet::class.java) {
|
||||
val storage = context.load(StorageManager::class.java, Meta.empty()).buildStorage(newMeta)
|
||||
StorageUtils.loaderStream(storage).forEach { loader ->
|
||||
if (loader is NumassSet) {
|
||||
builder.putStatic(loader.fullName.toUnescaped(), loader as NumassSet)
|
||||
builder.putStatic(loader.fullName.unescaped, loader as NumassSet)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ import hep.dataforge.storage.commons.DummyStorage
|
||||
import hep.dataforge.storage.filestorage.FileStorage
|
||||
import hep.dataforge.storage.loaders.AbstractLoader
|
||||
import hep.dataforge.tables.Table
|
||||
import hep.dataforge.toList
|
||||
import inr.numass.data.api.NumassPoint
|
||||
import inr.numass.data.api.NumassSet
|
||||
import inr.numass.data.legacy.NumassFileEnvelope
|
||||
@ -43,6 +42,7 @@ import java.time.Instant
|
||||
import java.util.*
|
||||
import java.util.function.Supplier
|
||||
import java.util.stream.Stream
|
||||
import kotlin.streams.toList
|
||||
|
||||
|
||||
/**
|
||||
|
@ -4,7 +4,6 @@ import hep.dataforge.context.Context
|
||||
import hep.dataforge.context.Global
|
||||
import hep.dataforge.io.envelopes.Envelope
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.toList
|
||||
import inr.numass.data.NumassProto
|
||||
import inr.numass.data.api.*
|
||||
import inr.numass.data.dataStream
|
||||
@ -15,6 +14,7 @@ import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.util.stream.IntStream
|
||||
import java.util.stream.Stream
|
||||
import kotlin.streams.toList
|
||||
|
||||
/**
|
||||
* Protobuf based numass point
|
||||
|
@ -16,7 +16,6 @@
|
||||
package inr.numass.models;
|
||||
|
||||
import hep.dataforge.exceptions.NotDefinedException;
|
||||
import hep.dataforge.names.Names;
|
||||
import hep.dataforge.values.ValueProvider;
|
||||
import hep.dataforge.values.Values;
|
||||
import org.apache.commons.math3.analysis.UnivariateFunction;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package inr.numass.models
|
||||
|
||||
import hep.dataforge.maths.integration.UnivariateIntegrator
|
||||
import hep.dataforge.names.Names
|
||||
import hep.dataforge.names.NameList
|
||||
import hep.dataforge.stat.models.Model
|
||||
import hep.dataforge.stat.models.ModelFactory
|
||||
import hep.dataforge.stat.parametric.AbstractParametricFunction
|
||||
@ -24,7 +24,7 @@ fun model(name: String,factory: ContextMetaFactory<Model>): ModelFactory {
|
||||
* Calculate sum of two parametric functions
|
||||
*/
|
||||
operator fun ParametricFunction.plus(func: ParametricFunction): ParametricFunction {
|
||||
val mergedNames = Names.of(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
val mergedNames = NameList(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
return object : AbstractParametricFunction(mergedNames) {
|
||||
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||
return func.derivValue(parName, x, set) + this@plus.derivValue(parName, x, set)
|
||||
@ -42,7 +42,7 @@ operator fun ParametricFunction.plus(func: ParametricFunction): ParametricFuncti
|
||||
}
|
||||
|
||||
operator fun ParametricFunction.minus(func: ParametricFunction): ParametricFunction {
|
||||
val mergedNames = Names.of(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
val mergedNames = NameList(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
return object : AbstractParametricFunction(mergedNames) {
|
||||
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||
return func.derivValue(parName, x, set) - this@minus.derivValue(parName, x, set)
|
||||
@ -64,7 +64,7 @@ operator fun ParametricFunction.minus(func: ParametricFunction): ParametricFunct
|
||||
*
|
||||
*/
|
||||
operator fun ParametricFunction.times(func: ParametricFunction): ParametricFunction {
|
||||
val mergedNames = Names.of(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
val mergedNames = NameList(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
return object : AbstractParametricFunction(mergedNames) {
|
||||
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||
return this@times.value(x, set) * func.derivValue(parName, x, set) + this@times.derivValue(parName, x, set) * func.value(x, set)
|
||||
@ -113,7 +113,7 @@ fun ParametricFunction.convolute(
|
||||
integrator: UnivariateIntegrator<*> = NumassIntegrator.getDefaultIntegrator(),
|
||||
support: Values.(String, Double) -> Pair<Double, Double>
|
||||
): ParametricFunction {
|
||||
val mergedNames = Names.of(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
val mergedNames = NameList(Stream.concat(names.stream(), func.names.stream()).distinct())
|
||||
return object : AbstractParametricFunction(mergedNames) {
|
||||
override fun derivValue(parName: String, x: Double, set: Values): Double {
|
||||
val (a, b) = set.support(parName, x)
|
||||
|
@ -66,7 +66,7 @@ fun main(args: Array<String>) {
|
||||
for (hv in arrayOf(14000.0, 14500.0, 15000.0, 15500.0, 16050.0)) {
|
||||
|
||||
val frame = displayChart("integral[$hv]").apply {
|
||||
this.plots.descriptor = Descriptors.forType(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forType("plot", DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ fun main(args: Array<String>) {
|
||||
val point = ProtoNumassPoint.readFile(Paths.get("D:\\Work\\Numass\\data\\2017_05_frames\\Fill_3_events\\set_33\\p36(30s)(HV1=17000).df"))
|
||||
|
||||
val frame = displayChart("integral").apply {
|
||||
this.plots.descriptor = Descriptors.forType(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forType("plot", DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
val frame = displayChart("differential").apply {
|
||||
this.plots.descriptor = Descriptors.forType(DataPlot::class)
|
||||
this.plots.descriptor = Descriptors.forType("plot", DataPlot::class)
|
||||
this.plots.configureValue("showLine", true)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user