Compare commits

...

10 Commits

Author SHA1 Message Date
3e8f44166c add Attributes minus 2024-07-07 11:14:11 +03:00
6e24b563b2 optimize attributes plus 2024-07-07 11:06:20 +03:00
2d309e050b Merge branch 'refs/heads/beta/kotlin2.0.0' into dev 2024-07-07 11:03:48 +03:00
c585c59552 2.0.0 2024-06-04 10:31:42 +03:00
c418607bf6 2.0.0-RC2 2024-04-30 19:41:34 +03:00
9518f16348 Merge branch 'refs/heads/dev' into beta/kotlin2.0.0
# Conflicts:
#	gradle.properties
2024-04-20 09:22:19 +03:00
0af8147be6 Remove unnecessary internal dependencies 2024-03-26 09:58:50 +03:00
bd9430bab4 Merge branch 'dev' into beta/kotlin2.0.0
# Conflicts:
#	gradle.properties
#	kmath-histograms/build.gradle.kts
#	kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt
2024-03-19 09:15:55 +03:00
9f9c4a347b Fix all issues for 2.0.0 2024-01-28 18:35:47 +03:00
9e88bff668 Kotlin 2.0.0-Beta1 2023-11-22 09:22:28 +03:00
16 changed files with 52 additions and 113 deletions

View File

@ -140,4 +140,18 @@ public fun <A : Attribute<Unit>> Attributes(
attribute: A,
): Attributes = MapAttributes(mapOf(attribute to Unit))
public operator fun Attributes.plus(other: Attributes): Attributes = MapAttributes(content + other.content)
/**
* Create a new [Attributes] that overlays [other] on top of this set of attributes. New attributes are added.
* Existing attribute keys are replaced.
*/
public operator fun Attributes.plus(other: Attributes): Attributes = when {
isEmpty() -> other
other.isEmpty() -> this
else -> MapAttributes(content + other.content)
}
/**
* Create a new [Attributes] with removed [key] (if it is present).
*/
public operator fun Attributes.minus(key: Attribute<*>): Attributes =
if (content.contains(key)) MapAttributes(content.minus(key)) else this

View File

