Skip to content

Remove logging from the API used for the compiler plugin #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.inputHandlers

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.documentation.UnifyingNumbers
import org.jetbrains.kotlinx.dataframe.impl.UnifiedNumberTypeOptions
import org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.Aggregator
Expand All @@ -22,8 +21,6 @@ import kotlin.reflect.full.isSubtypeOf
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

/**
* Input handler for aggregators that can handle any (mixed) primitive [Number] type of input.
*
Expand Down Expand Up @@ -107,14 +104,6 @@ internal class NumberInputHandler<out Return : Any?> : AggregatorInputHandler<Nu
override fun calculateValueType(valueTypes: Set<KType>): ValueType {
val unifiedType = valueTypes.unifiedNumberTypeOrNull(UnifiedNumberTypeOptions.PRIMITIVES_ONLY)
?: typeOf<Number>().withNullability(valueTypes.any { it.isMarkedNullable })

if (unifiedType.isSubtypeOf(typeOf<Double?>()) &&
(typeOf<ULong>() in valueTypes || typeOf<Long>() in valueTypes)
) {
logger.warn {
"Number unification of Long -> Double happened during ${aggregator!!.name} aggregation. Loss of precision may have occurred."
}
}
if (!unifiedType.isPrimitiveOrMixedNumber() && !unifiedType.isNothing) {
throw IllegalArgumentException(
"Cannot calculate ${aggregator!!.name} of ${
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.math

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.api.skipNaNDefault
import org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.CalculateReturnType
import org.jetbrains.kotlinx.dataframe.impl.nothingType
Expand All @@ -10,8 +9,6 @@ import java.math.BigInteger
import kotlin.reflect.KType
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

@Suppress("UNCHECKED_CAST")
internal fun <T : Number> Sequence<T>.mean(type: KType, skipNaN: Boolean): Double {
if (type.isMarkedNullable) {
Expand All @@ -29,7 +26,6 @@ internal fun <T : Number> Sequence<T>.mean(type: KType, skipNaN: Boolean): Doubl
typeOf<Byte>() -> (this as Sequence<Byte>).map { it.toDouble() }.mean(false)

typeOf<Long>() -> {
logger.warn { "Converting Longs to Doubles to calculate the mean, loss of precision may occur." }
(this as Sequence<Long>).map { it.toDouble() }.mean(false)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.math

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.api.isNaN
import org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.CalculateReturnType
import org.jetbrains.kotlinx.dataframe.impl.canBeNaN
Expand All @@ -15,8 +14,6 @@ import kotlin.reflect.KType
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

/**
* Returns the median of the comparable input:
* - `null` if empty
Expand Down Expand Up @@ -48,8 +45,7 @@ internal fun <T : Comparable<T>> Sequence<T>.medianOrNull(type: KType, skipNaN:
"Cannot calculate the median for big numbers in DataFrame. Only primitive numbers are supported.",
)

type == typeOf<Long>() ->
logger.warn { "Converting Longs to Doubles to calculate the median, loss of precision may occur." }
// TODO kdocs: note about loss of precision for Long
}

val p = 0.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.math

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.api.isNaN
import org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.CalculateReturnType
import org.jetbrains.kotlinx.dataframe.impl.isIntraComparable
Expand All @@ -14,8 +13,6 @@ import kotlin.reflect.KType
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

/**
* Uses [QuantileEstimationMethod.R8] for primitive numbers, else [QuantileEstimationMethod.R3]
*/
Expand All @@ -41,8 +38,7 @@ internal fun <T : Comparable<T>> Sequence<T>.percentileOrNull(percentile: Double
"Cannot calculate the percentile for big numbers in DataFrame. Only primitive numbers are supported.",
)

type == typeOf<Long>() ->
logger.warn { "Converting Longs to Doubles to calculate the percentile, loss of precision may occur." }
// TODO kdocs: note about loss of precision for Long
}

// percentile of 25.0 means the 25th 100-quantile, so 25 / 100 = 0.25
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.math

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.api.isNaN
import org.jetbrains.kotlinx.dataframe.impl.canBeNaN
import org.jetbrains.kotlinx.dataframe.impl.isIntraComparable
Expand All @@ -16,8 +15,6 @@ import kotlin.reflect.KType
import kotlin.reflect.full.withNullability
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

/**
* Returns the p-quantile: the k'th q-quantile, where p = k/q.
*
Expand Down Expand Up @@ -60,9 +57,6 @@ internal fun <T : Comparable<T>> Sequence<Any>.quantileOrNull(
throw IllegalArgumentException(
"Cannot calculate the $name for big numbers in DataFrame. Only primitive numbers are supported.",
)

type == typeOf<Long>() ->
logger.warn { "Converting Longs to Doubles to calculate the $name, loss of precision may occur." }
}

// propagate NaN to return if they are not to be skipped
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.kotlinx.dataframe.math

import io.github.oshai.kotlinlogging.KotlinLogging
import org.jetbrains.kotlinx.dataframe.api.ddofDefault
import org.jetbrains.kotlinx.dataframe.api.skipNaNDefault
import org.jetbrains.kotlinx.dataframe.impl.aggregation.aggregators.CalculateReturnType
Expand All @@ -12,8 +11,6 @@ import kotlin.math.sqrt
import kotlin.reflect.KType
import kotlin.reflect.typeOf

private val logger = KotlinLogging.logger { }

/**
* Calculates the standard deviation from [this] with optional delta degrees of freedom.
*
Expand All @@ -39,7 +36,6 @@ internal fun <T : Number> Sequence<T?>.std(type: KType, skipNaN: Boolean, ddof:
typeOf<Byte>() -> (this as Sequence<Byte>).map { it.toDouble() }.std(false, ddof)

typeOf<Long>() -> {
logger.warn { "Converting Longs to Doubles to calculate the std, loss of precision may occur." }
(this as Sequence<Long>).map { it.toDouble() }.std(false, ddof)
}

Expand Down