@@ -15,10 +15,13 @@ import kotlin.math.abs
15
15
16
16
17
17
private val logger = KotlinLogging .logger {}
18
+ private const val SHAPE_SIZE = 3
19
+ private const val MAX_SHAPE_DIGITS = 2
18
20
19
21
class NDArrayValueProvider (
20
22
private val typeStorage : PythonTypeHintsStorage
21
23
) : PythonValueProvider {
24
+
22
25
override fun accept (type : FuzzedUtType ): Boolean {
23
26
return type.pythonTypeName() == pythonNdarrayClassId.canonicalName
24
27
}
@@ -41,20 +44,25 @@ class NDArrayValueProvider(
41
44
) {
42
45
PythonFuzzedValue (
43
46
PythonTree .NDArrayNode (
44
- emptyMap<Int , PythonTree .PythonTreeNode >().toMutableMap(), // Generate new Python IntNode
47
+ emptyMap<Int , PythonTree .PythonTreeNode >().toMutableMap(),
45
48
((it.first().tree as PythonTree .ListNode ).items as Map <Int , PythonTree .PrimitiveNode >).values.map { node ->
46
- abs(node.repr.take(2 ).toInt())
47
- }
49
+ abs(node.repr.take(MAX_SHAPE_DIGITS ).toInt()) % 10
50
+ }.take(SHAPE_SIZE ).let { self ->
51
+ if (self.fold(1 , Int ::times) == 0 ){
52
+ listOf (0 )
53
+ } else {
54
+ self
55
+ }
56
+ } // TODO: Rethink logic
48
57
), " %var% = ${type.pythonTypeRepresentation()} "
49
58
)
50
59
},
51
60
modify = sequence {
52
- yield (Routine .Call ((0 until 10000 ).map { param[1 ] }.toFuzzed()) { instance, arguments ->
61
+ yield (Routine .Call ((0 until 1000000 ).map { param[1 ] }.toFuzzed()) { instance, arguments ->
53
62
val obj = instance.tree as PythonTree .NDArrayNode
54
63
(0 until obj.dimensions.fold(1 , Int ::times)).map {
55
- obj.items[it] = arguments.get(it) .tree
64
+ obj.items[it] = arguments[it] .tree
56
65
}
57
-
58
66
})
59
67
},
60
68
empty = Routine .Empty { PythonFuzzedValue (PythonTree .FakeNode ) }
0 commit comments