fun duplicateTemplateProject ( buildVersions : BuildVersions , destination : File )

{ <EOL> prepareProjectFiles ( destination = destination ) <EOL> updateCustomResourcesPath ( destination ) <EOL> updateBuildCacheConfig ( buildVersions , destination ) <EOL> }

/**
 * Create a duplicate [AbstractGradleIntegrationTest.templateProjectDir] in [destination], for Gradle Build Cache
 * testing.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> public fun < reified T : Any > Array < * > . isArrayOf ( ) : Boolean

= <EOL> T :: class . java . isAssignableFrom ( this :: class . java . componentType )

/**
 * Checks if array can contain element of type [T].
 */


private fun countTotalBytes ( column : AnyCol ) : Long ?

{ <EOL> val columnType = column . type ( ) <EOL> return when { <EOL> columnType . isSubtypeOf ( typeOf < String ? > ( ) ) -> column . values . fold ( <NUM_LIT:0L> ) { totalBytes , value -> totalBytes + value . toString ( ) . length * <NUM_LIT:4> } <EOL> else -> null <EOL> } <EOL> }

/**
 * Calculate buffer size for VariableWidthVector (return null for FixedWidthVector)
 */


private fun allocateVectorAndInfill ( field : Field , column : AnyCol ? , strictType : Boolean , strictNullable : Boolean , ) : FieldVector

{ <EOL> val containNulls = ( column == null || column . hasNulls ( ) ) <EOL> val ( convertedColumn , actualField ) = try { <EOL> convertColumnToTarget ( column , field . type ) to field <EOL> } catch ( e : CellConversionException ) { <EOL> if ( strictType ) { <EOL> val mismatch = <EOL> ConvertingMismatch . TypeConversionFail . ConversionFailError ( e . column ? . name ( ) ? : "<STR_LIT>" , e . row , e ) <EOL> mismatchSubscriber ( mismatch ) <EOL> throw ConvertingException ( mismatch ) <EOL> } else { <EOL> mismatchSubscriber ( ConvertingMismatch . TypeConversionFail . ConversionFailIgnored ( e . column ? . name ( ) ? : "<STR_LIT>" , e . row , e ) ) <EOL> column to column ! ! . toArrowField ( mismatchSubscriber ) <EOL> } <EOL> } catch ( e : TypeConverterNotFoundException ) { <EOL> if ( strictType ) { <EOL> val mismatch = ConvertingMismatch . TypeConversionNotFound . ConversionNotFoundError ( field . name , e ) <EOL> mismatchSubscriber ( mismatch ) <EOL> throw ConvertingException ( mismatch ) <EOL> } else { <EOL> mismatchSubscriber ( ConvertingMismatch . TypeConversionNotFound . ConversionNotFoundIgnored ( field . name , e ) ) <EOL> column to column ! ! . toArrowField ( mismatchSubscriber ) <EOL> } <EOL> } <EOL> val vector = if ( ! actualField . isNullable && containNulls ) { <EOL> var firstNullValue : Int ? = null <EOL> for ( i in <NUM_LIT:0> until ( column ? . size ( ) ? : - <NUM_LIT:1> ) ) { <EOL> if ( column ! ! [ i ] == null ) { <EOL> firstNullValue = i <EOL> break <EOL> } <EOL> } <EOL> if ( strictNullable ) { <EOL> val mismatch = ConvertingMismatch . NullableMismatch . NullValueError ( actualField . name , firstNullValue ) <EOL> mismatchSubscriber ( mismatch ) <EOL> throw ConvertingException ( mismatch ) <EOL> } else { <EOL> mismatchSubscriber ( ConvertingMismatch . NullableMismatch . NullValueIgnored ( actualField . name , firstNullValue ) ) <EOL> Field ( actualField . name , FieldType ( true , actualField . fieldType . type , actualField . fieldType . dictionary ) , actualField . children ) . createVector ( allocator ) ! ! <EOL> } <EOL> } else { <EOL> actualField . createVector ( allocator ) ! ! <EOL> } <EOL> if ( convertedColumn == null ) { <EOL> check ( actualField . isNullable ) <EOL> allocateVector ( vector , dataFrame . rowsCount ( ) ) <EOL> infillWithNulls ( vector , dataFrame . rowsCount ( ) ) <EOL> } else { <EOL> allocateVector ( vector , dataFrame . rowsCount ( ) , countTotalBytes ( convertedColumn ) ) <EOL> infillVector ( vector , convertedColumn ) <EOL> } <EOL> return vector <EOL> }

/**
 * Create Arrow FieldVector with [column] content cast to [field] type according to [strictType] and [strictNullable] settings.
 */


@ Deprecated ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun runBlockingTest ( context : CoroutineContext = EmptyCoroutineContext , testBody : suspend TestCoroutineScope . ( ) -> Unit )

{ <EOL> val scope = createTestCoroutineScope ( TestCoroutineDispatcher ( ) + SupervisorJob ( ) + context ) <EOL> val scheduler = scope . testScheduler <EOL> val deferred = scope . async { <EOL> scope . testBody ( ) <EOL> } <EOL> scheduler . advanceUntilIdle ( ) <EOL> deferred . getCompletionExceptionOrNull ( ) ? . let { <EOL> throw it <EOL> } <EOL> scope . cleanupTestCoroutines ( ) <EOL> }

/**
 * Executes a [testBody] inside an immediate execution dispatcher.
 *
 * This method is deprecated in favor of [runTest]. Please see the
 * [migration guide](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md)
 * for an instruction on how to update the code for the new API.
 *
 * This is similar to [runBlocking] but it will immediately progress past delays and into [launch] and [async] blocks.
 * You can use this to write tests that execute in the presence of calls to [delay] without causing your test to take
 * extra time.
 *
 * ```
 * @Test
 * fun exampleTest() = runBlockingTest {
 * val deferred = async {
 * delay(1_000)
 * async {
 * delay(1_000)
 * }.await()
 * }
 *
 * deferred.await() // result available immediately
 * }
 *
 * ```
 *
 * This method requires that all coroutines launched inside [testBody] complete, or are cancelled, as part of the test
 * conditions.
 *
 * Unhandled exceptions thrown by coroutines in the test will be re-thrown at the end of the test.
 *
 * @throws AssertionError If the [testBody] does not complete (or cancel) all coroutines that it launches
 * (including coroutines suspended on join/await).
 *
 * @param context additional context elements. If [context] contains [CoroutineDispatcher] or [CoroutineExceptionHandler],
 * then they must implement [DelayController] and [TestCoroutineExceptionHandler] respectively.
 * @param testBody The code of the unit-test.
 */


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun runBlockingTestOnTestScope ( context : CoroutineContext = EmptyCoroutineContext , testBody : suspend TestScope . ( ) -> Unit )

{ <EOL> val completeContext = TestCoroutineDispatcher ( ) + SupervisorJob ( ) + context <EOL> val startJobs = completeContext . activeJobs ( ) <EOL> val scope = TestScope ( completeContext ) . asSpecificImplementation ( ) <EOL> scope . enter ( ) <EOL> scope . start ( CoroutineStart . UNDISPATCHED , scope ) { <EOL> scope . testBody ( ) <EOL> } <EOL> scope . testScheduler . advanceUntilIdle ( ) <EOL> val throwable = try { <EOL> scope . getCompletionExceptionOrNull ( ) <EOL> } catch ( e : IllegalStateException ) { <EOL> null <EOL> } <EOL> scope . backgroundScope . cancel ( ) <EOL> scope . testScheduler . advanceUntilIdleOr { false } <EOL> throwable ? . let { <EOL> val exceptions = try { <EOL> scope . legacyLeave ( ) <EOL> } catch ( e : UncompletedCoroutinesError ) { <EOL> listOf ( ) <EOL> } <EOL> throwAll ( it , exceptions ) <EOL> return <EOL> } <EOL> throwAll ( null , scope . legacyLeave ( ) ) <EOL> val jobs = completeContext . activeJobs ( ) - startJobs <EOL> if ( jobs . isNotEmpty ( ) ) <EOL> throw UncompletedCoroutinesError ( "<STR_LIT>" ) <EOL> }

/**
 * A version of [runBlockingTest] that works with [TestScope].
 */


@ Deprecated ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun TestCoroutineScope . runBlockingTest ( block : suspend TestCoroutineScope . ( ) -> Unit ) : Unit

= <EOL> runBlockingTest ( coroutineContext , block )

/**
 * Convenience method for calling [runBlockingTest] on an existing [TestCoroutineScope].
 *
 * This method is deprecated in favor of [runTest], whereas [TestCoroutineScope] is deprecated in favor of [TestScope].
 * Please see the
 * [migration guide](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md)
 * for an instruction on how to update the code for the new API.
 */


@ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun TestScope . runBlockingTest ( block : suspend TestScope . ( ) -> Unit ) : Unit

= <EOL> runBlockingTestOnTestScope ( coroutineContext , block )

/**
 * Convenience method for calling [runBlockingTestOnTestScope] on an existing [TestScope].
 */


@ Deprecated ( "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun TestCoroutineDispatcher . runBlockingTest ( block : suspend TestCoroutineScope . ( ) -> Unit ) : Unit

= <EOL> runBlockingTest ( this , block )

/**
 * Convenience method for calling [runBlockingTest] on an existing [TestCoroutineDispatcher].
 *
 * This method is deprecated in favor of [runTest], whereas [TestCoroutineScope] is deprecated in favor of [TestScope].
 * Please see the
 * [migration guide](https://github.com/Kotlin/kotlinx.coroutines/blob/master/kotlinx-coroutines-test/MIGRATION.md)
 * for an instruction on how to update the code for the new API.
 */


@ ExperimentalCoroutinesApi <EOL> @ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun runTestWithLegacyScope ( context : CoroutineContext = EmptyCoroutineContext , dispatchTimeoutMs : Long = DEFAULT_DISPATCH_TIMEOUT_MS , testBody : suspend TestCoroutineScope . ( ) -> Unit )

{ <EOL> if ( context [ RunningInRunTest ] != null ) <EOL> throw IllegalStateException ( "<STR_LIT>" ) <EOL> val testScope = TestBodyCoroutine ( createTestCoroutineScope ( context + RunningInRunTest ) ) <EOL> return createTestResult { <EOL> runTestCoroutineLegacy ( testScope , dispatchTimeoutMs . milliseconds , TestBodyCoroutine :: tryGetCompletionCause , testBody ) { <EOL> try { <EOL> testScope . cleanup ( ) <EOL> emptyList ( ) <EOL> } catch ( e : UncompletedCoroutinesError ) { <EOL> throw e <EOL> } catch ( e : Throwable ) { <EOL> listOf ( e ) <EOL> } <EOL> } <EOL> } <EOL> }

/**
 * This is an overload of [runTest] that works with [TestCoroutineScope].
 */


@ ExperimentalCoroutinesApi <EOL> @ Deprecated ( "<STR_LIT>" , level = DeprecationLevel . WARNING ) <EOL> public fun TestCoroutineScope . runTest ( dispatchTimeoutMs : Long = DEFAULT_DISPATCH_TIMEOUT_MS , block : suspend TestCoroutineScope . ( ) -> Unit ) : TestResult

= runTestWithLegacyScope ( coroutineContext , dispatchTimeoutMs , block )

/**
 * Runs a test in a [TestCoroutineScope] based on this one.
 *
 * Calls [runTest] using a coroutine context from this [TestCoroutineScope]. The [TestCoroutineScope] used to run the
 * [block] will be different from this one, but will use its [Job] as a parent.
 *
 * Since this function returns [TestResult], in order to work correctly on the JS, its result must be returned
 * immediately from the test body. See the docs for [TestResult] for details.
 */


fun tryGetCompletionCause ( ) : Throwable ?

= completionCause

/** Throws an exception if the coroutine is not completing. */


fun renameLocalNames ( context : NamingContext , function : JsFunction )

{ <EOL> for ( name in collectDefinedNames ( function . body ) ) { <EOL> val temporaryName = JsScope . declareTemporaryName ( name . ident ) . apply { staticRef = name . staticRef } <EOL> context . replaceName ( name , temporaryName . makeRef ( ) ) <EOL> } <EOL> }

/**
 * Makes function local names fresh in context
 */


public operator fun get ( index : Int ) : UByte

= storage [ index ] . toUByte ( )

/**
 * Returns the array element at the given [index]. This method can be called using the index operator.
 *
 * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
 * where the behavior is unspecified.
 */


public operator fun set ( index : Int , value : UByte )

{ <EOL> storage [ index ] = value . toByte ( ) <EOL> }

/**
 * Sets the element at the given [index] to the given [value]. This method can be called using the index operator.
 *
 * If the [index] is out of bounds of this array, throws an [IndexOutOfBoundsException] except in Kotlin/JS
 * where the behavior is unspecified.
 */


public override operator fun iterator ( ) : kotlin . collections . Iterator < UByte >

= Iterator ( storage )

/** Creates an iterator over the elements of the array. */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> @ ExperimentalUnsignedTypes <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun UByteArray ( size : Int , init : ( Int ) -> UByte ) : UByteArray

{ <EOL> return UByteArray ( ByteArray ( size ) { index -> init ( index ) . toByte ( ) } ) <EOL> }

/**
 * Creates a new array of the specified [size], where each element is calculated by calling the specified
 * [init] function.
 *
 * The function [init] is called for each array element sequentially starting from the first one.
 * It should return the value for an array element given its index.
 */


private fun denseBenchmarkNames ( src : List < String > ) : Map < String , String >

{ <EOL> if ( src . isEmpty ( ) ) return emptyMap ( ) <EOL> var first = true <EOL> var prefixCut = false <EOL> val prefix = src . fold ( emptyList < String > ( ) ) { prefix , s -> <EOL> val names = s . split ( "<STR_LIT:.>" ) <EOL> if ( first ) { <EOL> first = false <EOL> names . takeWhile { it . lowercase ( ) == it } <EOL> } else { <EOL> val common = prefix . zip ( names ) . takeWhile { ( p , n ) -> p == n && n . lowercase ( ) == n } <EOL> if ( prefix . size != common . size ) prefixCut = true <EOL> prefix . take ( common . size ) <EOL> } <EOL> } . map { if ( prefixCut ) it [ <NUM_LIT:0> ] . toString ( ) else "<STR_LIT>" } <EOL> return src . associateWith { s -> <EOL> val names = prefix + s . split ( "<STR_LIT:.>" ) . drop ( prefix . size ) <EOL> names . joinToString ( "<STR_LIT>" ) { if ( it . isNotEmpty ( ) ) "<STR_LIT>" else "<STR_LIT>" } . removeSuffix ( "<STR_LIT:.>" ) <EOL> } <EOL> }

/**
 * Algorithm:
 * 1. remove package names, if it is the same for all benchmarks
 * 2. if not, shorthand same package names
 *
 * (jmh similar logic)
 */


fun javaFile ( pathFromSrc : String , fillFile : JavaTestDataFile . ( ) -> Unit )

/**
 * Creates a `.java` file.
 *
 * By default, the package of this file is deduced automatically from the [pathFromSrc] param.
 * For example, for a path `org/jetbrains/dokka/test` the package will be `org.jetbrains.dokka.test`.
 * It is normally prohibited for Java files to have a mismatch in package and file path, so it
 * cannot be overridden.
 *
 * @param pathFromSrc path relative to the source code directory of the project.
 * Must contain packages (if any) and end in `.java`.
 * Example: `org/jetbrains/dokka/test/MyClass.java`
 */


public fun copy ( copiedModelName : String ? = null , copyOptimizerState : Boolean = false , copyWeights : Boolean = true ) : Functional

{ <EOL> val serializedModel = serializeModel ( true ) <EOL> return deserializeFunctionalModel ( serializedModel ) . also { modelCopy -> <EOL> if ( copiedModelName != null ) modelCopy . name = copiedModelName <EOL> if ( copyWeights ) copyWeightsTo ( modelCopy , copyOptimizerState ) <EOL> } <EOL> }

/**
 * Creates a copy of this model.
 *
 * @param [copiedModelName] a name for the copy
 * @param [copyOptimizerState] whether optimizer state needs to be copied
 * @param [copyWeights] whether model weights need to be copied
 * @return A copied inference model.
 */


public fun removeLastLayer ( ) : Functional

{ <EOL> require ( ! this . isModelCompiled ) { "<STR_LIT>" } <EOL> val layers = mutableListOf < Layer > ( ) <EOL> for ( layer in this . layers ) { <EOL> layers . add ( layer ) <EOL> } <EOL> val lastLayer = layers . last ( ) <EOL> for ( outboundLayer in lastLayer . inboundLayers ) <EOL> outboundLayer . outboundLayers . remove ( lastLayer ) <EOL> layers . removeLast ( ) <EOL> return of ( layers ) <EOL> }

/** Removes the last layer from the [Functional] model, if it's not compiled yet! . */


@ JvmStatic <EOL> public fun of ( vararg layers : Layer , noInput : Boolean = false , gpuConfiguration : GpuConfiguration ? = null ) : Functional

{ <EOL> if ( ! noInput ) { <EOL> layerValidation ( layers . toList ( ) ) <EOL> } <EOL> return preprocessAndCreate ( layers . toList ( ) , gpuConfiguration ) <EOL> }

/**
 * Creates the [Functional] model.
 *
 * @param [noInput] If true it disables input layer check.
 * @param [layers] The layers to describe the model design.
 * @param [gpuConfiguration] The configuration of a model passed to the Tensorflow Runtime.
 *
 * All connections between the layers must be established and form an acyclic directed graph.
 * Layers could be ordered in free way.
 *
 * NOTE: The first layer should be an input layer if you want to compile a model.
 *
 * @return the [Functional] model.
 */


@ JvmStatic <EOL> public fun of ( vararg layers : Layer , noInput : Boolean = false ) : Functional

{ <EOL> return of ( layers = layers , noInput = noInput , gpuConfiguration = null ) <EOL> }

/**
 * Creates the [Functional] model.
 *
 * @param [noInput] If true it disables input layer check.
 * @param [layers] The layers to describe the model design.
 *
 * All connections between the layers must be established and form an acyclic directed graph.
 * Layers could be ordered in free way.
 *
 * NOTE: The first layer should be an input layer if you want to compile a model.
 *
 * @return the [Functional] model.
 */


@ JvmStatic <EOL> public fun of ( layers : List < Layer > , noInput : Boolean = false , gpuConfiguration : GpuConfiguration ? = null ) : Functional

{ <EOL> if ( ! noInput ) { <EOL> layerValidation ( layers . toList ( ) ) <EOL> } <EOL> return preprocessAndCreate ( layers , gpuConfiguration = gpuConfiguration ) <EOL> }


@ JvmStatic <EOL> public fun of ( layers : List < Layer > , noInput : Boolean = false ) : Functional


@ JvmStatic <EOL> public fun of ( pretrainedModel : GraphTrainableModel , topModel : GraphTrainableModel , gpuConfiguration : GpuConfiguration ? = null ) : Functional

{ <EOL> require ( ! pretrainedModel . isModelCompiled ) { "<STR_LIT>" } <EOL> require ( ! topModel . isModelCompiled ) { "<STR_LIT>" } <EOL> val pretrainedLayers = pretrainedModel . layers <EOL> pretrainedLayers . forEach { it . freeze ( ) } <EOL> val layers = mutableListOf < Layer > ( ) <EOL> layers += pretrainedLayers <EOL> val topLayers = topModel . layers <EOL> layers += topLayers <EOL> topLayers [ <NUM_LIT:0> ] . inboundLayers . add ( pretrainedLayers . last ( ) ) <EOL> if ( topModel is Sequential && layers . size > <NUM_LIT:1> ) { <EOL> topLayers . subList ( <NUM_LIT:1> , topLayers . size ) . forEachIndexed { index , layer -> <EOL> val topLayersIndex = index - <NUM_LIT:1> + <NUM_LIT:1> <EOL> layer . inboundLayers . add ( topLayers [ topLayersIndex ] ) <EOL> } <EOL> } <EOL> return of ( layers , gpuConfiguration = gpuConfiguration ) <EOL> }

/**
 * Creates the [Functional] model from two models: [pretrainedModel] and [topModel].
 * All layers of pretrainedModel will be frozen automatically.
 * The input of the [topModel] will be connected to the output of the [pretrainedModel].
 *
 * NOTE: First layer of [pretrainedModel] should be an input layer.
 * NOTE: Both models should be non-compiled still.
 *
 * @return the [Functional] model.
 */


@ JvmStatic <EOL> public fun of ( pretrainedModel : GraphTrainableModel , topModel : GraphTrainableModel ) : Functional

{ <EOL> return of ( pretrainedModel , topModel , null ) <EOL> }


@ JvmStatic <EOL> public fun fromOutput ( finalLayer : Layer , gpuConfiguration : GpuConfiguration ? = null ) : Functional

{ <EOL> require ( finalLayer . inboundLayers . isNotEmpty ( ) ) { "<STR_LIT>" } <EOL> val layers = mutableSetOf < Layer > ( ) <EOL> layers . add ( finalLayer ) <EOL> visitInboundNodes ( finalLayer , layers ) <EOL> return preprocessAndCreate ( layers . toList ( ) , gpuConfiguration ) <EOL> }

/**
 * Creates the [Functional] model.
 *
 * @param [finalLayer] This layer specifies the output tensors that represent the outputs of this model.
 * All connections between the layers must be established and form an acyclic directed graph.
 *
 * @return the [Functional] model.
 */


@ JvmStatic <EOL> public fun fromOutput ( finalLayer : Layer ) : Functional

{ <EOL> return fromOutput ( finalLayer , null ) <EOL> }


private fun preprocessAndCreate ( layers : List < Layer > , gpuConfiguration : GpuConfiguration ? = null ) : Functional

{ <EOL> val inputLayer = findInputLayer ( layers ) <EOL> fillOutputLayers ( layers ) <EOL> val layerList = topologicalSort ( layers , inputLayer ) <EOL> preProcessLayerNames ( layerList . toTypedArray ( ) ) <EOL> return Functional ( * layerList . toTypedArray ( ) , gpuConfiguration = gpuConfiguration ) <EOL> }

/**
 * Creates the [Functional] model.
 * @property [layers] The layers to describe the model design.
 *
 * NOTE: The first layer should be the input layer.
 *
 * @return the [Functional] model.
 */


@ JvmStatic <EOL> public fun loadModelConfiguration ( configuration : File , inputShape : IntArray ? = null ) : Functional

{ <EOL> require ( configuration . isFile ) { "<STR_LIT>" } <EOL> return loadFunctionalModelConfiguration ( configuration , inputShape ) <EOL> }

/**
 * Loads a [Functional] model from json file with model configuration.
 *
 * @param [configuration] File in .json format, containing the [Functional] model.
 * @return Non-compiled and non-trained Functional model.
 */


@ JvmStatic <EOL> public fun loadModelLayersFromConfiguration ( configuration : File , inputShape : IntArray ? = null ) : List < Layer >

{ <EOL> require ( configuration . isFile ) { "<STR_LIT>" } <EOL> val functionalConfig = loadSerializedModel ( configuration ) <EOL> return loadFunctionalModelLayers ( functionalConfig , inputShape ) <EOL> }

/**
 * Loads a [Functional] model layers from json file with model configuration.
 *
 * @param [configuration] File in .json format, containing the [Functional] model.
 * @return List of layers. All connections between the layers are established and form an acyclic directed graph.
 */


@ JvmStatic <EOL> public fun loadDefaultModelConfiguration ( modelDirectory : File , inputShape : IntArray ? = null ) : Functional

{ <EOL> require ( modelDirectory . isDirectory ) { "<STR_LIT>" } <EOL> val configuration = File ( "<STR_LIT>" ) <EOL> if ( ! configuration . exists ( ) ) throw FileNotFoundException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> return loadFunctionalModelConfiguration ( configuration , inputShape ) <EOL> }

/**
 * Loads a [Functional] model from json file with name 'modelConfig.json' with model configuration located in [modelDirectory].
 *
 * @param [modelDirectory] Directory, containing file 'modelConfig.json'.
 * @throws [FileNotFoundException] If 'modelConfig.json' file is not found.
 * @return Non-compiled and non-trained Functional model.
 */


@ JvmStatic <EOL> public fun loadModelLayersFromDefaultConfiguration ( modelDirectory : File , inputShape : IntArray ? = null ) : List < Layer >

{ <EOL> require ( modelDirectory . isDirectory ) { "<STR_LIT>" } <EOL> val configuration = File ( "<STR_LIT>" ) <EOL> if ( ! configuration . exists ( ) ) throw FileNotFoundException ( "<STR_LIT>" + "<STR_LIT>" ) <EOL> val functionalConfig = loadSerializedModel ( configuration ) <EOL> return loadFunctionalModelLayers ( functionalConfig , inputShape ) <EOL> }

/**
 * Loads a [Functional] model layers from json file with name 'modelConfig.json' with model configuration located in [modelDirectory].
 *
 * @param [modelDirectory] Directory, containing file 'modelConfig.json'.
 * @throws [FileNotFoundException] If 'modelConfig.json' file is not found.
 * @return List of layers. All connections between the layers are established and form an acyclic directed graph.
 */


internal fun convertToState ( value : Any ? , irType : IrType ) : State

{ <EOL> return when ( value ) { <EOL> is Proxy -> value . state <EOL> is State -> value <EOL> is Boolean , is Char , is Byte , is Short , is Int , is Long , is String , is Float , is Double , is Array < * > , is ByteArray , <EOL> is CharArray , is ShortArray , is IntArray , is LongArray , is FloatArray , is DoubleArray , is BooleanArray -> Primitive ( value , irType ) <EOL> null -> Primitive . nullStateOfType ( irType ) <EOL> else -> irType . classOrNull ? . owner ? . let { Wrapper ( value , it , this ) } <EOL> ? : Wrapper ( value , this . javaClassToIrClass [ value :: class . java ] ! ! , this ) <EOL> } <EOL> }

/**
 * Convert object from outer world to state
 */


private fun FirNamedFunctionSymbol . shouldBeVisibleAsOverrideOfBuiltInWithErasedValueParameters ( ) : Boolean

{ <EOL> if ( ! name . sameAsBuiltinMethodWithErasedValueParameters ) return false <EOL> val candidatesToOverride = supertypeScopeContext . collectIntersectionResultsForCallables ( name , FirScope :: processFunctionsByName ) <EOL> . flatMap { it . overriddenMembers } <EOL> . filterNot { ( member , _ ) -> <EOL> member . valueParameterSymbols . all { it . resolvedReturnType . lowerBoundIfFlexible ( ) . isAny } <EOL> } . mapNotNull { ( member , scope ) -> <EOL> BuiltinMethodsWithSpecialGenericSignature . getOverriddenBuiltinFunctionWithErasedValueParametersInJava ( member , scope ) <EOL> } <EOL> val jvmDescriptor = fir . computeJvmDescriptor ( ) <EOL> return candidatesToOverride . any { candidate -> <EOL> candidate . fir . computeJvmDescriptor ( ) == jvmDescriptor && this . hasErasedParameters ( ) <EOL> } <EOL> }

/**
 * Checks if function is a valid override of JDK analogue of built-in method with erased value parameters (e.g. Map.containsKey(k: K))
 *
 * Examples:
 * - boolean containsKey(Object key) -> true
 * - boolean containsKey(K key) -> false // Wrong JDK method override, while it's a valid Kotlin built-in override
 *
 * There is a case when we shouldn't hide a function even if it overrides builtin member with value parameter erasure:
 * if substituted kotlin overridden has the same parameters as current java override. Such situation may happen only in
 * case when `Any`/`Object` is used as parameterization of supertype:
 *
 * // java
 * class MySuperMap extends java.util.Map<Object, Object> {
 * @Override
 * public boolean containsKey(Object key) {...}
 *
 * @Override
 * public boolean containsValue(Object key) {...}
 * }
 *
 * In this case, the signature of override, made based on the correct kotlin signature, will be the same (because of { K -> Any, V -> Any }
 * substitution for both functions).
 * And since the list of all such functions is well-known, the only case when this may happen is when value parameter types of kotlin
 * overridden are `Any`
 */


private fun processOverridesForFunctionsWithErasedValueParameter ( name : Name , destination : MutableCollection < FirNamedFunctionSymbol > , resultOfIntersectionWithNaturalName : ResultOfIntersection < FirNamedFunctionSymbol > , explicitlyDeclaredFunctionWithNaturalName : FirNamedFunctionSymbol ? <EOL> ) : Boolean

{ <EOL> val membersFromSupertypesWithScopes = resultOfIntersectionWithNaturalName . overriddenMembers <EOL> val memberFromSupertypeWithValueParametersToBeErased = membersFromSupertypesWithScopes . firstOrNull { ( member , scope ) -> <EOL> BuiltinMethodsWithSpecialGenericSignature . getOverriddenBuiltinFunctionWithErasedValueParametersInJava ( member , scope ) != null <EOL> } ? . member ? : return false <EOL> val unwrappedMemberFromSupertypeWithValueParametersToBeErased = <EOL> memberFromSupertypeWithValueParametersToBeErased . fir . originalForSubstitutionOverride <EOL> ? : memberFromSupertypeWithValueParametersToBeErased . fir <EOL> val functionFromSupertypeWithValueParametersToBeErased = unwrappedMemberFromSupertypeWithValueParametersToBeErased <EOL> . initialSignatureAttr <EOL> ? . symbol as? FirNamedFunctionSymbol <EOL> ? : unwrappedMemberFromSupertypeWithValueParametersToBeErased . symbol <EOL> val explicitlyDeclaredFunctionWithErasedValueParameters = <EOL> declaredMemberScope . getFunctions ( name ) . firstOrNull { declaredFunction -> <EOL> declaredFunction . hasSameJvmDescriptor ( functionFromSupertypeWithValueParametersToBeErased ) && <EOL> declaredFunction . hasErasedParameters ( ) && <EOL> javaOverrideChecker . doesReturnTypesHaveSameKind ( functionFromSupertypeWithValueParametersToBeErased . fir , declaredFunction . fir ) <EOL> } ? : return false <EOL> var allParametersAreAny = true <EOL> val declaredFunctionCopyWithParameterTypesFromSupertype = buildJavaMethodCopy ( explicitlyDeclaredFunctionWithErasedValueParameters . fir as FirJavaMethod ) { <EOL> this . name = name <EOL> symbol = FirNamedFunctionSymbol ( explicitlyDeclaredFunctionWithErasedValueParameters . callableId ) <EOL> this . valueParameters . clear ( ) <EOL> explicitlyDeclaredFunctionWithErasedValueParameters . fir . valueParameters . zip ( memberFromSupertypeWithValueParametersToBeErased . fir . valueParameters ) . mapTo ( this . valueParameters ) { ( overrideParameter , parameterFromSupertype ) -> <EOL> if ( ! parameterFromSupertype . returnTypeRef . coneType . lowerBoundIfFlexible ( ) . isAny ) { <EOL> allParametersAreAny = false <EOL> } <EOL> buildJavaValueParameterCopy ( overrideParameter ) { <EOL> this@buildJavaValueParameterCopy . returnTypeRef = parameterFromSupertype . returnTypeRef <EOL> } <EOL> } <EOL> } . apply { <EOL> initialSignatureAttr = explicitlyDeclaredFunctionWithErasedValueParameters . fir <EOL> } . symbol <EOL> if ( allParametersAreAny ) { <EOL> return false <EOL> } <EOL> val accidentalOverrideWithDeclaredFunction = explicitlyDeclaredFunctionWithNaturalName ? . takeIf { <EOL> overrideChecker . isOverriddenFunction ( declaredFunctionCopyWithParameterTypesFromSupertype , it ) <EOL> } <EOL> val symbolToBeCollected = if ( accidentalOverrideWithDeclaredFunction == null ) { <EOL> declaredFunctionCopyWithParameterTypesFromSupertype <EOL> } else { <EOL> val newSymbol = FirNamedFunctionSymbol ( accidentalOverrideWithDeclaredFunction . callableId ) <EOL> val original = accidentalOverrideWithDeclaredFunction . fir <EOL> val accidentalOverrideWithDeclaredFunctionHiddenCopy = buildSimpleFunctionCopy ( original ) { <EOL> this . name = name <EOL> symbol = newSymbol <EOL> dispatchReceiverType = klass . defaultType ( ) <EOL> } . apply { <EOL> initialSignatureAttr = explicitlyDeclaredFunctionWithErasedValueParameters . fir <EOL> isHiddenToOvercomeSignatureClash = true <EOL> } <EOL> accidentalOverrideWithDeclaredFunctionHiddenCopy . symbol <EOL> } <EOL> destination += symbolToBeCollected <EOL> directOverriddenFunctions [ symbolToBeCollected ] = listOf ( resultOfIntersectionWithNaturalName ) <EOL> for ( ( member , _ ) in membersFromSupertypesWithScopes ) { <EOL> overrideByBase [ member ] = symbolToBeCollected <EOL> } <EOL> return true <EOL> }

/**
 * This function collects in [destination] an overriding method for base method group [resultOfIntersectionWithNaturalName],
 * in case base methods should have their value parameters erased in Java,
 * e.g. Collection.contains(T) in Kotlin is paired with Collection.contains(Object) in Java.
 *
 * Given we have a Java class [klass] and some its method(s) name [name]
 * with base method group [resultOfIntersectionWithNaturalName] and (maybe)
 * explicitly declared [explicitlyDeclaredFunctionWithNaturalName],
 * this function builds a synthetic override for [resultOfIntersectionWithNaturalName] in the Java class,
 * binds it with this intersection result using the override relation,
 * and collects it as a matching method with this name.
 *
 * Important: all explicitly declared functions are already collected at this point, there is no reason to collect them once more!
 *
 * @param name a given method name
 * @param destination used to collect base functions for [explicitlyDeclaredFunctionWithNaturalName] with erased value parameters in Java
 * @param resultOfIntersectionWithNaturalName one group of intersected base methods, each "overridden member" inside is a pair of (base method, its scope)
 * @param explicitlyDeclaredFunctionWithNaturalName the function in the Java class [klass] with the name [name], which overrides [resultOfIntersectionWithNaturalName] (if any)
 * @return true if we collected something, false otherwise
 * @see [SpecialGenericSignatures.GENERIC_PARAMETERS_METHODS_TO_DEFAULT_VALUES_MAP] and
 * [SpecialGenericSignatures.ERASED_COLLECTION_PARAMETER_NAME_AND_SIGNATURES]
 */


private fun processOverridesForFunctionsWithDifferentJvmName ( someSymbolWithNaturalNameFromSuperType : FirNamedFunctionSymbol , explicitlyDeclaredFunctionWithNaturalName : FirNamedFunctionSymbol ? , naturalName : Name , resultOfIntersectionWithNaturalName : ResultOfIntersection < FirNamedFunctionSymbol > , destination : MutableCollection < FirNamedFunctionSymbol > , functionsFromSupertypesToSaveInCache : MutableList < ResultOfIntersection < FirNamedFunctionSymbol > > ) : Boolean

{ <EOL> val jvmName = resultOfIntersectionWithNaturalName . overriddenMembers . firstNotNullOfOrNull { <EOL> it . member . getJvmMethodNameIfSpecial ( it . baseScope , session ) <EOL> } ? : return false <EOL> val ( intersectedOverridingRenamedBuiltin , intersectedOverridingNonBuiltin ) = <EOL> resultOfIntersectionWithNaturalName . overriddenMembers . partition { <EOL> it . member . getJvmMethodNameIfSpecial ( it . baseScope , session ) == jvmName <EOL> } <EOL> val explicitlyDeclaredFunctionWithBuiltinJvmName = declaredMemberScope . getFunctions ( jvmName ) . firstOrNull { <EOL> overrideChecker . isOverriddenFunction ( it , someSymbolWithNaturalNameFromSuperType ) <EOL> } <EOL> val functionsFromSupertypesWithBuiltinJvmName = supertypeScopeContext . collectFunctions ( jvmName ) . firstOrNull { <EOL> overrideChecker . similarFunctionsOrBothProperties ( it . extractSomeSymbolFromSuperType ( ) , someSymbolWithNaturalNameFromSuperType ) <EOL> } <EOL> fun createCopyWithNaturalName ( originalSymbol : FirNamedFunctionSymbol , isHidden : Boolean = false , origin : FirDeclarationOrigin ? = null , ) : FirNamedFunctionSymbol { <EOL> val original = originalSymbol . fir <EOL> val newSymbol = FirNamedFunctionSymbol ( originalSymbol . callableId . copy ( callableName = naturalName ) ) <EOL> return if ( original is FirJavaMethod ) { <EOL> buildJavaMethodCopy ( original ) { <EOL> name = naturalName <EOL> symbol = newSymbol <EOL> dispatchReceiverType = klass . defaultType ( ) <EOL> status = original . status . copy ( isOperator = true ) <EOL> } <EOL> } else { <EOL> buildSimpleFunctionCopy ( original ) { <EOL> name = naturalName <EOL> symbol = newSymbol <EOL> dispatchReceiverType = klass . defaultType ( ) <EOL> origin ? . let { this . origin = it } <EOL> } <EOL> } . apply { <EOL> initialSignatureAttr = original <EOL> if ( isHidden ) { <EOL> isHiddenToOvercomeSignatureClash = true <EOL> } <EOL> } . symbol <EOL> } <EOL> val resultsOfIntersectionWithNaturalNameOrRenamed = when { <EOL> functionsFromSupertypesWithBuiltinJvmName != null -> { <EOL> val membersByScope = buildList { <EOL> intersectedOverridingRenamedBuiltin . mapTo ( this ) { it . baseScope to listOf ( it . member ) } <EOL> addAll ( functionsFromSupertypesWithBuiltinJvmName . overriddenMembers . map { <EOL> val renamedFunction = createCopyWithNaturalName ( it . member , origin = FirDeclarationOrigin . RenamedForOverride ) <EOL> it . baseScope to listOf ( renamedFunction ) <EOL> } ) <EOL> } <EOL> supertypeScopeContext . convertGroupedCallablesToIntersectionResults ( membersByScope ) <EOL> } <EOL> else -> { <EOL> if ( intersectedOverridingNonBuiltin . isEmpty ( ) ) listOf ( resultOfIntersectionWithNaturalName ) <EOL> else supertypeScopeContext . convertGroupedCallablesToIntersectionResults ( intersectedOverridingRenamedBuiltin . map { it . baseScope to listOf ( it . member ) } ) <EOL> } <EOL> } <EOL> val functionWithNaturalNameExists = explicitlyDeclaredFunctionWithNaturalName != null || <EOL> intersectedOverridingNonBuiltin . isNotEmpty ( ) <EOL> if ( explicitlyDeclaredFunctionWithBuiltinJvmName != null ) { <EOL> val renamedFunction = createCopyWithNaturalName ( explicitlyDeclaredFunctionWithBuiltinJvmName , isHidden = functionWithNaturalNameExists ) <EOL> destination += renamedFunction <EOL> setOverrides ( renamedFunction , resultsOfIntersectionWithNaturalNameOrRenamed ) <EOL> } <EOL> if ( functionWithNaturalNameExists ) { <EOL> val resultOfIntersectionOfOverridingNonBuiltin = supertypeScopeContext . convertGroupedCallablesToIntersectionResults ( intersectedOverridingNonBuiltin . map { it . baseScope to listOf ( it . member ) } ) <EOL> if ( explicitlyDeclaredFunctionWithNaturalName != null ) { <EOL> setOverrides ( explicitlyDeclaredFunctionWithNaturalName , when { <EOL> explicitlyDeclaredFunctionWithBuiltinJvmName == null -> resultsOfIntersectionWithNaturalNameOrRenamed <EOL> else -> resultOfIntersectionOfOverridingNonBuiltin <EOL> } ) <EOL> } else { <EOL> val intersectionOfNaturalName = resultOfIntersectionOfOverridingNonBuiltin . single ( ) <EOL> destination += intersectionOfNaturalName . chosenSymbol <EOL> if ( intersectionOfNaturalName is ResultOfIntersection . NonTrivial ) { <EOL> setOverrides ( intersectionOfNaturalName . chosenSymbol , resultOfIntersectionOfOverridingNonBuiltin ) <EOL> } <EOL> } <EOL> } else if ( explicitlyDeclaredFunctionWithBuiltinJvmName == null ) { <EOL> for ( resultOfIntersection in resultsOfIntersectionWithNaturalNameOrRenamed ) { <EOL> destination += resultOfIntersection . chosenSymbol <EOL> } <EOL> functionsFromSupertypesToSaveInCache += resultsOfIntersectionWithNaturalNameOrRenamed <EOL> } <EOL> return true <EOL> }

/**
 * This function collects in [destination] an overriding method for base method group [resultOfIntersectionWithNaturalName],
 * in case base methods should have its name changed in Java,
 * e.g. MutableList.removeAt(Int) in Kotlin is paired with List.remove(int) in Java.
 *
 * Given we have a Java class [klass] and some its method(s) name mapped to [naturalName] in Kotlin
 * with base method group [resultOfIntersectionWithNaturalName] and (maybe)
 * explicitly declared [explicitlyDeclaredFunctionWithNaturalName],
 * this function builds a synthetic override for [resultOfIntersectionWithNaturalName] in the Java class,
 * binds it with this intersection result using the override relation,
 * and collects it as a matching method with this [naturalName].
 *
 * Important: all explicitly declared functions are already collected at this point, there is no reason to collect them once more!
 *
 * @param naturalName the Kotlin name of the function, e.g., toByte, get, removeAt
 * @param destination used to collect base functions for [explicitlyDeclaredFunctionWithNaturalName] with erased value parameters in Java
 * @param resultOfIntersectionWithNaturalName one group of intersected base methods, each "overridden member" inside is a pair of (base method, its scope)
 * @param someSymbolWithNaturalNameFromSuperType unwrapped symbol taken from [resultOfIntersectionWithNaturalName]
 * @param explicitlyDeclaredFunctionWithNaturalName the function in the Java class [klass] with the name [naturalName], which overrides [resultOfIntersectionWithNaturalName] (if any)
 * @return true if we collected something, false otherwise
 * @see [SpecialGenericSignatures.NAME_AND_SIGNATURE_TO_JVM_REPRESENTATION_NAME_MAP] and
 * [SpecialGenericSignatures.JVM_SIGNATURES_FOR_RENAMED_BUILT_INS]
 */


private fun FirRegularClass . hasKotlinSuper ( session : FirSession , visited : MutableSet < FirRegularClass > = mutableSetOf ( ) ) : Boolean

= <EOL> when { <EOL> ! visited . add ( this ) -> false <EOL> this is FirJavaClass -> superConeTypes . any { type -> <EOL> type . toFir ( session ) ? . hasKotlinSuper ( session , visited ) == true <EOL> } <EOL> isInterface || origin == FirDeclarationOrigin . BuiltIns -> false <EOL> else -> true <EOL> }

/**
 * Checks if class has any kotlin super-types apart from builtins and interfaces
 */


private fun Frame < BasicValue > . getUninitializedValueForConstructorCall ( insn : AbstractInsnNode ) : UninitializedNewValue ?

{ <EOL> if ( ! insn . isConstructorCall ( ) ) return null <EOL> assert ( insn . opcode == Opcodes . INVOKESPECIAL ) { "<STR_LIT>" } <EOL> val paramsCountIncludingReceiver = Type . getArgumentTypes ( ( insn as MethodInsnNode ) . desc ) . size + <NUM_LIT:1> <EOL> val newValue = peek ( paramsCountIncludingReceiver ) as? UninitializedNewValue <EOL> ? : if ( isInSpecialMethod ) <EOL> return null <EOL> else <EOL> error ( "<STR_LIT>" ) <EOL> assert ( peek ( paramsCountIncludingReceiver - <NUM_LIT:1> ) is UninitializedNewValue ) { <EOL> "<STR_LIT>" <EOL> } <EOL> return newValue <EOL> }

/**
 * @return value generated by NEW that used as 0-th argument of constructor call or null if current instruction is not constructor call
 */


@ Test <EOL> fun testRenameFileFacade ( )

{ <EOL> val changes = computeClasspathChanges ( File ( testDataDir , "<STR_LIT>" ) , tmpDir ) <EOL> Changes ( lookupSymbols = setOf ( LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , ) , fqNames = setOf ( "<STR_LIT>" ) ) . assertEquals ( changes ) <EOL> }


@ Test <EOL> fun testChangedAnnotations ( )

{ <EOL> val changes = computeClasspathChanges ( File ( testDataDir , "<STR_LIT>" ) , tmpDir ) <EOL> Changes ( lookupSymbols = setOf ( LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , ) , fqNames = setOf ( "<STR_LIT>" , ) ) . assertEquals ( changes ) <EOL> }


@ Test <EOL> fun testDelegatedProperties ( )

{ <EOL> val changes = computeClasspathChanges ( File ( testDataDir , "<STR_LIT>" ) , tmpDir ) <EOL> Changes ( lookupSymbols = setOf ( LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , ) , fqNames = setOf ( "<STR_LIT>" ) ) . assertEquals ( changes ) <EOL> }


@ Test <EOL> override fun testImpactComputation_SupertypesInheritors ( )

{ <EOL> val changes = computeClasspathChanges ( File ( testDataDir , "<STR_LIT>" ) , tmpDir ) <EOL> Changes ( lookupSymbols = setOf ( LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = SAM_LOOKUP_NAME . asString ( ) , scope = "<STR_LIT>" ) , LookupSymbol ( name = SAM_LOOKUP_NAME . asString ( ) , scope = "<STR_LIT>" ) , LookupSymbol ( name = SAM_LOOKUP_NAME . asString ( ) , scope = "<STR_LIT>" ) ) , fqNames = setOf ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) . assertEquals ( changes ) <EOL> }

/** Tests [SupertypesInheritorsImpact]. */


@ Test <EOL> fun testImpactComputation_ConstantsInCompanionObjects ( )

{ <EOL> val changes = computeClasspathChanges ( File ( testDataDir , "<STR_LIT>" ) , tmpDir ) <EOL> Changes ( lookupSymbols = setOf ( LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , LookupSymbol ( name = SAM_LOOKUP_NAME . asString ( ) , scope = "<STR_LIT>" ) , LookupSymbol ( name = "<STR_LIT>" , scope = "<STR_LIT>" ) , ) , fqNames = setOf ( "<STR_LIT>" , "<STR_LIT>" ) ) . assertEquals ( changes ) <EOL> }

/**
 * Tests [ConstantsInCompanionObjectsImpact].
 *
 * Note that this test is slightly different from [testConstantsAndInlineFunctions]: In [testConstantsAndInlineFunctions], the companion
 * object's .class file changes, whereas in this test, the companion object's .class file does not change because we want to test that
 * the companion object is unchanged but *impacted* by the change in the .class file of the companion object's outer class.
 */


fun ScriptCompilationConfiguration ? . with ( body : ScriptCompilationConfiguration . Builder . ( ) -> Unit ) : ScriptCompilationConfiguration

{ <EOL> val newConfiguration = <EOL> if ( this == null ) ScriptCompilationConfiguration ( body = body ) <EOL> else ScriptCompilationConfiguration ( this , body = body ) <EOL> return if ( newConfiguration == this ) this else newConfiguration <EOL> }

/**
 * An alternative to the constructor with base configuration, which returns a new configuration only if [body] adds anything
 * to the original one, otherwise returns original
 */


fun beforeParsing ( handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> ScriptCompilationConfiguration . refineConfigurationBeforeParsing . append ( RefineConfigurationUnconditionallyData ( handler ) ) <EOL> }

/**
 * The callback that will be called on the script compilation before parsing the script
 * @param handler the callback that will be called
 */


fun onAnnotations ( annotations : List < KotlinType > , handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> ScriptCompilationConfiguration . refineConfigurationOnAnnotations . append ( RefineConfigurationOnAnnotationsData ( annotations , handler ) ) <EOL> }

/**
 * The callback that will be called on the script compilation after parsing script file annotations
 * @param annotations the list of annotations to trigger the callback on
 * @param handler the callback that will be called
 */


fun onAnnotations ( vararg annotations : KotlinType , handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> onAnnotations ( annotations . asList ( ) , handler ) <EOL> }


inline fun < reified T : Annotation > onAnnotations ( noinline handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> onAnnotations ( listOf ( KotlinType ( T :: class ) ) , handler ) <EOL> }

/**
 * The callback that will be called on the script compilation after parsing script file annotations
 * @param T the annotation to trigger the callback on
 * @param handler the callback that will be called
 */


fun onAnnotations ( vararg annotations : KClass < out Annotation > , handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> onAnnotations ( annotations . map { KotlinType ( it ) } , handler ) <EOL> }


fun onAnnotations ( annotations : Iterable < KClass < out Annotation > > , handler : RefineScriptCompilationConfigurationHandler )


fun beforeCompiling ( handler : RefineScriptCompilationConfigurationHandler )

{ <EOL> ScriptCompilationConfiguration . refineConfigurationBeforeCompiling . append ( RefineConfigurationUnconditionallyData ( handler ) ) <EOL> }

/**
 * The callback that will be called on the script compilation immediately before starting the compilation
 * @param handler the callback that will be called
 */


suspend operator fun invoke ( script : SourceCode , scriptCompilationConfiguration : ScriptCompilationConfiguration ) : ResultWithDiagnostics < CompiledScript >

/**
 * Compiles the [script] according to the [scriptCompilationConfiguration]
 * @param script the interface to the script source code
 * @param scriptCompilationConfiguration the script compilation configuration properties
 * @return result wrapper, if successful - with compiled script
 */


suspend fun getClass ( scriptEvaluationConfiguration : ScriptEvaluationConfiguration ? ) : ResultWithDiagnostics < KClass < * > >

/**
 * The function that loads compiled script class
 * @param scriptEvaluationConfiguration the script evaluation configuration properties
 * @return result wrapper, if successful - with loaded KClass
 */


internal fun fromJsonListAnyColumns ( records : List < * > , keyValuePaths : List < JsonPath > = emptyList ( ) , header : List < String > = emptyList ( ) , jsonPath : JsonPath = JsonPath ( ) , ) : AnyFrame

