1
+ package org.utbot.python.fuzzing.provider
2
+
3
+ import mu.KotlinLogging
4
+ import org.utbot.fuzzing.Routine
5
+ import org.utbot.fuzzing.Seed
6
+ import org.utbot.python.framework.api.python.PythonTree
7
+ import org.utbot.python.framework.api.python.util.pythonNdarrayClassId
8
+ import org.utbot.python.fuzzing.FuzzedUtType
9
+ import org.utbot.python.fuzzing.FuzzedUtType.Companion.activateAnyIf
10
+ import org.utbot.python.fuzzing.FuzzedUtType.Companion.toFuzzed
11
+ import org.utbot.python.fuzzing.PythonFuzzedValue
12
+ import org.utbot.python.fuzzing.PythonMethodDescription
13
+ import org.utbot.python.fuzzing.PythonValueProvider
14
+ import org.utpython.types.pythonAnnotationParameters
15
+
16
+
17
+ private val logger = KotlinLogging .logger {}
18
+
19
+ object NDArrayValueProvider : PythonValueProvider {
20
+ override fun accept (type : FuzzedUtType ): Boolean {
21
+ return type.pythonTypeName() == pythonNdarrayClassId.canonicalName
22
+ }
23
+
24
+ override fun generate (
25
+ description : PythonMethodDescription , type : FuzzedUtType
26
+ ) = sequence {
27
+ val param = type.utType.pythonAnnotationParameters()
28
+ yield (Seed .Collection ( // TODO: Rewrite to construct NDArray objects
29
+ construct = Routine .Collection {
30
+ PythonFuzzedValue (
31
+ PythonTree .NdarrayNode (
32
+ emptyMap<Int , PythonTree .PythonTreeNode >().toMutableMap(),
33
+ ), " %var% = ${type.pythonTypeRepresentation()} "
34
+ )
35
+ },
36
+ modify = Routine .ForEach (param.toFuzzed().activateAnyIf(type)) { self, i, values ->
37
+ (self.tree as PythonTree .NdarrayNode ).items[i] = values.first().tree
38
+ }))
39
+ }
40
+ }
0 commit comments