From 5404d5a6f96e176083c5d0ce188690991572e139 Mon Sep 17 00:00:00 2001 From: "Shane (Treasure) Xue" Date: Sat, 28 Nov 2020 15:56:47 +0800 Subject: [PATCH 1/3] Update jieji.py Used set for the points Used unpacking to deal with error Used line segment instead of line in make line segment TSR, 20201128 --- jieji.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jieji.py b/jieji.py index 1014ee0..895e89a 100644 --- a/jieji.py +++ b/jieji.py @@ -112,8 +112,8 @@ def plot(self): y = [self.p2.y_coord , self.p2.y_coord] plt.plot(x,y) -def create_line (puntoa , puntob): - return Line(puntoa , puntob) +def create_line_segment (puntoa , puntob): + return Line_Segment(puntoa , puntob) class Math_Vector(): """2d math vector""" @@ -170,9 +170,10 @@ def __str__(self): class Quadrilateral(): def __init__(self , a , b , c , d): - self.points = [a,b,c,d] + self.points = {a,b,c,d} def Circumference(self): + a,b,c,d=self.points return (distance(a,b) + distance(b,c) + distance(c,d) + distance(d,a)) def All_Equal(self , other): @@ -180,13 +181,14 @@ def All_Equal(self , other): class Triangle(): def __init__(self,a,b,c): - self.points = [a,b,c] + self.points = {a,b,c} def Sides(self): + a,b,c=self.points toa = distance(b,c) tob = distance(a,c) toc = distance(a,b) - return [toa , tob , toc] + return {toa , tob , toc} def All_Equal(self , other): return self.points == other.points From 9b4cbe3469c0e7ac0c781fe684fd2799917bfef4 Mon Sep 17 00:00:00 2001 From: "Shane (Treasure) Xue" Date: Sat, 28 Nov 2020 16:01:28 +0800 Subject: [PATCH 2/3] Update python-package.yml Delete pyhon 2.7 --- .github/workflows/python-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 421670b..5b01aad 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] + python-version: [3.5, 3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 From 9a3d16f20d256b95f4c54dee532bf8a767045b06 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 28 Nov 2020 16:09:51 +0800 Subject: [PATCH 3/3] Corrections Used sublime to look up mistakes on indentation and corrected them. TSR, 20201128 --- jieji.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/jieji.py b/jieji.py index 895e89a..8c13cb1 100644 --- a/jieji.py +++ b/jieji.py @@ -123,28 +123,28 @@ def __init__(self , x , y): self.y = y def __add__(self , other): - return Math_Vector ( self.x + other.x , self.y + other.y ) + return Math_Vector ( self.x + other.x , self.y + other.y ) def __neg__(self): - return Math_Vector (-self.x , -self.y) + return Math_Vector (-self.x , -self.y) def __pos__(self): - return self + return self def __sub__(self , other): - return -self + other + return -self + other def __mul__(self , other): - if (Is_arithmetic(other)): - return Math_Vector ( self.x * other , self.y * other ) + if (Is_arithmetic(other)): + return Math_Vector ( self.x * other , self.y * other ) class Circle(): """a circle defined by the center and radius""" - + def __init__(self , center , radius): self.center = center self.radius = radius - + def __eq__(self , otro): """ note: this only checks if the two are equal in normal geometry terms. @@ -152,10 +152,10 @@ def __eq__(self , otro): If you wnat checking against the center, use All_Equal. """ return self.radius == otro.radius - + def __ne__(self , otro): return not self == otro - + def All_Equal(self , otro): return self == otro and self.center == otro.center @@ -184,7 +184,7 @@ def __init__(self,a,b,c): self.points = {a,b,c} def Sides(self): - a,b,c=self.points + a,b,c=self.points toa = distance(b,c) tob = distance(a,c) toc = distance(a,b)