Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hdd29-CS265-sp19
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdd29
hdd29-CS265-sp19
Commits
4f310776
Commit
4f310776
authored
6 years ago
by
hdd29
Browse files
Options
Downloads
Patches
Plain Diff
Last commit
parent
25e2b119
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lab09/gInt.py
+2
-2
2 additions, 2 deletions
lab09/gInt.py
lab09/test_gInt.py
+2
-4
2 additions, 4 deletions
lab09/test_gInt.py
with
4 additions
and
6 deletions
lab09/gInt.py
+
2
−
2
View file @
4f310776
...
...
@@ -43,13 +43,13 @@ class gInt :
def
__mul__
(
self
,
rhs
)
:
'''
Return a new gInt, self * rhs
'''
r
=
self
.
real
*
rhs
.
real
-
self
.
imag
*
rhs
.
imag
i
=
self
.
real
*
rhs
.
imag
-
self
.
imag
*
rhs
.
real
i
=
self
.
real
*
rhs
.
imag
+
self
.
imag
*
rhs
.
real
return
gInt
(
r
,
i
)
def
norm
(
self
)
:
'''
Return real^2 + imag^2 as an int
'''
norm
=
(
self
.
imag
*
2
+
self
.
real
*
2
)
norm
=
(
self
.
imag
*
*
2
+
self
.
real
*
*
2
)
return
norm
def
test
()
:
...
...
This diff is collapsed.
Click to expand it.
lab09/test_gInt.py
+
2
−
4
View file @
4f310776
...
...
@@ -66,14 +66,12 @@ class gIntTest(unittest.TestCase):
self
.
assertEqual
(
self
.
np1
,
self
.
np1_copy
,
'
Right operand changed after mul
'
)
self
.
assertEqual
(
self
.
small
,
self
.
small
,
'
Left operand changed after mul if it is small
'
)
self
.
assertEqual
(
self
.
np1
,
self
.
np1_copy
,
'
Right operand changed after mul if it is small
'
)
self
.
assertEqual
(
Product
,
gInt
(
1
0
,
20
)),
'
Mul is not correct to every significant figures
'
self
.
assertEqual
(
Product
,
gInt
(
1
1
,
61
)),
'
Mul is not correct to every significant figures
'
def
test_norm
(
self
):
#norm1 = self.oi.norm()
#self.assertEqual(norm1, (3^2) + (4^2))
norm2
=
self
.
pn1
.
norm
()
self
.
assertEqual
(
norm2
,
(
3
^
2
+
(
-
5
)
^
2
))
self
.
assertEqual
(
norm2
,
(
3
**
2
+
(
-
5
)
**
2
))
if
__name__
==
'
__main__
'
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment