Я новичок в Python (начался около месяца назад как хобби), и недавно я начал работать над программой моделирования / визуализации 4D + (как бы бессмысленно это ни звучало, это казалось забавным занятием). Поэтому я начал работать с некоторыми очень простыми классами / объектами и почти мгновенно столкнулся с проблемой, когда речь шла о процедурном определении гиперкуба:
Основная программа
import itertools as itt
import numpy as np
import Vertex as vx
def main():
defineHypercube(4)
def defineHypercube(n=4): #Creates an n-dimensional generalization of the cube
vertices = [] #List of the hypercube's vertices
coordList = list(itt.product([0, 1], repeat=n)) #Lists all the possible combinations with n bits (you probably already know though)
vertexCoords = [] #This list is here because it seemed like the easiest way to go about attributing coordinates to the vertices
for i in range(2**n): #An n-dimensional hypercube has 2^n vertices
for coords in range(n): #Each vertex is defined by n coordinates
vertexCoords.append(coordList[coords*n]) #Gets the x,y,z,w... coordinates for the new vertex
vertices.append(vx.Vertex(vertexCoords)) #Supposedly adds a new vertex with the coordinates from vertexCoords
vertexCoords.clear() #Well... it clears the list
print(list(vertices[i].coords)) #Used to check if I got it right
main()
класс вершин
import numpy as np
class Vertex:
coords = []
def __init__(self, coords):
self.coords = coords
"""def project():""" #This is here to remind me to get it done soon :')
Так что это хорошо, и все, и я не могу понять, что может пойти не так, но дело в том, что я все еще получаю этот вывод неожиданный вывод, который, кажется, указывает на то, что была проблема во время всего процесса назначения координат:
О мастера Python, пожалуйста, протяните руку этому маленькому новичку, который застрял на целый день по этому вопросу: v