-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hash test #64
Open
SkandanC
wants to merge
33
commits into
BYUCamachoLab:master
Choose a base branch
from
SkandanC:hash-test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Hash test #64
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
251cfe7
Added __hash__() method to models.py
SkandanC 5f2e6fc
Add __hash__() function
SkandanC 5788793
Create modelhashtest.py
SkandanC 6769bde
Added hash method to models.py
SkandanC 32d0bb3
Deleted test files
SkandanC 12c2f7d
Add __hash__() methods for siepic models
SkandanC c7dc8f2
Add __hash__() methods to sipann models
SkandanC 5523b79
Add _hash__() method to models.py
SkandanC ae857f2
Add hash tests
SkandanC 910f0da
Update __hash__() docstring
SkandanC 11efb64
Add base tests
SkandanC 74d289d
Update siepichashtest.py
SkandanC 1abc4f8
Update hash test files
SkandanC df5b128
Linting
SkandanC 00ec666
Linting
SkandanC 434ec55
Remove unused import
SkandanC 6186a5e
Add SiPANN to tox deps
SkandanC ff07d54
Update test_hash.py
SkandanC 721f295
Update assert statements
SkandanC 4446369
Add SiPANN and numpy version to deps
SkandanC b68326c
Update test_hash.py
SkandanC db4cd99
Update tox.ini
SkandanC b3d9000
Add numpy version and remove py37
SkandanC 1728617
Remove python version 3.7
SkandanC 3f1b19c
Remove numpy version requirement
SkandanC 284f228
Update build-and-test.yml
SkandanC b26f29e
Temporarily disable SiPANN hash tests
SkandanC 3e1c516
Uncomment SiPANN hash tests
SkandanC 799ebe2
Merge branch 'BYUCamachoLab:hash-test' into hash-test
SkandanC 10d252e
Remove unnecessary tests and add tests to test every parameter
SkandanC 4dcdf4b
Fix linting errors
SkandanC 4acd986
Merge branch 'master' into hash-test
SkandanC fdbbbb2
Merge remote-tracking branch 'upstream/master' into hash-test
SkandanC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
# Copyright © Simphony Project Contributors | ||
# Licensed under the terms of the MIT License | ||
# (see simphony/__init__.py for details) | ||
|
||
from simphony.libraries import siepic | ||
from simphony.libraries import sipann | ||
|
||
|
||
class TestSiepicHash: | ||
|
||
def test_hash(self): | ||
|
||
bdc1 = siepic.BidirectionalCoupler(thickness=2.2e-7, width=5e-7) | ||
bdc2 = siepic.BidirectionalCoupler(thickness=2.2e-7, width=5e-7) | ||
assert bdc1.__hash__() == bdc2.__hash__() | ||
|
||
bdc1 = siepic.BidirectionalCoupler(thickness=2.1e-7) | ||
bdc2 = siepic.BidirectionalCoupler(thickness=2.2e-7) | ||
assert bdc1.__hash__() != bdc2.__hash__() | ||
|
||
bdc1 = siepic.BidirectionalCoupler(width=5.2e-7) | ||
bdc2 = siepic.BidirectionalCoupler(width=5e-7) | ||
assert bdc1.__hash__() != bdc2.__hash__() | ||
|
||
hr1siepic = siepic.HalfRing(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
hr2siepic = siepic.HalfRing(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1siepic.__hash__() == hr2siepic.__hash__() | ||
|
||
hr1siepic = siepic.HalfRing(gap=8e-8, radius=1e-5, width=5e-7, thickness=2.1e-7) | ||
hr2siepic = siepic.HalfRing(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1siepic.__hash__() != hr2siepic.__hash__() | ||
|
||
hr1siepic = siepic.HalfRing(gap=1e-7, radius=5e-6, width=5e-7, thickness=2.2e-7) | ||
hr2siepic = siepic.HalfRing(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1siepic.__hash__() != hr2siepic.__hash__() | ||
|
||
dc1 = siepic.DirectionalCoupler() | ||
dc2 = siepic.DirectionalCoupler() | ||
assert dc1.__hash__() == dc2.__hash__() | ||
|
||
dc1 = siepic.DirectionalCoupler(Lc=0) | ||
dc2 = siepic.DirectionalCoupler() | ||
assert dc1.__hash__() != dc2.__hash__() | ||
|
||
term1 = siepic.Terminator() | ||
term2 = siepic.Terminator() | ||
assert term1.__hash__() == term2.__hash__() | ||
|
||
wg1 = siepic.Waveguide(length=150e-6) | ||
wg2 = siepic.Waveguide(length=150e-6) | ||
assert wg1.__hash__() == wg2.__hash__() | ||
|
||
wg1 = siepic.Waveguide(length=150e-6) | ||
wg2 = siepic.Waveguide(length=50e-6) | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
wg1 = siepic.Waveguide(width=5.2e-7) | ||
wg2 = siepic.Waveguide() | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
wg1 = siepic.Waveguide(height=2e-7) | ||
wg2 = siepic.Waveguide() | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
|
||
class TestSipannHash: | ||
|
||
def test_hash(self): | ||
|
||
hr1 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
hr2 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1.__hash__() == hr2.__hash__() | ||
|
||
hr1 = sipann.HalfRing(gap=1.5e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
hr2 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1.__hash__() != hr2.__hash__() | ||
|
||
hr1 = sipann.HalfRing(gap=2e-7, radius=8e-6, width=5e-7, thickness=2.2e-7) | ||
hr2 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1.__hash__() != hr2.__hash__() | ||
|
||
hr1 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5.2e-7, thickness=2.2e-7) | ||
hr2 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1.__hash__() != hr2.__hash__() | ||
|
||
hr1 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.1e-7) | ||
hr2 = sipann.HalfRing(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7) | ||
assert hr1.__hash__() != hr2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=1e-7) | ||
hra2 = sipann.HalfRacetrack(gap=1e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=1e-7) | ||
assert hra1.__hash__() == hra2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=1.5e-7, radius=10e-6, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
hra2 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
assert hra1.__hash__() != hra2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=2e-7, radius=5e-6, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
hra2 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
assert hra1.__hash__() != hra2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5.2e-7, thickness=2.2e-7, length=2e-7) | ||
hra2 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
assert hra1.__hash__() != hra2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.1e-7, length=2e-7) | ||
hra2 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
assert hra1.__hash__() != hra2.__hash__() | ||
|
||
hra1 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2.2e-7) | ||
hra2 = sipann.HalfRacetrack(gap=2e-7, radius=1e-5, width=5e-7, thickness=2.2e-7, length=2e-7) | ||
assert hra1.__hash__() != hra2.__hash__() | ||
|
||
sc1 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=1e-7) | ||
sc2 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=1e-7) | ||
assert sc1.__hash__() == sc2.__hash__() | ||
|
||
sc1 = sipann.StraightCoupler(width=5.8e-7, thickness=2e-7, gap=2e-7, length=2e-7) | ||
sc2 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=2e-7) | ||
assert sc1.__hash__() != sc2.__hash__() | ||
|
||
sc1 = sipann.StraightCoupler(width=5e-7, thickness=2.2e-7, gap=2e-7, length=2e-7) | ||
sc2 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=2e-7) | ||
assert sc1.__hash__() != sc2.__hash__() | ||
|
||
sc1 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2.2e-7, length=2e-7) | ||
sc2 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=2e-7) | ||
assert sc1.__hash__() != sc2.__hash__() | ||
|
||
sc1 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=2.2e-7) | ||
sc2 = sipann.StraightCoupler(width=5e-7, thickness=2e-7, gap=2e-7, length=2e-7) | ||
assert sc1.__hash__() != sc2.__hash__() | ||
|
||
wg1 = sipann.Waveguide(length=150e-6, width=5e-7, thickness=2e-7) | ||
wg2 = sipann.Waveguide(length=150e-6, width=5e-7, thickness=2e-7) | ||
assert wg1.__hash__() == wg2.__hash__() | ||
|
||
wg1 = sipann.Waveguide(length=150e-6, width=5e-7, thickness=2e-7) | ||
wg2 = sipann.Waveguide(length=50e-6, width=5e-7, thickness=2e-7) | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
wg1 = sipann.Waveguide(length=50e-6, width=5.2e-7, thickness=2e-7) | ||
wg2 = sipann.Waveguide(length=50e-6, width=5e-7, thickness=2e-7) | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
wg1 = sipann.Waveguide(length=50e-6, width=5e-7, thickness=2.3e-7) | ||
wg2 = sipann.Waveguide(length=50e-6, width=5e-7, thickness=2e-7) | ||
assert wg1.__hash__() != wg2.__hash__() | ||
|
||
stcoup1 = sipann.Standard(width=5e-7, thickness=2.3e-7, gap=2e-7, length=10e-6, horizontal=1e-6, vertical=1e-6) | ||
stcoup2 = sipann.Standard(width=5e-7, thickness=2.3e-7, gap=2e-7, length=10e-6, horizontal=1e-6, vertical=1e-6) | ||
assert stcoup1.__hash__() == stcoup2.__hash__() | ||
|
||
stcoup1 = sipann.Standard(width=5.8e-7, thickness=2.2e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
stcoup2 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
assert stcoup1.__hash__() != stcoup2.__hash__() | ||
|
||
stcoup1 = sipann.Standard(width=5e-7, thickness=2.3e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
stcoup2 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
assert stcoup1.__hash__() != stcoup2.__hash__() | ||
|
||
stcoup1 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2.3e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
stcoup2 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
assert stcoup1.__hash__() != stcoup2.__hash__() | ||
|
||
stcoup1 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2e-7, length=9e-6, horizontal=2e-6, vertical=2e-6) | ||
stcoup2 = sipann.Standard(width=5e-7, thickness=2.2e-7, gap=2e-7, length=10e-6, horizontal=2e-6, vertical=2e-6) | ||
assert stcoup1.__hash__() != stcoup2.__hash__() | ||
|
||
dhr1 = sipann.DoubleHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, gap=2e-7) | ||
dhr2 = sipann.DoubleHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, gap=2e-7) | ||
assert dhr1.__hash__() == dhr2.__hash__() | ||
|
||
dhr1 = sipann.DoubleHalfRing(width=5.8e-7, thickness=2.2e-7, radius=1e-5, gap=2e-7) | ||
dhr2 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, gap=2e-7) | ||
assert dhr1.__hash__() != dhr2.__hash__() | ||
|
||
dhr1 = sipann.DoubleHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, gap=2e-7) | ||
dhr2 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, gap=2e-7) | ||
assert dhr1.__hash__() != dhr2.__hash__() | ||
|
||
dhr1 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=5e-6, gap=2e-7) | ||
dhr2 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, gap=2e-7) | ||
assert dhr1.__hash__() != dhr2.__hash__() | ||
|
||
dhr1 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, gap=1e-7) | ||
dhr2 = sipann.DoubleHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, gap=2e-7) | ||
assert dhr1.__hash__() != dhr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, theta=45, gap=2e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() == ahr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5.8e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() != ahr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5e-7, thickness=2.3e-7, radius=1e-5, theta=45, gap=2e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() != ahr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=5e-6, theta=45, gap=2e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() != ahr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=50, gap=2e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() != ahr2.__hash__() | ||
|
||
ahr1 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=1e-7) | ||
ahr2 = sipann.AngledHalfRing(width=5e-7, thickness=2.2e-7, radius=1e-5, theta=45, gap=2e-7) | ||
assert ahr1.__hash__() != ahr2.__hash__() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ deps = | |
numpy | ||
pytest | ||
scipy | ||
SiPANN | ||
commands = pytest -vv |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For components with multiple parameters, you should probably do multiple tests where each test only has 1 parameter different. That way you can get full coverage.