{ <EOL> var hasPrimitive = false <EOL> var hasArray = false <EOL> var hasObject = false <EOL> val nameGenerator = ColumnNameGenerator ( ) <EOL> records . forEach { <EOL> when ( it ) { <EOL> is JsonObject -> { <EOL> hasObject = true <EOL> it . entries . forEach { <EOL> nameGenerator . addIfAbsent ( it . key ) <EOL> } <EOL> } <EOL> is JsonArray < * > -> hasArray = true <EOL> null -> Unit <EOL> else -> hasPrimitive = true <EOL> } <EOL> } <EOL> val colType = when { <EOL> hasArray && ! hasPrimitive && ! hasObject -> AnyColType . ARRAYS <EOL> hasObject && ! hasPrimitive && ! hasArray -> AnyColType . OBJECTS <EOL> else -> AnyColType . ANY <EOL> } <EOL> val justPrimitives = hasPrimitive && ! hasArray && ! hasObject <EOL> val isKeyValue = keyValuePaths . any { jsonPath . matches ( it ) } <EOL> if ( isKeyValue && colType != AnyColType . OBJECTS ) { <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> val columns : List < AnyCol > = when { <EOL> colType == AnyColType . ANY -> { <EOL> val collector : DataCollectorBase < Any ? > = <EOL> if ( justPrimitives ) createDataCollector ( records . size ) <EOL> else createDataCollector ( records . size , typeOf < Any ? > ( ) ) <EOL> val nanIndices = mutableListOf < Int > ( ) <EOL> records . forEachIndexed { i , v -> <EOL> when ( v ) { <EOL> is JsonObject -> { <EOL> val parsed = <EOL> fromJsonListAnyColumns ( records = listOf ( v ) , keyValuePaths = keyValuePaths , jsonPath = jsonPath . replaceLastWildcardWithIndex ( i ) , ) <EOL> collector . add ( if ( parsed . isSingleUnnamedColumn ( ) ) ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . values . first ( ) else parsed . firstOrNull ( ) ? : DataRow . empty ) <EOL> } <EOL> is JsonArray < * > -> { <EOL> val parsed = fromJsonListAnyColumns ( records = v , keyValuePaths = keyValuePaths , jsonPath = jsonPath . replaceLastWildcardWithIndex ( i ) . appendArrayWithWildcard ( ) , ) <EOL> collector . add ( if ( parsed . isSingleUnnamedColumn ( ) ) ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . values . asList ( ) else parsed . unwrapUnnamedColumns ( ) ) <EOL> } <EOL> "<STR_LIT>" -> { <EOL> nanIndices . add ( i ) <EOL> collector . add ( null ) <EOL> } <EOL> else -> collector . add ( v ) <EOL> } <EOL> } <EOL> val column = collector . toColumn ( valueColumnName ) <EOL> val res = if ( nanIndices . isNotEmpty ( ) ) { <EOL> fun < C > DataColumn < C > . updateNaNs ( nanValue : C ) : DataColumn < C > { <EOL> var j = <NUM_LIT:0> <EOL> var nextNanIndex = nanIndices [ j ] <EOL> return mapIndexed ( column . type ) { i , v -> <EOL> if ( i == nextNanIndex ) { <EOL> j ++ <EOL> nextNanIndex = if ( j < nanIndices . size ) nanIndices [ j ] else - <NUM_LIT:1> <EOL> nanValue <EOL> } else v <EOL> } <EOL> } <EOL> when ( column . typeClass ) { <EOL> Double :: class -> column . cast < Double ? > ( ) . updateNaNs ( Double . NaN ) <EOL> Float :: class -> column . cast < Float ? > ( ) . updateNaNs ( Float . NaN ) <EOL> String :: class -> column . cast < String ? > ( ) . updateNaNs ( "<STR_LIT>" ) <EOL> else -> column <EOL> } <EOL> } else column <EOL> listOf ( UnnamedColumn ( res ) ) <EOL> } <EOL> colType == AnyColType . ARRAYS -> { <EOL> val values = mutableListOf < Any ? > ( ) <EOL> val startIndices = ArrayList < Int > ( ) <EOL> records . forEach { <EOL> startIndices . add ( values . size ) <EOL> when ( it ) { <EOL> is JsonArray < * > -> values . addAll ( it . value ) <EOL> null -> Unit <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val parsed = fromJsonListAnyColumns ( records = values , keyValuePaths = keyValuePaths , jsonPath = jsonPath . appendArrayWithWildcard ( ) , ) <EOL> val res = when { <EOL> parsed . isSingleUnnamedColumn ( ) -> { <EOL> val col = ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col <EOL> val elementType = col . type <EOL> val values = col . values . asList ( ) . splitByIndices ( startIndices . asSequence ( ) ) . toList ( ) <EOL> DataColumn . createValueColumn ( name = arrayColumnName , values = values , type = List :: class . createType ( listOf ( KTypeProjection . invariant ( elementType ) ) ) , ) <EOL> } <EOL> else -> DataColumn . createFrameColumn ( name = arrayColumnName , df = parsed . unwrapUnnamedColumns ( ) , startIndices = startIndices , ) <EOL> } <EOL> listOf ( UnnamedColumn ( res ) ) <EOL> } <EOL> colType == AnyColType . OBJECTS && isKeyValue -> { <EOL> val valueTypes = mutableSetOf < KType > ( ) <EOL> val dataFrames = records . map { <EOL> when ( it ) { <EOL> is JsonObject -> { <EOL> val map = it . map . mapValues { ( key , value ) -> <EOL> val parsed = fromJsonListAnyColumns ( records = listOf ( value ) , keyValuePaths = keyValuePaths , jsonPath = jsonPath . append ( key ) , ) <EOL> if ( parsed . isSingleUnnamedColumn ( ) ) ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . values . first ( ) <EOL> else parsed . unwrapUnnamedColumns ( ) . firstOrNull ( ) <EOL> } <EOL> val valueType = map . values . map { <EOL> guessValueType ( sequenceOf ( it ) ) <EOL> } . commonType ( ) <EOL> valueTypes += valueType <EOL> dataFrameOf ( columnOf ( * map . keys . toTypedArray ( ) ) . named ( KeyValueProperty < * > :: key . name ) , createColumn ( values = map . values , suggestedType = valueType , guessType = false ) . named ( KeyValueProperty < * > :: value . name ) , ) <EOL> } <EOL> null -> DataFrame . emptyOf < AnyKeyValueProperty > ( ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val valueColumns = dataFrames . map { it [ KeyValueProperty < * > :: value . name ] } <EOL> val valueColumnSchema = when { <EOL> valueColumns . all { it is ColumnGroup < * > } || valueColumns . all { it is FrameColumn < * > } -> <EOL> valueColumns . concat ( ) . extractSchema ( ) <EOL> else -> ColumnSchema . Value ( valueTypes . commonType ( ) ) <EOL> } <EOL> listOf ( UnnamedColumn ( DataColumn . createFrameColumn ( name = valueColumnName , groups = dataFrames , schema = lazy { <EOL> DataFrameSchemaImpl ( columns = mapOf ( KeyValueProperty < * > :: key . name to ColumnSchema . Value ( typeOf < String > ( ) ) , KeyValueProperty < * > :: value . name to valueColumnSchema , ) ) <EOL> } , ) ) ) <EOL> } <EOL> colType == AnyColType . OBJECTS && ! isKeyValue -> { <EOL> nameGenerator . names . map { colName -> <EOL> val values = ArrayList < Any ? > ( records . size ) <EOL> records . forEach { <EOL> when ( it ) { <EOL> is JsonObject -> values . add ( it [ colName ] ) <EOL> null -> values . add ( null ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> val parsed = fromJsonListAnyColumns ( records = values , keyValuePaths = keyValuePaths , jsonPath = jsonPath . append ( colName ) , ) <EOL> when { <EOL> parsed . ncol == <NUM_LIT:0> -> <EOL> DataColumn . createValueColumn ( name = colName , values = arrayOfNulls < Any ? > ( values . size ) . toList ( ) , type = typeOf < Any ? > ( ) , ) <EOL> parsed . isSingleUnnamedColumn ( ) -> <EOL> ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . rename ( colName ) <EOL> else -> <EOL> DataColumn . createColumnGroup ( colName , parsed . unwrapUnnamedColumns ( ) ) as AnyCol <EOL> } <EOL> } <EOL> } <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> return when { <EOL> columns . isEmpty ( ) -> DataFrame . empty ( records . size ) <EOL> columns . size == <NUM_LIT:1> && hasArray && header . isNotEmpty ( ) && columns [ <NUM_LIT:0> ] . typeClass == List :: class -> <EOL> columns [ <NUM_LIT:0> ] <EOL> . cast < List < * > > ( ) <EOL> . splitInto ( * header . toTypedArray ( ) ) <EOL> else -> columns . toDataFrame ( ) <EOL> } <EOL> }

/**
 * Json to DataFrame converter that creates [Any] columns.
 * A.k.a. [TypeClashTactic.ANY_COLUMNS].
 *
 * @param records List of json elements to be converted to a [DataFrame].
 * @param keyValuePaths List of [JsonPath]s where instead of a [ColumnGroup], a [FrameColumn]<[KeyValueProperty]>
 * will be created.
 * @param header Optional list of column names. If given, [records] will be read like an object with [header] being the keys.
 * @return [DataFrame] from the given [records].
 */


internal fun fromJsonListArrayAndValueColumns ( records : List < * > , keyValuePaths : List < JsonPath > = emptyList ( ) , header : List < String > = emptyList ( ) , jsonPath : JsonPath = JsonPath ( ) , ) : AnyFrame

{ <EOL> var hasPrimitive = false <EOL> var hasArray = false <EOL> val isKeyValue = keyValuePaths . any { jsonPath . matches ( it ) } <EOL> val nameGenerator = ColumnNameGenerator ( ) <EOL> records . forEach { <EOL> when ( it ) { <EOL> is JsonObject -> it . entries . forEach { <EOL> nameGenerator . addIfAbsent ( it . key ) <EOL> } <EOL> is JsonArray < * > -> hasArray = true <EOL> null -> Unit <EOL> else -> hasPrimitive = true <EOL> } <EOL> } <EOL> if ( records . all { it == null } ) hasPrimitive = true <EOL> val valueColumn = if ( hasPrimitive || records . isEmpty ( ) ) { <EOL> nameGenerator . addUnique ( valueColumnName ) <EOL> } else null <EOL> val arrayColumn = if ( hasArray ) { <EOL> nameGenerator . addUnique ( arrayColumnName ) <EOL> } else null <EOL> if ( isKeyValue && ( hasPrimitive || hasArray ) ) { <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> val columns : List < AnyCol > = when { <EOL> isKeyValue -> { <EOL> val dataFrames = records . map { <EOL> when ( it ) { <EOL> is JsonObject -> { <EOL> val map = it . map . mapValues { ( key , value ) -> <EOL> val parsed = fromJsonListArrayAndValueColumns ( records = listOf ( value ) , keyValuePaths = keyValuePaths , jsonPath = jsonPath . append ( key ) , ) <EOL> if ( parsed . isSingleUnnamedColumn ( ) ) ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . values . first ( ) <EOL> else parsed . unwrapUnnamedColumns ( ) . firstOrNull ( ) <EOL> } <EOL> val valueType = <EOL> map . values . map { guessValueType ( sequenceOf ( it ) ) } <EOL> . commonType ( ) <EOL> dataFrameOf ( columnOf ( * map . keys . toTypedArray ( ) ) . named ( KeyValueProperty < * > :: key . name ) , createColumn ( values = map . values , suggestedType = valueType , guessType = false , ) . named ( KeyValueProperty < * > :: value . name ) , ) <EOL> } <EOL> null -> DataFrame . emptyOf < AnyKeyValueProperty > ( ) <EOL> else -> error ( "<STR_LIT>" ) <EOL> } <EOL> } <EOL> listOf ( UnnamedColumn ( DataColumn . createFrameColumn ( name = valueColumnName , groups = dataFrames , schema = lazy { <EOL> dataFrames . mapNotNull { it . takeIf { it . nrow > <NUM_LIT:0> } ? . schema ( ) } . intersectSchemas ( ) <EOL> } , ) ) ) <EOL> } <EOL> else -> <EOL> nameGenerator . names . map { colName -> <EOL> when { <EOL> colName == valueColumn && ( hasPrimitive || records . isEmpty ( ) ) -> { <EOL> val collector = createDataCollector ( records . size ) <EOL> val nanIndices = mutableListOf < Int > ( ) <EOL> records . forEachIndexed { i , v -> <EOL> when ( v ) { <EOL> is JsonObject -> collector . add ( null ) <EOL> is JsonArray < * > -> collector . add ( null ) <EOL> "<STR_LIT>" -> { <EOL> nanIndices . add ( i ) <EOL> collector . add ( null ) <EOL> } <EOL> else -> collector . add ( v ) <EOL> } <EOL> } <EOL> val column = collector . toColumn ( colName ) <EOL> val res = if ( nanIndices . isNotEmpty ( ) ) { <EOL> fun < C > DataColumn < C > . updateNaNs ( nanValue : C ) : DataColumn < C > { <EOL> var j = <NUM_LIT:0> <EOL> var nextNanIndex = nanIndices [ j ] <EOL> return mapIndexed ( column . type ) { i , v -> <EOL> if ( i == nextNanIndex ) { <EOL> j ++ <EOL> nextNanIndex = if ( j < nanIndices . size ) nanIndices [ j ] else - <NUM_LIT:1> <EOL> nanValue <EOL> } else v <EOL> } <EOL> } <EOL> when ( column . typeClass ) { <EOL> Double :: class -> column . cast < Double ? > ( ) . updateNaNs ( Double . NaN ) <EOL> Float :: class -> column . cast < Float ? > ( ) . updateNaNs ( Float . NaN ) <EOL> String :: class -> column . cast < String ? > ( ) . updateNaNs ( "<STR_LIT>" ) <EOL> else -> column <EOL> } <EOL> } else column <EOL> UnnamedColumn ( res ) <EOL> } <EOL> colName == arrayColumn && hasArray -> { <EOL> val values = mutableListOf < Any ? > ( ) <EOL> val startIndices = ArrayList < Int > ( ) <EOL> records . forEach { <EOL> startIndices . add ( values . size ) <EOL> if ( it is JsonArray < * > ) values . addAll ( it . value ) <EOL> } <EOL> val parsed = fromJsonListArrayAndValueColumns ( records = values , keyValuePaths = keyValuePaths , jsonPath = jsonPath . appendArrayWithWildcard ( ) , ) <EOL> val res = when { <EOL> parsed . isSingleUnnamedColumn ( ) -> { <EOL> val col = ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col <EOL> val elementType = col . type <EOL> val values = col . values . asList ( ) . splitByIndices ( startIndices . asSequence ( ) ) . toList ( ) <EOL> DataColumn . createValueColumn ( name = colName , values = values , type = List :: class . createType ( listOf ( KTypeProjection . invariant ( elementType ) ) ) , ) <EOL> } <EOL> else -> DataColumn . createFrameColumn ( colName , parsed . unwrapUnnamedColumns ( ) , startIndices ) <EOL> } <EOL> UnnamedColumn ( res ) <EOL> } <EOL> else -> { <EOL> val values = ArrayList < Any ? > ( records . size ) <EOL> records . forEach { <EOL> when ( it ) { <EOL> is JsonObject -> values . add ( it [ colName ] ) <EOL> else -> values . add ( null ) <EOL> } <EOL> } <EOL> val parsed = fromJsonListArrayAndValueColumns ( records = values , keyValuePaths = keyValuePaths , jsonPath = jsonPath . append ( colName ) , ) <EOL> when { <EOL> parsed . ncol == <NUM_LIT:0> -> <EOL> DataColumn . createValueColumn ( name = colName , values = arrayOfNulls < Any ? > ( values . size ) . toList ( ) , type = typeOf < Any ? > ( ) , ) <EOL> parsed . isSingleUnnamedColumn ( ) -> <EOL> ( parsed . getColumn ( <NUM_LIT:0> ) as UnnamedColumn ) . col . rename ( colName ) <EOL> else -> <EOL> DataColumn . createColumnGroup ( colName , parsed . unwrapUnnamedColumns ( ) ) as AnyCol <EOL> } <EOL> } <EOL> } <EOL> } <EOL> } <EOL> return when { <EOL> columns . isEmpty ( ) -> <EOL> DataFrame . empty ( records . size ) <EOL> columns . size == <NUM_LIT:1> && hasArray && header . isNotEmpty ( ) && columns [ <NUM_LIT:0> ] . typeClass == List :: class -> <EOL> columns [ <NUM_LIT:0> ] <EOL> . cast < List < * > > ( ) <EOL> . splitInto ( * header . toTypedArray ( ) ) <EOL> else -> <EOL> columns . toDataFrame ( ) <EOL> } <EOL> }

/**
 * Json to DataFrame converter that creates allows creates `value` and `array` accessors
 * instead of [Any] columns.
 * A.k.a. [TypeClashTactic.ARRAY_AND_VALUE_COLUMNS].
 *
 * @param records List of json elements to be converted to a [DataFrame].
 * @param keyValuePaths List of [JsonPath]s where instead of a [ColumnGroup], a [FrameColumn]<[KeyValueProperty]>
 * will be created.
 * @param header Optional list of column names. If given, [records] will be read like an object with [header] being the keys.
 * @return [DataFrame] from the given [records].
 */


internal fun IrFunction . isCEnumVarValueAccessor ( symbols : KonanSymbols ) : Boolean

{ <EOL> val parent = parent as? IrClass ? : return false <EOL> return if ( symbols . interopCEnumVar in parent . superClasses && isPropertyAccessor ) { <EOL> ( propertyIfAccessor as IrProperty ) . name . asString ( ) == "<STR_LIT:value>" <EOL> } else { <EOL> false <EOL> } <EOL> }

/**
 * Check given function is a getter or setter
 * for `value` property of CEnumVar subclass.
 */


private fun registerDokkatooSourceSets ( dokkatooExtension : DokkatooExtension , sourceSetDetails : NamedDomainObjectContainer < KotlinSourceSetDetails > , )

{ <EOL> sourceSetDetails . all details @ { <EOL> dokkatooExtension . dokkatooSourceSets . register ( details = this @ details ) <EOL> } <EOL> }

/** Register a [DokkaSourceSetSpec] for each element in [sourceSetDetails] */


private fun NamedDomainObjectContainer < DokkaSourceSetSpec > . register ( details : KotlinSourceSetDetails )

{ <EOL> val kssPlatform = details . compilations . map { values : List < KotlinCompilationDetails > -> <EOL> values . map { it . kotlinPlatform } <EOL> . distinct ( ) <EOL> . singleOrNull ( ) ? : KotlinPlatform . Common <EOL> } <EOL> val kssClasspath = determineClasspath ( details ) <EOL> register ( details . name ) dss @ { <EOL> suppress . set ( ! details . isPublishedSourceSet ( ) ) <EOL> sourceRoots . from ( details . sourceDirectories ) <EOL> classpath . from ( kssClasspath ) <EOL> analysisPlatform . set ( kssPlatform ) <EOL> dependentSourceSets . addAllLater ( details . dependentSourceSetIds ) <EOL> } <EOL> }

/** Register a single [DokkaSourceSetSpec] for [details] */


private fun ExtensionContainer . findKotlinExtension ( ) : KotlinProjectExtension ?

= <EOL> try { <EOL> findByType ( ) <EOL> ? : findByType < org . jetbrains . kotlin . gradle . dsl . KotlinJvmProjectExtension > ( ) <EOL> } catch ( e : Throwable ) { <EOL> when ( e ) { <EOL> is TypeNotPresentException , <EOL> is ClassNotFoundException , <EOL> is NoClassDefFoundError -> null <EOL> else -> throw e <EOL> } <EOL> }

/** Try and get [KotlinProjectExtension], or `null` if it's not present */


private fun createCompilationDetails ( compilation : KotlinCompilation < * > , ) : KotlinCompilationDetails

{ <EOL> val allKotlinSourceSetsNames = <EOL> compilation . allKotlinSourceSets . map { it . name } + compilation . defaultSourceSet . name <EOL> val dependentSourceSetNames = <EOL> compilation . defaultSourceSet . dependsOn . map { it . name } <EOL> val compilationClasspath : FileCollection = <EOL> collectKotlinCompilationClasspath ( compilation = compilation ) <EOL> return KotlinCompilationDetails ( target = compilation . target . name , kotlinPlatform = KotlinPlatform . fromString ( compilation . platformType . name ) , allKotlinSourceSetsNames = allKotlinSourceSetsNames . toSet ( ) , publishedCompilation = compilation . isPublished ( ) , dependentSourceSetNames = dependentSourceSetNames . toSet ( ) , compilationClasspath = compilationClasspath , defaultSourceSetName = compilation . defaultSourceSet . name ) <EOL> }

/** Create a single [KotlinCompilationDetails] for [compilation] */


private fun collectKotlinCompilationClasspath ( compilation : KotlinCompilation < * > , ) : FileCollection

{ <EOL> val compilationClasspath = objects . fileCollection ( ) <EOL> compilationClasspath . from ( providers . provider { compilation . compileDependencyFiles } ) <EOL> if ( currentKotlinToolingVersion < KotlinToolingVersion ( "<STR_LIT>" ) && compilation is AbstractKotlinNativeCompilation ) { <EOL> compilationClasspath . from ( konanHome . map { konanHome -> <EOL> kotlinNativeDependencies ( konanHome , compilation . konanTarget ) <EOL> } ) <EOL> } <EOL> return compilationClasspath <EOL> }

/**
 * Get the [Configuration][org.gradle.api.artifacts.Configuration] names of all configurations
 * used to build this [KotlinCompilation] and
 * [its source sets][KotlinCompilation.kotlinSourceSets].
 */


private fun KotlinCompilation < * > . isPublished ( ) : Boolean

{ <EOL> return when ( this ) { <EOL> is KotlinMetadataCompilation < * > -> true <EOL> is KotlinJvmAndroidCompilation -> <EOL> androidVariant is LibraryVariant || androidVariant is ApplicationVariant <EOL> else -> <EOL> name == MAIN_COMPILATION_NAME <EOL> } <EOL> }

/**
 * Determine if a [KotlinCompilation] is 'publishable', and so should be enabled by default
 * when creating a Dokka publication.
 *
 * Typically, 'main' compilations are publishable and 'test' compilations should be suppressed.
 * This can be overridden manually, though.
 *
 * @see DokkaSourceSetSpec.suppress
 */


fun isPublishedSourceSet ( ) : Provider < Boolean >

= <EOL> compilations . map { values -> <EOL> values . any { it . publishedCompilation } <EOL> }

/** Estimate if this Kotlin source set contains 'published' sources */


private tailrec fun KotlinSourceSet . allDependentSourceSets ( queue : Set < KotlinSourceSet > = dependsOn . toSet ( ) , allDependents : List < KotlinSourceSet > = emptyList ( ) , ) : List < KotlinSourceSet >

{ <EOL> val next = queue . firstOrNull ( ) ? : return allDependents <EOL> return next . allDependentSourceSets ( queue = ( queue - next ) union next . dependsOn , allDependents = allDependents + next , ) <EOL> }

/**
 * Return a list containing _all_ source sets that this source set depends on,
 * searching recursively.
 *
 * @see KotlinSourceSet.dependsOn
 */


@ Test <EOL> fun testSharedFlowToCollection ( )

= runTest { <EOL> val sharedFlow = MutableSharedFlow < Int > ( ) <EOL> val list = mutableListOf < Int > ( ) <EOL> val set = mutableSetOf < Int > ( ) <EOL> val jobs = listOf ( suspend { sharedFlow . toList ( list ) } , { sharedFlow . toSet ( set ) } ) . map { <EOL> launch ( Dispatchers . Unconfined ) { it ( ) } <EOL> } <EOL> repeat ( <NUM_LIT:10> ) { <EOL> sharedFlow . emit ( it ) <EOL> } <EOL> jobs . forEach { it . cancelAndJoin ( ) } <EOL> assertEquals ( ( <NUM_LIT:0> .. <NUM_LIT:9> ) . toList ( ) , list ) <EOL> assertEquals ( ( <NUM_LIT:0> .. <NUM_LIT:9> ) . toSet ( ) , set ) <EOL> }

/**
 * Tests that using [SharedFlow.toList] and similar functions by passing a mutable collection does add values
 * to the provided collection.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.9>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . append ( value : Byte ) : StringBuilder

= this . append ( value . toInt ( ) )

/**
 * Appends the string representation of the specified byte [value] to this string builder and returns this instance.
 *
 * The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
 * and then that string was appended to this string builder.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.9>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . append ( value : Short ) : StringBuilder

= this . append ( value . toInt ( ) )

/**
 * Appends the string representation of the specified short [value] to this string builder and returns this instance.
 *
 * The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
 * and then that string was appended to this string builder.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.9>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . insert ( index : Int , value : Byte ) : StringBuilder

= this . insert ( index , value . toInt ( ) )

/**
 * Inserts the string representation of the specified byte [value] into this string builder at the specified [index] and returns this instance.
 *
 * The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
 * and then that string was inserted into this string builder at the specified [index].
 *
 * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
 */


@ Suppress ( "<STR_LIT>" ) <EOL> @ SinceKotlin ( "<STR_LIT:1.9>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . insert ( index : Int , value : Short ) : StringBuilder

/**
 * Inserts the string representation of the specified short [value] into this string builder at the specified [index] and returns this instance.
 *
 * The overall effect is exactly as if the [value] were converted to a string by the `value.toString()` method,
 * and then that string was inserted into this string builder at the specified [index].
 *
 * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
 */


@ SinceKotlin ( "<STR_LIT:1.3>" ) <EOL> public actual fun StringBuilder . clear ( ) : StringBuilder

= apply { setLength ( <NUM_LIT:0> ) }

/**
 * Clears the content of this string builder making it empty and returns this instance.
 *
 * @sample samples.text.Strings.clearStringBuilder
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline operator fun StringBuilder . set ( index : Int , value : Char ) : Unit

= this . setCharAt ( index , value )

/**
 * Sets the character at the specified [index] to the specified [value].
 *
 * @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . setRange ( startIndex : Int , endIndex : Int , value : String ) : StringBuilder

= <EOL> this . replace ( startIndex , endIndex , value )

/**
 * Replaces characters in the specified range of this string builder with characters in the specified string [value] and returns this instance.
 *
 * @param startIndex the beginning (inclusive) of the range to replace.
 * @param endIndex the end (exclusive) of the range to replace.
 * @param value the string to replace with.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] if [startIndex] is less than zero, greater than the length of this string builder, or `startIndex > endIndex`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . deleteAt ( index : Int ) : StringBuilder

= this . deleteCharAt ( index )

/**
 * Removes the character at the specified [index] from this string builder and returns this instance.
 *
 * If the `Char` at the specified [index] is part of a supplementary code point, this method does not remove the entire supplementary character.
 *
 * @param index the index of `Char` to remove.
 *
 * @throws IndexOutOfBoundsException if [index] is out of bounds of this string builder.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . deleteRange ( startIndex : Int , endIndex : Int ) : StringBuilder

= this . delete ( startIndex , endIndex )

/**
 * Removes characters in the specified range from this string builder and returns this instance.
 *
 * @param startIndex the beginning (inclusive) of the range to remove.
 * @param endIndex the end (exclusive) of the range to remove.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> @ Suppress ( "<STR_LIT:ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS>" ) <EOL> public actual inline fun StringBuilder . toCharArray ( destination : CharArray , destinationOffset : Int = <NUM_LIT:0> , startIndex : Int = <NUM_LIT:0> , endIndex : Int = this . length ) : Unit

= <EOL> this . getChars ( startIndex , endIndex , destination , destinationOffset )

/**
 * Copies characters from this string builder into the [destination] character array.
 *
 * @param destination the array to copy to.
 * @param destinationOffset the position in the array to copy to, 0 by default.
 * @param startIndex the beginning (inclusive) of the range to copy, 0 by default.
 * @param endIndex the end (exclusive) of the range to copy, length of this string builder by default.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of this string builder indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException when the subrange doesn't fit into the [destination] array starting at the specified [destinationOffset],
 * or when that index is out of the [destination] array indices range.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendRange ( value : CharArray , startIndex : Int , endIndex : Int ) : StringBuilder

= <EOL> this . append ( value , startIndex , endIndex - startIndex )

/**
 * Appends characters in a subarray of the specified character array [value] to this string builder and returns this instance.
 *
 * Characters are appended in order, starting at specified [startIndex].
 *
 * @param value the array from which characters are appended.
 * @param startIndex the beginning (inclusive) of the subarray to append.
 * @param endIndex the end (exclusive) of the subarray to append.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendRange ( value : CharSequence , startIndex : Int , endIndex : Int ) : StringBuilder

= <EOL> this . append ( value , startIndex , endIndex )

/**
 * Appends a subsequence of the specified character sequence [value] to this string builder and returns this instance.
 *
 * @param value the character sequence from which a subsequence is appended.
 * @param startIndex the beginning (inclusive) of the subsequence to append.
 * @param endIndex the end (exclusive) of the subsequence to append.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . insertRange ( index : Int , value : CharArray , startIndex : Int , endIndex : Int ) : StringBuilder

= <EOL> this . insert ( index , value , startIndex , endIndex - startIndex )

/**
 * Inserts characters in a subarray of the specified character array [value] into this string builder at the specified [index] and returns this instance.
 *
 * The inserted characters go in same order as in the [value] array, starting at [index].
 *
 * @param index the position in this string builder to insert at.
 * @param value the array from which characters are inserted.
 * @param startIndex the beginning (inclusive) of the subarray to insert.
 * @param endIndex the end (exclusive) of the subarray to insert.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] array indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . insertRange ( index : Int , value : CharSequence , startIndex : Int , endIndex : Int ) : StringBuilder

= <EOL> this . insert ( index , value , startIndex , endIndex )

/**
 * Inserts characters in a subsequence of the specified character sequence [value] into this string builder at the specified [index] and returns this instance.
 *
 * The inserted characters go in the same order as in the [value] character sequence, starting at [index].
 *
 * @param index the position in this string builder to insert at.
 * @param value the character sequence from which a subsequence is inserted.
 * @param startIndex the beginning (inclusive) of the subsequence to insert.
 * @param endIndex the end (exclusive) of the subsequence to insert.
 *
 * @throws IndexOutOfBoundsException or [IllegalArgumentException] when [startIndex] or [endIndex] is out of range of the [value] character sequence indices or when `startIndex > endIndex`.
 * @throws IndexOutOfBoundsException if [index] is less than zero or greater than the length of this string builder.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendLine ( value : StringBuffer ? ) : StringBuilder

= append ( value ) . appendLine ( )

/** Appends [value] to this [StringBuilder], followed by a line feed character (`\n`). */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendLine ( value : StringBuilder ? ) : StringBuilder

= append ( value ) . appendLine ( )


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Int ) : StringBuilder

= append ( value ) . appendLine ( )


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Short ) : StringBuilder

= append ( value . toInt ( ) ) . appendLine ( )


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Byte ) : StringBuilder


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Long ) : StringBuilder

= append ( value ) . appendLine ( )


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Float ) : StringBuilder

= append ( value ) . appendLine ( )


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ kotlin . internal . InlineOnly <EOL> public actual inline fun StringBuilder . appendLine ( value : Double ) : StringBuilder

= append ( value ) . appendLine ( )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> public fun Appendable . appendln ( ) : Appendable

= append ( SystemProperties . LINE_SEPARATOR )

/** Appends a line separator to this Appendable. */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Appendable . appendln ( value : CharSequence ? ) : Appendable

= append ( value ) . appendln ( )

/** Appends value to the given Appendable and line separator after it. */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun Appendable . appendln ( value : Char ) : Appendable

= append ( value ) . appendln ( )


@ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> public fun StringBuilder . appendln ( ) : StringBuilder

/** Appends a line separator to this StringBuilder. */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : StringBuffer ? ) : StringBuilder

= append ( value ) . appendln ( )

/** Appends [value] to this [StringBuilder], followed by a line separator. */


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : CharSequence ? ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : String ? ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Any ? ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : StringBuilder ? ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : CharArray ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Char ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Boolean ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Int ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Short ) : StringBuilder

= append ( value . toInt ( ) ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Byte ) : StringBuilder


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Long ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Float ) : StringBuilder

= append ( value ) . appendln ( )


@ Suppress ( "<STR_LIT:DEPRECATION>" ) <EOL> @ Deprecated ( "<STR_LIT>" , ReplaceWith ( "<STR_LIT>" ) , level = DeprecationLevel . WARNING ) <EOL> @ kotlin . internal . InlineOnly <EOL> public inline fun StringBuilder . appendln ( value : Double ) : StringBuilder

= append ( value ) . appendln ( )


private fun removeNonAccessorsReturning ( fieldAccessors : MutableMap < PsiField , MutableList < PsiMethod > > ) : List < PsiMethod >

{ <EOL> val nonAccessors = mutableListOf < PsiMethod > ( ) <EOL> fieldAccessors . entries . removeIf { ( field , methods ) -> <EOL> if ( methods . size == <NUM_LIT:1> && methods [ <NUM_LIT:0> ] . isSetterFor ( field ) ) { <EOL> nonAccessors . add ( methods [ <NUM_LIT:0> ] ) <EOL> true <EOL> } else { <EOL> false <EOL> } <EOL> } <EOL> return nonAccessors <EOL> }

/**
 * If a field has no getter, it's not accessible as a property from Kotlin's perspective,
 * but it still might have a setter. In this case, this "setter" should be just a regular function
 */


public fun Plot . toHTML ( iFrame : Boolean = true ) : String

= <EOL> PlotHtmlExport . buildHtmlFromRawSpecs ( toLetsPlot ( ) . toSpec ( ) , letsPlotJSUrl , iFrame )

/**
 * Exports the plot to HTML format.
 *
 * @receiver [Plot] - the plot to export.
 * @param iFrame Whether to wrap HTML in IFrame
 *
 * @return A [String] in HTML format representing the exported plot.
 */


public fun PlotGrid . toHTML ( iFrame : Boolean = true ) : String

= <EOL> PlotHtmlExport . buildHtmlFromRawSpecs ( wrap ( ) . toSpec ( ) , letsPlotJSUrl , iFrame )

/**
 * Exports the plot grid to HTML format.
 *
 * @receiver [PlotGrid] - the plot grid to export.
 * @param iFrame Whether to wrap HTML in IFrame
 *
 * @return A [String] in HTML format representing the exported plot.
 */


public fun PlotBunch . toHTML ( iFrame : Boolean = true ) : String

/**
 * Exports the plot bunch to HTML format.
 *
 * @receiver [PlotBunch] - the plot bunch to export.
 * @param iFrame Whether to wrap HTML in IFrame
 *
 * @return A [String] in HTML format representing the exported plot.
 */


public fun < T , C > DataFrame < T > . fillNulls ( columns : ColumnsSelector < T , C ? > ) : Update < T , C ? >

= <EOL> update ( columns ) . where { it == null }

/**
 * @include [CommonFillNullsFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetFillNullsOperationArg]}
 * @include [Update.DslParam]
 */


public fun < T > DataFrame < T > . fillNulls ( vararg columns : String ) : Update < T , Any ? >

= <EOL> fillNulls { columns . toColumnSet ( ) }

/**
 * @include [CommonFillNullsFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetFillNullsOperationArg]}
 * @include [Update.ColumnNamesParam]
 */


public fun < T , C > DataFrame < T > . fillNulls ( vararg columns : KProperty < C > ) : Update < T , C ? >

/**
 * @include [CommonFillNullsFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNullsOperationArg]}
 * @include [Update.KPropertiesParam]
 */


public fun < T , C > DataFrame < T > . fillNulls ( vararg columns : ColumnReference < C > ) : Update < T , C ? >

/**
 * @include [CommonFillNullsFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetFillNullsOperationArg]}
 * @include [Update.ColumnAccessorsParam]
 */


public fun < T , C > DataFrame < T > . fillNaNs ( columns : ColumnsSelector < T , C > ) : Update < T , C >

= <EOL> update ( columns ) . where { it . isNaN }

/**
 * @include [CommonFillNaNsFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetFillNaNsOperationArg]}
 * @include [Update.DslParam]
 */


public fun < T > DataFrame < T > . fillNaNs ( vararg columns : String ) : Update < T , Any ? >

= <EOL> fillNaNs { columns . toColumnSet ( ) }

/**
 * @include [CommonFillNaNsFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetFillNaNsOperationArg]}
 * @include [Update.ColumnNamesParam]
 */


public fun < T , C > DataFrame < T > . fillNaNs ( vararg columns : KProperty < C > ) : Update < T , C >

/**
 * @include [CommonFillNaNsFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNaNsOperationArg]}
 * @include [Update.KPropertiesParam]
 */


public fun < T , C > DataFrame < T > . fillNaNs ( vararg columns : ColumnReference < C > ) : Update < T , C >

/**
 * @include [CommonFillNaNsFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetFillNaNsOperationArg]}
 * @include [Update.ColumnAccessorsParam]
 */


public fun < T , C > DataFrame < T > . fillNA ( columns : ColumnsSelector < T , C ? > ) : Update < T , C ? >

= <EOL> update ( columns ) . where { it . isNA }

/**
 * @include [CommonFillNAFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetFillNAOperationArg]}
 * @include [Update.DslParam]
 */


public fun < T > DataFrame < T > . fillNA ( vararg columns : String ) : Update < T , Any ? >

= <EOL> fillNA { columns . toColumnSet ( ) }

/**
 * @include [CommonFillNAFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetFillNAOperationArg]}
 * @include [Update.ColumnNamesParam]
 */


public fun < T , C > DataFrame < T > . fillNA ( vararg columns : KProperty < C > ) : Update < T , C ? >

/**
 * @include [CommonFillNAFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetFillNAOperationArg]}
 * @include [Update.KPropertiesParam]
 */


public fun < T , C > DataFrame < T > . fillNA ( vararg columns : ColumnReference < C > ) : Update < T , C ? >

/**
 * @include [CommonFillNAFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetFillNAOperationArg]}
 * @include [Update.ColumnAccessorsParam]
 */


public fun < T > DataFrame < T > . dropNulls ( whereAllNull : Boolean = false , columns : ColumnsSelector < T , * > ) : DataFrame < T >

{ <EOL> val cols = this [ columns ] <EOL> return if ( whereAllNull ) drop { row -> cols . all { col -> col [ row ] == null } } <EOL> else drop { row -> cols . any { col -> col [ row ] == null } } <EOL> }

/**
 * @include [CommonDropNullsFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNullsOperationArg]}
 * `df.`[dropNulls][dropNulls]`(whereAllNull = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
 * @include [DropNulls.WhereAllNullParam]
 * @include [DropDslParam]
 */


public fun < T > DataFrame < T > . dropNulls ( whereAllNull : Boolean = false ) : DataFrame < T >

= <EOL> dropNulls ( whereAllNull ) { all ( ) }

/**
 * @include [CommonDropNullsFunctionDoc]
 * This overload operates on all columns in the [DataFrame].
 * @include [DropNulls.WhereAllNullParam]
 */


public fun < T > DataFrame < T > . dropNulls ( vararg columns : KProperty < * > , whereAllNull : Boolean = false ) : DataFrame < T >

= <EOL> dropNulls ( whereAllNull ) { columns . toColumnSet ( ) }

/**
 * @include [CommonDropNullsFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNullsOperationArg]}
 * `df.`[dropNulls][dropNulls]`(Person::length, whereAllNull = true)`
 * @include [DropNulls.WhereAllNullParam]
 * @include [DropKPropertiesParam]
 */


public fun < T > DataFrame < T > . dropNulls ( vararg columns : String , whereAllNull : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNullsFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNullsOperationArg]}
 * `df.`[dropNulls][dropNulls]`("length", whereAllNull = true)`
 * @include [DropNulls.WhereAllNullParam]
 * @include [DropColumnNamesParam]
 */


public fun < T > DataFrame < T > . dropNulls ( vararg columns : AnyColumnReference , whereAllNull : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNullsFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNullsOperationArg]}
 * `df.`[dropNulls][dropNulls]`(length, whereAllNull = true)`
 * @include [DropNulls.WhereAllNullParam]
 * @include [DropColumnAccessorsParam]
 */


public fun < T > DataColumn < T ? > . dropNulls ( ) : DataColumn < T >

= <EOL> ( if ( ! hasNulls ( ) ) this else filter { it != null } ) as DataColumn < T >

/**
 * ## The Drop Nulls Operation
 *
 * Removes `null` values from this [DataColumn], adjusting the type accordingly.
 */


public fun < T > DataFrame < T > . dropNA ( whereAllNA : Boolean = false , columns : ColumnsSelector < T , * > ) : DataFrame < T >

{ <EOL> val cols = this [ columns ] <EOL> return if ( whereAllNA ) drop { cols . all { this [ it ] . isNA } } <EOL> else drop { cols . any { this [ it ] . isNA } } <EOL> }

/**
 * @include [CommonDropNAFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNAOperationArg]}
 * `df.`[dropNA][dropNA]`(whereAllNA = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
 * @include [DropNA.WhereAllNAParam]
 * @include [DropDslParam]
 */


public fun < T > DataFrame < T > . dropNA ( vararg columns : KProperty < * > , whereAllNA : Boolean = false ) : DataFrame < T >

= <EOL> dropNA ( whereAllNA ) { columns . toColumnSet ( ) }

/**
 * @include [CommonDropNAFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNAOperationArg]}
 * `df.`[dropNA][dropNA]`(Person::length, whereAllNA = true)`
 * @include [DropNA.WhereAllNAParam]
 * @include [DropKPropertiesParam]
 */


public fun < T > DataFrame < T > . dropNA ( vararg columns : String , whereAllNA : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNAFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNAOperationArg]}
 * `df.`[dropNA][dropNA]`("length", whereAllNA = true)`
 * @include [DropNA.WhereAllNAParam]
 * @include [DropColumnNamesParam]
 */


public fun < T > DataFrame < T > . dropNA ( vararg columns : AnyColumnReference , whereAllNA : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNAFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNAOperationArg]}
 * `df.`[dropNA][dropNA]`(length, whereAllNA = true)`
 * @include [DropNA.WhereAllNAParam]
 * @include [DropColumnAccessorsParam]
 */


