-
Notifications
You must be signed in to change notification settings - Fork 0
/
matriz.py
37 lines (25 loc) · 941 Bytes
/
matriz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class Matriz:
def __init__(self, lista_numeros: list, dimension):
"""
Args:
lista_numeros (list): contenido de la matriz
dimension (iterable): Dimensión de la matriz
"""
self.__matriz = lista_numeros
self.__dim = tuple(dimension)
def crea_matriz(representacion):
representacion = representacion.split(':')
lista = list(map(float, representacion[0].replace('[', '').replace(']', '').split(',')))
dimension = tuple(map(int, representacion[1].replace('[', '').replace(']', '').split(',')))
return Matriz(lista, dimension)
@property
def matriz(self):
return self.__matriz
@property
def dimension(self):
return self.__dim
def __repr__(self) -> str:
dimension = str(self.__dim).replace('(', '[').replace(')', ']')
return f"{self.__matriz}:{dimension}"
def __str__(self) -> str:
return self.__repr__()