Skip to content

Commit bddf85f

Browse files
committed
Add build panel, Add str filter to Vector __init__
1 parent d4f5983 commit bddf85f

File tree

7 files changed

+51
-38
lines changed

7 files changed

+51
-38
lines changed
62 Bytes
Binary file not shown.

eggdriver/pypi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
def build(setupFile = "setup.py", autoVersion = True):
1414
"""Build and upload a pypi package release"""
1515
installFromRequests(["setuptools", "twine", "build"], False)
16-
if autoVersion:
17-
# setup = py.getLines(setupFile)
18-
# v = '0.0.1a8'
16+
#if autoVersion:
17+
# setup = py.getLines(setupFile)
18+
# v = '0.0.1a8'
1919
sysCommand("-m build --sdist")
2020
sysCommand("-m build --wheel")
2121
sysCommand("-m twine check dist/*")

eggdriver/resources/math/linear.py renamed to eggdriver/resources/math/linear/__init__.py

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from eggdriver.resources.structures.lists import List
22
from eggdriver.resources.utils import indexes
3+
from eggdriver.resources.math.linear.utils import *
34

45
class Vector(List):
5-
def __init__(self, list = []):
6-
super().__init__(list)
6+
def __init__(self, vanillaList = []):
7+
if type(vanillaList) == str:
8+
temp = vanillaList.replace("[", "").replace("]", "")
9+
vanillaList = list(map(int, temp.split()))
10+
super().__init__(vanillaList)
711
def plus(self, vector):
812
return plus(self, vector)
913
def dot(self, vector):
@@ -43,14 +47,9 @@ def n(self):
4347
def m(self):
4448
return len(self[0])
4549

46-
class LinearError(Exception):
47-
def __init__(self, type = 0):
48-
message = {
49-
0: "Vectors have to be of the same size",
50-
1: "Matrix must be a squared matrix",
51-
2: "Number of rows (n) must not be 0"
52-
}
53-
super().__init__(message[type])
50+
def rowReduce(matrix: Matrix):
51+
result = Vector()
52+
return result
5453

5554
def determinant(M):
5655
result = M[0][0]
@@ -75,12 +74,6 @@ def subMatrix(M, row, column):
7574
result.append(v)
7675
return result
7776

78-
def dualExpand(a, b):
79-
if a.size < b.size:
80-
a.expand(b.size - a.size)
81-
else:
82-
b.expand(a.size - b.size)
83-
8477
def plus(a, b, autoExpand = False):
8578
result = Vector()
8679
if len(a) != len(b):
@@ -93,18 +86,6 @@ def plus(a, b, autoExpand = False):
9386
result.append(a[i] + b[i])
9487
return result
9588

96-
def dot(a, b, autoExpand = False):
97-
result = 0
98-
if len(a) != len(b):
99-
if autoExpand:
100-
dualExpand(a, b)
101-
else:
102-
raise LinearError
103-
if len(a) != 0 and len(a) == len(b):
104-
for i in range(0, a.size):
105-
result += a[i] * b[i]
106-
return result
107-
10889
def scale(vector, scalar):
10990
result = Vector()
11091
if vector.size != 0:
@@ -138,7 +119,4 @@ def vectorize(poly: str):
138119
result.expand(degree + 1)
139120
for i in indexes(coefs):
140121
result[exps[i]] += coefs[i]
141-
return result
142-
143-
144-
122+
return result
Binary file not shown.
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
class LinearError(Exception):
2+
def __init__(self, type = 0):
3+
message = {
4+
0: "Vectors have to be of the same size",
5+
1: "Matrix must be a squared matrix",
6+
2: "Number of rows (n) must not be 0"
7+
}
8+
super().__init__(message[type])
9+
10+
def dot(a, b, autoExpand = False):
11+
result = 0
12+
if len(a) != len(b):
13+
if autoExpand:
14+
dualExpand(a, b)
15+
else:
16+
raise LinearError
17+
if len(a) != 0 and len(a) == len(b):
18+
for i in range(0, a.size):
19+
result += a[i] * b[i]
20+
return result
21+
22+
def dualExpand(a, b):
23+
if a.size < b.size:
24+
a.expand(b.size - a.size)
25+
else:
26+
b.expand(a.size - b.size)

test.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
from eggdriver import build, Matrix
1+
###############################
2+
wannaBuildRelease = False ## ** Build panel **
3+
############################### Set
4+
from eggdriver import build ## wannaBuildRelease = True
5+
if wannaBuildRelease: ## to build a new release!
6+
build() ##
7+
###############################
28

3-
build()
9+
from eggdriver import Matrix, Vector
410

511
c = Matrix("""
612
| 1 1 2 3 4 |
@@ -9,4 +15,7 @@
915
| 1 1 2 3 4 |
1016
| 1 1 2 3 4 |
1117
""", 4, 5)
12-
c.display()
18+
c.display()
19+
20+
a = Vector("[ 1 2 3 4 5 6 30 0 9]")
21+
a.display()

0 commit comments

Comments
 (0)