So weisen Sie Variablen in einer Schleife viele Numpy -Arrays zu [Duplikat]

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: So weisen Sie Variablen in einer Schleife viele Numpy -Arrays zu [Duplikat]

by Anonymous » 19 Aug 2025, 12:03

Ich muss eine große Anzahl von Numpy -Arrays instanziieren. Der Code -Snippet lautet: < /p>

Code: Select all

def computa(self):
self.variable1 = ma.zeros([self.nx, self.ny, self.nz], dtype=float)
self.variable2 = ma.zeros([self.nx, self.ny, self.nz], dtype=float)
self.variable3 = ma.zeros([self.nx, self.ny, self.nz], dtype=float)
< /code>
Das [url=viewtopic.php?t=26065]Problem[/url] ist, dass dies mit zunehmender Anzahl von Variablen hässlicher wird.def computa(self):
self.variables_list = [self.variable1, self.variable2, self.variable3]
for variables in (self.variables_list):
variables = ma.zeros([self.nx, self.ny, self.nz], dtype=float)
Gibt es eine pythonische Möglichkeit, über alle Numpy -Arrays zu gruppieren oder zu schleifen?

Top