Skip to content

Commit e651988

Browse files
[Andrew Polyakov] Change codegen for type in ndarray
1 parent bbab9b3 commit e651988

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/tree/PythonCgVariableConstructor.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ class PythonCgVariableConstructor(cgContext: CgContext) : CgVariableConstructor(
7979
is PythonTree.NDArrayNode -> {
8080
val items = objectNode.items.values.map { pythonBuildObject(it) }
8181
val shape = objectNode.dimensions
82-
val type = objectNode.items.values.firstOrNull()?.type?.typeName
83-
Pair(CgPythonNdarray(items.map { it.first }, shape, type?: "int"), items.flatMap { it.second })
82+
val type = objectNode.items.values.firstOrNull()?.type
83+
Pair(CgPythonNdarray(items.map { it.first }, shape, type?:PythonClassId("int")), items.flatMap { it.second })
8484
}
8585

8686
is PythonTree.TupleNode -> {

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/constructor/visitor/CgPythonRenderer.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,9 @@ internal class CgPythonRenderer(
563563
override fun visit(element: CgPythonNdarray) {
564564

565565
print("numpy.ndarray(")
566-
print("dtype=" + element.dtype + ",")
566+
print("dtype=")
567+
print(element.dtype.toString().removePrefix("builtins."))
568+
print(",")
567569
print("shape=(")
568570

569571
print(element.shape.joinToString(",") { it.toString() })

utbot-python/src/main/kotlin/org/utbot/python/framework/codegen/model/tree/CgPythonElement.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class CgPythonSet(
126126
class CgPythonNdarray(
127127
val elements: List<CgValue>,
128128
val shape: List<Int>,
129-
val dtype: String
129+
val dtype: PythonClassId
130130
) : CgValue, CgPythonElement {
131131
override val type: PythonClassId = pythonNdarrayClassId
132132
}

0 commit comments

Comments
 (0)