Kotlin / multik

Multidimensional array library for Kotlin
https://kotlin.github.io/multik/
Apache License 2.0
633 stars 38 forks source link

Overload resolution ambiguity. #201

Closed paccuk closed 4 months ago

paccuk commented 4 months ago

I have been learning kotlin for a few days. When I use multik in Kotlin Notebook to create an array, I get "Overload resolution ambiguity."

Build Tool: Gradle Gradle JVM: 11.0.22 IDE: IntelliJ IDEA

Here is my code:

%use multik
val x = mk.arange<Float>(-10, 10, 0.25)

Line_21.jupyter.kts (1:12 - 18) Overload resolution ambiguity:

public inline fun <reified T : Number> Multik.arange(start: Int, stop: Int, step: Double): D1Array<TypeVariable(T)> /* = NDArray<TypeVariable(T), D1> */ defined in org.jetbrains.kotlinx.multik.api
public inline fun <reified T : Number> Multik.arange(start: Int, stop: Int, step: Double): D1Array<TypeVariable(T)> /* = NDArray<TypeVariable(T), D1> */ defined in org.jetbrains.kotlinx.multik.api
devcrocod commented 4 months ago

Ooh, that looks weird. Apparently Kotlin couldn't resolve it. Since identical signatures are written in the output, I assume that this message was duplicated.

workaround for now, I can suggest writing parameters explicitly:

val x = mk.arange<Float>(start = -10, stop = 10, step = 0.25)

Also could you separate the import and call into different cells. Because %use multik or %use other_library can execute some init code and add imports. In theory, this shouldn't have any effect, but I'm not sure.

I will check the behavior you described in myself

devcrocod commented 4 months ago

ok, I couldn't reproduce this bug.

Please tell us more details:

Since a conflict may arise between the code in the notebook and the library source code. You can set up this in kotlin notebook settings:

image
paccuk commented 4 months ago

Since a conflict may arise between the code in the notebook and the library source code. You can set up this in kotlin notebook settings:

I tried what you suggested, then restarted the kernel a few times and now it works. Thank you for response and help.