public fun < T > DataFrame < T > . dropNA ( whereAllNA : Boolean = false ) : DataFrame < T >

= <EOL> dropNA ( whereAllNA ) { all ( ) }

/**
 * @include [CommonDropNAFunctionDoc]
 * This overload operates on all columns in the [DataFrame].
 * @include [DropNA.WhereAllNAParam]
 */


public fun < T > DataColumn < T ? > . dropNA ( ) : DataColumn < T >

= <EOL> when ( typeClass ) { <EOL> Double :: class , Float :: class -> filter { ! it . isNA } . cast ( ) <EOL> else -> ( if ( ! hasNulls ( ) ) this else filter { it != null } ) as DataColumn < T > <EOL> }

/**
 * ## The Drop `NA` Operation
 *
 * Removes [`NA`][NA] values from this [DataColumn], adjusting the type accordingly.
 */


public fun < T > DataFrame < T > . dropNaNs ( whereAllNaN : Boolean = false , columns : ColumnsSelector < T , * > ) : DataFrame < T >

{ <EOL> val cols = this [ columns ] <EOL> return if ( whereAllNaN ) drop { cols . all { this [ it ] . isNaN } } <EOL> else drop { cols . any { this [ it ] . isNaN } } <EOL> }

/**
 * @include [CommonDropNaNsFunctionDoc]
 * @include [SelectingColumns.Dsl.WithExample] {@include [SetDropNaNsOperationArg]}
 * `df.`[dropNaNs][dropNaNs]`(whereAllNaN = true) { `[colsOf][colsOf]`<`[Double][Double]`>() }`
 * @include [DropNaNs.WhereAllNaNParam]
 * @include [DropDslParam]
 */