@ -1,6 +1,5 @@
@file:Suppress("UNUSED_VARIABLE")
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import space.kscience.kmath.benchmarks.addBenchmarkProperties
plugins {
@ -152,18 +151,12 @@ benchmark {
}
}
kotlin.sourceSets.all {
with(languageSettings) {
optIn("kotlin.contracts.ExperimentalContracts")
optIn("kotlin.ExperimentalUnsignedTypes")
optIn("space.kscience.kmath.UnstableKMathAPI")
}
}
tasks.withType<KotlinJvmCompile> {
kotlinOptions {
jvmTarget = "11"
freeCompilerArgs = freeCompilerArgs + "-Xjvm-default=all" + "-Xlambdas=indy"
kotlin {
jvmToolchain(11)
compilerOptions {
optIn.addAll(
"space.kscience.kmath.UnstableKMathAPI"
)
}
}

View File

@ -16,7 +16,7 @@ allprojects {
}
group = "space.kscience"
version = "0.4.0"
version = "0.4.1-dev"
}
subprojects {

View File

@ -1,4 +1,5 @@
plugins {
kotlin("jvm") version "1.9.23"
`kotlin-dsl`
`version-catalog`
}
@ -25,10 +26,8 @@ dependencies {
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
sourceSets.all {
languageSettings.optIn("kotlin.OptIn")
jvmToolchain(11)
compilerOptions {
optIn.add("kotlin.OptIn")
}
}

View File

@ -9,6 +9,7 @@ org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4096m
org.gradle.parallel=true
org.gradle.workers.max=4
toolsVersion=0.15.2-kotlin-1.9.22
toolsVersion=0.15.4-kotlin-2.0.0
#kotlin.experimental.tryK2=true
#kscience.wasm.disabled=true

View File

@ -4,7 +4,20 @@ plugins {
kscience {
jvm()
js()
js{
nodejs {
testTask {
useMocha().timeout = "0"
}
}
browser {
useCommonJs()
testTask {
useMocha().timeout = "0"
}
}
}
native()
dependencies {
@ -18,7 +31,7 @@ kscience {
dependencies(jsMain) {
implementation(npm("astring", "1.7.5"))
implementation(npm("binaryen", "101.0.0"))
implementation(npm("binaryen", "117.0.0"))
implementation(npm("js-base64", "3.6.1"))
}
@ -29,19 +42,6 @@ kscience {
}
kotlin {
js {
nodejs {
testTask {
useMocha().timeout = "0"
}
}
browser {
testTask {
useMocha().timeout = "0"
}
}
}
sourceSets {
filter { it.name.contains("test", true) }

View File

@ -4,11 +4,6 @@
*/
@file:Suppress(
"INTERFACE_WITH_SUPERCLASS",
"OVERRIDING_FINAL_MEMBER",
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
"CONFLICTING_OVERLOADS",
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
"ObjectPropertyName",
"ClassName",
)

View File

@ -4,10 +4,6 @@
*/
@file:Suppress(
"INTERFACE_WITH_SUPERCLASS",
"OVERRIDING_FINAL_MEMBER",
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
"CONFLICTING_OVERLOADS",
"PropertyName",
"ClassName", "ENUM_CLASS_IN_EXTERNAL_DECLARATION_WARNING",
)

View File

@ -6,10 +6,6 @@
@file:JsQualifier("WebAssembly")
@file:Suppress(
"INTERFACE_WITH_SUPERCLASS",
"OVERRIDING_FINAL_MEMBER",
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
"ClassName",
)
@ -22,78 +18,34 @@ import org.w3c.fetch.Response
import space.kscience.kmath.internal.tsstdlib.PromiseLike
import kotlin.js.Promise
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface CompileError {
companion object {
var prototype: CompileError
}
}
internal external interface CompileError
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface Global {
var value: Any
fun valueOf(): Any
companion object {
var prototype: Global
}
}
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
@JsName("Instance")
internal external interface Instance1 {
var exports: Exports
companion object {
var prototype: Instance
}
}
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface LinkError {
companion object {
var prototype: LinkError
}
}
internal external interface LinkError
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface Memory {
var buffer: ArrayBuffer
fun grow(delta: Number): Number
companion object {
var prototype: Memory
}
}
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
@JsName("Module")
internal external interface Module1 {
companion object {
var prototype: Module
fun customSections(moduleObject: Module, sectionName: String): Array<ArrayBuffer>
fun exports(moduleObject: Module): Array<ModuleExportDescriptor>
fun imports(moduleObject: Module): Array<ModuleImportDescriptor>
}
}
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface RuntimeError {
companion object {
var prototype: RuntimeError
}
}
internal external interface RuntimeError
@Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")
internal external interface Table {
var length: Number
fun get(index: Number): Function<*>?
fun grow(delta: Number): Number
fun set(index: Number, value: Function<*>?)
companion object {
var prototype: Table
}
}
internal external interface GlobalDescriptor {

View File

@ -3,13 +3,6 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@file:Suppress(
"INTERFACE_WITH_SUPERCLASS",
"OVERRIDING_FINAL_MEMBER",
"RETURN_TYPE_MISMATCH_ON_OVERRIDE",
"CONFLICTING_OVERLOADS",
"NO_EXPLICIT_VISIBILITY_IN_API_MODE_WARNING",
)
package space.kscience.kmath.internal.webassembly

View File

@ -12,8 +12,6 @@ import space.kscience.kmath.expressions.Symbol
import space.kscience.kmath.operations.Algebra
import space.kscience.kmath.operations.Float64Field
import space.kscience.kmath.operations.Int32Ring
import kotlin.contracts.InvocationKind
import kotlin.contracts.contract
import space.kscience.kmath.asm.compile as asmCompile
import space.kscience.kmath.asm.compileToExpression as asmCompileToExpression
@ -43,7 +41,6 @@ private object PrimitiveAsmCompilerTestContext : CompilerTestContext {
internal actual inline fun runCompilerTest(action: CompilerTestContext.() -> Unit) {
contract { callsInPlace(action, InvocationKind.EXACTLY_ONCE) }
action(GenericAsmCompilerTestContext)
action(PrimitiveAsmCompilerTestContext)
}

View File

@ -6,7 +6,6 @@
package space.kscience.kmath.nd
import space.kscience.kmath.UnsafeKMathAPI
import kotlin.jvm.JvmInline
/**
* A read-only ND shape

View File

@ -159,7 +159,7 @@ class Rational {
override fun equals(other: Any?): Boolean =
when (other) {
is Rational -> numerator == other.numerator && denominator == other.denominator
is Int -> numerator == other && denominator == 1L
is Int -> numerator == other.toLong() && denominator == 1L
is Long -> numerator == other && denominator == 1L
else -> false
}

View File

@ -33,7 +33,7 @@ public interface Histogram<in T : Any, out V, out B : Bin<T, V>> {
/**
* Find existing bin, corresponding to given coordinates
*/
public operator fun get(point: Point<out T>): B?
public operator fun get(point: Point<T>): B?
/**
* Dimension of the histogram
@ -57,7 +57,7 @@ public interface HistogramBuilder<in T, V> {
/**
* Increment appropriate bin with given value
*/
public fun putValue(point: Point<out T>, value: V = defaultValue)
public fun putValue(point: Point<T>, value: V = defaultValue)
}

View File

@ -42,7 +42,7 @@ public interface Histogram1DBuilder<in T : Any, V : Any> : HistogramBuilder<T, V
*/
public fun putValue(at: T, value: V = defaultValue)
override fun putValue(point: Point<out T>, value: V) {
override fun putValue(point: Point<T>, value: V) {
require(point.size == 1) { "Only points with single value could be used in Histogram1D" }
putValue(point[0], value)
}

View File

@ -93,7 +93,7 @@ public class UniformHistogramGroupND<V : Any, A : Field<V>>(
val hBuilder = object : HistogramBuilder<Double, V> {
override val defaultValue: V get() = valueAlgebraND.elementAlgebra.one
override fun putValue(point: Point<out Double>, value: V) = with(valueAlgebraND.elementAlgebra) {
override fun putValue(point: Point<Double>, value: V) = with(valueAlgebraND.elementAlgebra) {
val index = getIndexOrNull(point)
ndCounter[index].add(value)
}