1
0
pwr_project/src/matrix.py

36 lines
1.1 KiB
Python

import numpy
class Matrix:
__data__ = []
__shape__ = ()
def __init__(self, data=None, shape=None, structure=None, model=None, size=None):
if isinstance(data, numpy.ndarray):
try:
data.shape[1]
except IndexError:
self.__shape__ = (data.shape[0], 1)
else:
self.__shape__ = data.shape
self.__data__ = data.tolist()
elif isinstance(data, list) and isinstance(shape, tuple):
self.__shape__ = shape
self.__data__ = numpy.array(data).reshape(shape).tolist()
elif isinstance(data, list) and isinstance(structure, str) and isinstance(size, int):
...
elif isinstance(model, str) and isinstance(size, int):
...
else:
raise ValueError("Only following signatures are allowed: "
"(numpy.ndarray), (list, tuple), (list, str, int), (str, int)")
def get_data(self):
return self.__data__
def shape(self):
return self.__shape__
def __eq__(self, other):
return self.__data__ == other.__data__