public fun < T > DataFrame < T > . dropNaNs ( vararg columns : KProperty < * > , whereAllNaN : Boolean = false ) : DataFrame < T >

= <EOL> dropNaNs ( whereAllNaN ) { columns . toColumnSet ( ) }

/**
 * @include [CommonDropNaNsFunctionDoc]
 * @include [SelectingColumns.KProperties.WithExample] {@include [SetDropNaNsOperationArg]}
 * `df.`[dropNaNs][dropNaNs]`(Person::length, whereAllNaN = true)`
 * @include [DropNaNs.WhereAllNaNParam]
 * @include [DropKPropertiesParam]
 */


public fun < T > DataFrame < T > . dropNaNs ( vararg columns : String , whereAllNaN : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNaNsFunctionDoc]
 * @include [SelectingColumns.ColumnNames.WithExample] {@include [SetDropNaNsOperationArg]}
 * `df.`[dropNaNs][dropNaNs]`("length", whereAllNaN = true)`
 * @include [DropNaNs.WhereAllNaNParam]
 * @include [DropColumnNamesParam]
 */


public fun < T > DataFrame < T > . dropNaNs ( vararg columns : AnyColumnReference , whereAllNaN : Boolean = false ) : DataFrame < T >

/**
 * @include [CommonDropNaNsFunctionDoc]
 * @include [SelectingColumns.ColumnAccessors.WithExample] {@include [SetDropNaNsOperationArg]}
 * `df.`[dropNaNs][dropNaNs]`(length, whereAllNaN = true)`
 * @include [DropNaNs.WhereAllNaNParam]
 * @include [DropColumnAccessorsParam]
 */


public fun < T > DataFrame < T > . dropNaNs ( whereAllNaN : Boolean = false ) : DataFrame < T >

= <EOL> dropNaNs ( whereAllNaN ) { all ( ) }

/**
 * @include [CommonDropNaNsFunctionDoc]
 * This overload operates on all columns in the [DataFrame].
 * @include [DropNaNs.WhereAllNaNParam]
 */


public fun < T > DataColumn < T > . dropNaNs ( ) : DataColumn < T >

= <EOL> when ( typeClass ) { <EOL> Double :: class , Float :: class -> filter { ! it . isNaN } . cast ( ) <EOL> else -> this <EOL> }

/**
 * ## The Drop `NaN` Operation
 *
 * Removes [`NaN`][NaN] values from this [DataColumn], adjusting the type accordingly.
 */


internal fun addClasspath ( paths : List < File > )

{ <EOL> if ( analysisPlatform == Platform . js || analysisPlatform == Platform . wasm ) { <EOL> configuration . addAll ( JSConfigurationKeys . LIBRARIES , paths . map { it . absolutePath } ) <EOL> } else { <EOL> configuration . addJvmClasspathRoots ( paths ) <EOL> } <EOL> }

/**
 * Adds list of paths to classpath.
 * $paths: collection of files to add
 */


internal fun addClasspath ( path : File )

{ <EOL> if ( analysisPlatform == Platform . js || analysisPlatform == Platform . wasm ) { <EOL> configuration . add ( JSConfigurationKeys . LIBRARIES , path . absolutePath ) <EOL> } else { <EOL> configuration . addJvmClasspathRoot ( path ) <EOL> } <EOL> }

/**
 * Adds path to classpath.
 * $path: path to add
 */