zu erstellen Wenn das Array eine Größe von 2x2 oder größer hat, ist alles gut, aber wenn die Dimension der Zeile 1 ist, zum Beispiel 1x2, macht numpy etwas I hatte nicht erwartet.Erstellen eines numpy Array schlägt fehl, wenn ich versuche, aus einem Array von QString
Wie kann ich das lösen?
# TEST 1 OK
myarray = np.array([[QString('hello'), QString('world')],
[QString('hello'), QString('moon')]],
dtype=object)
print myarray
print myarray.shape
#[[PyQt4.QtCore.QString(u'hello') PyQt4.QtCore.QString(u'world')]
# [PyQt4.QtCore.QString(u'hello') PyQt4.QtCore.QString(u'moon')]]
#(2, 2)
# TEST 2 OK
myarray = np.array([['hello'], ['world']], dtype=object)
print myarray
print myarray.shape
#[['hello']
# ['world']]
#(2, 1)
# TEST 3 FAIL
myarray = np.array([[QString('hello'), QString('world')]], dtype=object)
print myarray
print myarray.shape
#[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[PyQt4.QtCore.QString(u'h')]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
#..
#[[[[[[[[[[[[[[[[[[[[[[[[[[[[[PyQt4.QtCore.QString(u'e')]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
# etc...
#(1, 2, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
Oh seltsam ... scheint fast wie numpy die Saiten als Arrays oder etwas behandelt ... Was ist, wenn Sie setzen geschieht ein Komma zwischen den 2 schließenden eckigen Klammern? – karina