diff --git a/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/Attributes.kt b/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/Attributes.kt index 9d186acf1..56cd91b13 100644 --- a/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/Attributes.kt +++ b/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/Attributes.kt @@ -84,7 +84,7 @@ public fun > Attributes.withAttribute(attribute: A): Attribu * Create a new [Attributes] by modifying the current one */ public fun Attributes.modify(block: AttributesBuilder.() -> Unit): Attributes = Attributes { - from(this@modify) + putAll(this@modify) block() } diff --git a/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/AttributesBuilder.kt b/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/AttributesBuilder.kt index 0082ba143..033c143cc 100644 --- a/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/AttributesBuilder.kt +++ b/attributes-kt/src/commonMain/kotlin/space/kscience/attributes/AttributesBuilder.kt @@ -34,13 +34,18 @@ public class AttributesBuilder internal constructor( set(this, value) } - public fun from(attributes: Attributes) { + public infix fun Attribute.put(value: V?) { + set(this, value) + } + + /** + * Put all attributes for given [attributes] + */ + public fun putAll(attributes: Attributes) { map.putAll(attributes.content) } - public fun SetAttribute.add( - attrValue: V, - ) { + public infix fun SetAttribute.add(attrValue: V) { val currentSet: Set = get(this) ?: emptySet() map[this] = currentSet + attrValue } @@ -48,9 +53,7 @@ public class AttributesBuilder internal constructor( /** * Remove an element from [SetAttribute] */ - public fun SetAttribute.remove( - attrValue: V, - ) { + public infix fun SetAttribute.remove(attrValue: V) { val currentSet: Set = get(this) ?: emptySet() map[this] = currentSet - attrValue } diff --git a/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt index 3c5f8f5e2..4030e630f 100644 --- a/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt +++ b/kmath-commons/src/jvmMain/kotlin/space/kscience/kmath/commons/optimization/CMOptimizer.kt @@ -43,7 +43,7 @@ public object CMOptimizerData : SetAttribute OptimizationDat * Specify Commons-maths optimization data. */ public fun AttributesBuilder>.cmOptimizationData(data: SymbolIndexer.() -> OptimizationData) { - CMOptimizerData.add(data) + CMOptimizerData add data } public fun AttributesBuilder>.simplexSteps(vararg steps: Pair) {