Update gradle-tools, do Kotlin 1.6.0 migrations

This commit is contained in:
Iaroslav Postovalov 2021-11-24 03:48:43 +07:00
parent 4691caaa7f
commit d2e3110480
18 changed files with 42 additions and 60 deletions

View File

@ -48,7 +48,7 @@ kotlin {
implementation(project(":kmath-nd4j")) implementation(project(":kmath-nd4j"))
implementation(project(":kmath-kotlingrad")) implementation(project(":kmath-kotlingrad"))
implementation(project(":kmath-viktor")) implementation(project(":kmath-viktor"))
implementation(projects.kmathMultik) implementation(project(":kmath-multik"))
implementation("org.nd4j:nd4j-native:1.0.0-M1") implementation("org.nd4j:nd4j-native:1.0.0-M1")
// uncomment if your system supports AVX2 // uncomment if your system supports AVX2
// val os = System.getProperty("os.name") // val os = System.getProperty("os.name")
@ -134,9 +134,9 @@ afterEvaluate {
kotlin.sourceSets.all { kotlin.sourceSets.all {
with(languageSettings) { with(languageSettings) {
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") optIn("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes") optIn("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") optIn("space.kscience.kmath.misc.UnstableKMathAPI")
} }
} }

View File

@ -39,7 +39,7 @@ subprojects {
localDirectory.set(kotlinDir) localDirectory.set(kotlinDir)
remoteUrl.set( remoteUrl.set(
URL("https://github.com/mipt-npm/${rootProject.name}/tree/master/${this@subprojects.name}/$kotlinDirPath") URL("https://github.com/mipt-npm/kmath/tree/master/${this@subprojects.name}/$kotlinDirPath")
) )
} }
@ -64,9 +64,9 @@ subprojects {
readme.readmeTemplate = file("docs/templates/README-TEMPLATE.md") readme.readmeTemplate = file("docs/templates/README-TEMPLATE.md")
ksciencePublish { ksciencePublish {
vcs("https://github.com/mipt-npm/kmath") github("kmath", publish = false)
space(publish = true) space()
sonatype(publish = true) sonatype()
} }
apiValidation.nonPublicMarkers.add("space.kscience.kmath.misc.UnstableKMathAPI") apiValidation.nonPublicMarkers.add("space.kscience.kmath.misc.UnstableKMathAPI")

View File

@ -1,6 +1,6 @@
plugins { plugins {
`kotlin-dsl` `kotlin-dsl`
kotlin("plugin.serialization") version "1.4.31" kotlin("plugin.serialization") version "1.5.21"
} }
repositories { repositories {
@ -10,8 +10,8 @@ repositories {
} }
dependencies { dependencies {
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.1.0") api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2")
api("ru.mipt.npm:gradle-tools:0.10.2") api("ru.mipt.npm:gradle-tools:0.10.7")
api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.3.1") api("org.jetbrains.kotlinx:kotlinx-benchmark-plugin:0.3.1")
} }

View File

@ -32,7 +32,7 @@ dependencies {
//jafama //jafama
implementation(project(":kmath-jafama")) implementation(project(":kmath-jafama"))
//multik //multik
implementation(projects.kmathMultik) implementation(project(":kmath-multik"))
implementation("org.nd4j:nd4j-native:1.0.0-beta7") implementation("org.nd4j:nd4j-native:1.0.0-beta7")
@ -57,9 +57,9 @@ dependencies {
kotlin.sourceSets.all { kotlin.sourceSets.all {
with(languageSettings) { with(languageSettings) {
useExperimentalAnnotation("kotlin.contracts.ExperimentalContracts") optIn("kotlin.contracts.ExperimentalContracts")
useExperimentalAnnotation("kotlin.ExperimentalUnsignedTypes") optIn("kotlin.ExperimentalUnsignedTypes")
useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") optIn("space.kscience.kmath.misc.UnstableKMathAPI")
} }
} }

View File

@ -20,7 +20,7 @@ kotlin.js {
kotlin.sourceSets { kotlin.sourceSets {
filter { it.name.contains("test", true) } filter { it.name.contains("test", true) }
.map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings) .map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
.forEach { it.useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") } .forEach { it.optIn("space.kscience.kmath.misc.UnstableKMathAPI") }
commonMain { commonMain {
dependencies { dependencies {

View File

@ -38,10 +38,7 @@ public class CMRandomGeneratorWrapper(
override fun nextInt(): Int = generator.nextInt() override fun nextInt(): Int = generator.nextInt()
override fun nextInt(n: Int): Int = generator.nextInt(n) override fun nextInt(n: Int): Int = generator.nextInt(n)
@PerformancePitfall
override fun nextGaussian(): Double = runBlocking { GaussianSampler(0.0, 1.0).next(generator) } override fun nextGaussian(): Double = runBlocking { GaussianSampler(0.0, 1.0).next(generator) }
override fun nextDouble(): Double = generator.nextDouble() override fun nextDouble(): Double = generator.nextDouble()
override fun nextLong(): Long = generator.nextLong() override fun nextLong(): Long = generator.nextLong()
} }

View File

@ -5,21 +5,14 @@ plugins {
// id("com.xcporter.metaview") version "0.0.5" // id("com.xcporter.metaview") version "0.0.5"
} }
kotlin { kotlin.sourceSets {
jvm { filter { it.name.contains("test", true) }
compilations.all { .map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
kotlinOptions { .forEach { it.optIn("space.kscience.kmath.misc.PerformancePitfall") }
freeCompilerArgs =
freeCompilerArgs + "-Xjvm-default=all" + "-Xopt-in=kotlin.RequiresOptIn" + "-Xlambdas=indy"
}
}
}
sourceSets { commonMain {
commonMain { dependencies {
dependencies { api(project(":kmath-memory"))
api(project(":kmath-memory"))
}
} }
} }
} }

View File

@ -12,7 +12,7 @@ package space.kscience.kmath.misc
* in some way that may break some code. * in some way that may break some code.
*/ */
@MustBeDocumented @MustBeDocumented
@Retention(value = AnnotationRetention.SOURCE) @Retention(value = AnnotationRetention.BINARY)
@RequiresOptIn("This API is unstable and could change in future", RequiresOptIn.Level.WARNING) @RequiresOptIn("This API is unstable and could change in future", RequiresOptIn.Level.WARNING)
public annotation class UnstableKMathAPI public annotation class UnstableKMathAPI
@ -21,10 +21,10 @@ public annotation class UnstableKMathAPI
* slow-down in some cases. Refer to the documentation and benchmark it to be sure. * slow-down in some cases. Refer to the documentation and benchmark it to be sure.
*/ */
@MustBeDocumented @MustBeDocumented
@Retention(value = AnnotationRetention.SOURCE) @Retention(value = AnnotationRetention.BINARY)
@RequiresOptIn( @RequiresOptIn(
"Refer to the documentation to use this API in performance-critical code", "Refer to the documentation to use this API in performance-critical code",
RequiresOptIn.Level.WARNING RequiresOptIn.Level.WARNING,
) )
public annotation class PerformancePitfall( public annotation class PerformancePitfall(
val message: String = "Potential performance problem" val message: String = "Potential performance problem"

View File

@ -35,13 +35,11 @@ public interface BufferAlgebra<T, out A : Algebra<T>> : Algebra<Buffer<T>> {
public fun Buffer<T>.zip(other: Buffer<T>, block: A.(left: T, right: T) -> T): Buffer<T> = public fun Buffer<T>.zip(other: Buffer<T>, block: A.(left: T, right: T) -> T): Buffer<T> =
zipInline(this, other, block) zipInline(this, other, block)
@UnstableKMathAPI
override fun unaryOperationFunction(operation: String): (arg: Buffer<T>) -> Buffer<T> { override fun unaryOperationFunction(operation: String): (arg: Buffer<T>) -> Buffer<T> {
val operationFunction = elementAlgebra.unaryOperationFunction(operation) val operationFunction = elementAlgebra.unaryOperationFunction(operation)
return { arg -> bufferFactory(arg.size) { operationFunction(arg[it]) } } return { arg -> bufferFactory(arg.size) { operationFunction(arg[it]) } }
} }
@UnstableKMathAPI
override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> { override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> {
val operationFunction = elementAlgebra.binaryOperationFunction(operation) val operationFunction = elementAlgebra.binaryOperationFunction(operation)
return { left, right -> return { left, right ->
@ -141,11 +139,9 @@ public open class BufferRingOps<T, A: Ring<T>>(
override fun multiply(left: Buffer<T>, right: Buffer<T>): Buffer<T> = zipInline(left, right) { l, r -> l * r } override fun multiply(left: Buffer<T>, right: Buffer<T>): Buffer<T> = zipInline(left, right) { l, r -> l * r }
override fun Buffer<T>.unaryMinus(): Buffer<T> = map { -it } override fun Buffer<T>.unaryMinus(): Buffer<T> = map { -it }
@UnstableKMathAPI
override fun unaryOperationFunction(operation: String): (arg: Buffer<T>) -> Buffer<T> = override fun unaryOperationFunction(operation: String): (arg: Buffer<T>) -> Buffer<T> =
super<BufferAlgebra>.unaryOperationFunction(operation) super<BufferAlgebra>.unaryOperationFunction(operation)
@UnstableKMathAPI
override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> = override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> =
super<BufferAlgebra>.binaryOperationFunction(operation) super<BufferAlgebra>.binaryOperationFunction(operation)
} }
@ -165,7 +161,6 @@ public open class BufferFieldOps<T, A : Field<T>>(
override fun scale(a: Buffer<T>, value: Double): Buffer<T> = a.map { scale(it, value) } override fun scale(a: Buffer<T>, value: Double): Buffer<T> = a.map { scale(it, value) }
override fun Buffer<T>.unaryMinus(): Buffer<T> = map { -it } override fun Buffer<T>.unaryMinus(): Buffer<T> = map { -it }
@UnstableKMathAPI
override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> = override fun binaryOperationFunction(operation: String): (left: Buffer<T>, right: Buffer<T>) -> Buffer<T> =
super<BufferRingOps>.binaryOperationFunction(operation) super<BufferRingOps>.binaryOperationFunction(operation)
} }

View File

@ -40,7 +40,6 @@ public class DoubleBufferField(public val size: Int) : ExtendedField<Buffer<Doub
} }
} }
@UnstableKMathAPI
override fun unaryOperationFunction(operation: String): (arg: Buffer<Double>) -> Buffer<Double> = override fun unaryOperationFunction(operation: String): (arg: Buffer<Double>) -> Buffer<Double> =
super<ExtendedField>.unaryOperationFunction(operation) super<ExtendedField>.unaryOperationFunction(operation)

View File

@ -26,11 +26,9 @@ public abstract class DoubleBufferOps : BufferAlgebra<Double, DoubleField>, Exte
override fun Buffer<Double>.map(block: DoubleField.(Double) -> Double): DoubleBuffer = override fun Buffer<Double>.map(block: DoubleField.(Double) -> Double): DoubleBuffer =
mapInline { DoubleField.block(it) } mapInline { DoubleField.block(it) }
@UnstableKMathAPI
override fun unaryOperationFunction(operation: String): (arg: Buffer<Double>) -> Buffer<Double> = override fun unaryOperationFunction(operation: String): (arg: Buffer<Double>) -> Buffer<Double> =
super<ExtendedFieldOps>.unaryOperationFunction(operation) super<ExtendedFieldOps>.unaryOperationFunction(operation)
@UnstableKMathAPI
override fun binaryOperationFunction(operation: String): (left: Buffer<Double>, right: Buffer<Double>) -> Buffer<Double> = override fun binaryOperationFunction(operation: String): (left: Buffer<Double>, right: Buffer<Double>) -> Buffer<Double> =
super<ExtendedFieldOps>.binaryOperationFunction(operation) super<ExtendedFieldOps>.binaryOperationFunction(operation)

View File

@ -7,9 +7,9 @@ plugins {
kotlin.sourceSets { kotlin.sourceSets {
all { all {
with(languageSettings) { with(languageSettings) {
useExperimentalAnnotation("kotlinx.coroutines.InternalCoroutinesApi") optIn("kotlinx.coroutines.InternalCoroutinesApi")
useExperimentalAnnotation("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
useExperimentalAnnotation("kotlinx.coroutines.FlowPreview") optIn("kotlinx.coroutines.FlowPreview")
} }
} }

View File

@ -23,5 +23,5 @@ readme {
} }
kotlin.sourceSets.all { kotlin.sourceSets.all {
languageSettings.useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") languageSettings.optIn("space.kscience.kmath.misc.UnstableKMathAPI")
} }

View File

@ -9,7 +9,7 @@ dependencies {
api(project(":kmath-for-real")) api(project(":kmath-for-real"))
} }
kscience{ kscience {
useHtml() useHtml()
} }
@ -18,7 +18,7 @@ readme {
} }
kotlin.sourceSets.all { kotlin.sourceSets.all {
languageSettings.useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") languageSettings.optIn("space.kscience.kmath.misc.UnstableKMathAPI")
} }
tasks.processJupyterApiResources { tasks.processJupyterApiResources {

View File

@ -8,6 +8,10 @@ kscience {
} }
kotlin.sourceSets { kotlin.sourceSets {
all {
languageSettings.optIn("space.kscience.kmath.misc.UnstableKMathAPI")
}
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-coroutines")) api(project(":kmath-coroutines"))

View File

@ -6,9 +6,13 @@ plugins {
kotlin.sourceSets { kotlin.sourceSets {
all { all {
languageSettings.useExperimentalAnnotation("space.kscience.kmath.misc.UnstableKMathAPI") languageSettings.optIn("space.kscience.kmath.misc.UnstableKMathAPI")
} }
filter { it.name.contains("test", true) }
.map(org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet::languageSettings)
.forEach { it.optIn("space.kscience.kmath.misc.PerformancePitfall") }
commonMain { commonMain {
dependencies { dependencies {
api(project(":kmath-core")) api(project(":kmath-core"))

View File

@ -384,7 +384,6 @@ public open class DoubleTensorAlgebra :
override fun Tensor<Double>.viewAs(other: StructureND<Double>): DoubleTensor = override fun Tensor<Double>.viewAs(other: StructureND<Double>): DoubleTensor =
tensor.view(other.shape) tensor.view(other.shape)
@PerformancePitfall
override infix fun StructureND<Double>.dot(other: StructureND<Double>): DoubleTensor { override infix fun StructureND<Double>.dot(other: StructureND<Double>): DoubleTensor {
if (tensor.shape.size == 1 && other.shape.size == 1) { if (tensor.shape.size == 1 && other.shape.size == 1) {
return DoubleTensor(intArrayOf(1), doubleArrayOf(tensor.times(other).tensor.mutableBuffer.array().sum())) return DoubleTensor(intArrayOf(1), doubleArrayOf(tensor.times(other).tensor.mutableBuffer.array().sum()))

View File

@ -5,14 +5,10 @@ pluginManagement {
gradlePluginPortal() gradlePluginPortal()
} }
val kotlinVersion = "1.6.0-RC" val kotlinVersion = "1.6.0"
val toolsVersion = "0.10.5"
plugins { plugins {
id("org.jetbrains.kotlinx.benchmark") version "0.3.1" id("org.jetbrains.kotlinx.benchmark") version "0.3.1"
id("ru.mipt.npm.gradle.project") version toolsVersion
id("ru.mipt.npm.gradle.jvm") version toolsVersion
id("ru.mipt.npm.gradle.mpp") version toolsVersion
kotlin("multiplatform") version kotlinVersion kotlin("multiplatform") version kotlinVersion
kotlin("plugin.allopen") version kotlinVersion kotlin("plugin.allopen") version kotlinVersion
} }
@ -20,9 +16,6 @@ pluginManagement {
rootProject.name = "kmath" rootProject.name = "kmath"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
enableFeaturePreview("VERSION_CATALOGS")
include( include(
":kmath-memory", ":kmath-memory",
":kmath-complex", ":kmath-complex",