Skip to content
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
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
251cfe7
Added __hash__() method to models.py
SkandanC Mar 15, 2022
5f2e6fc
Add __hash__() function
SkandanC Mar 15, 2022
5788793
Create modelhashtest.py
SkandanC Mar 15, 2022
6769bde
Added hash method to models.py
SkandanC Mar 21, 2022
32d0bb3
Deleted test files
SkandanC Mar 21, 2022
12c2f7d
Add __hash__() methods for siepic models
SkandanC Mar 23, 2022
c7dc8f2
Add __hash__() methods to sipann models
SkandanC Mar 23, 2022
5523b79
Add _hash__() method to models.py
SkandanC Mar 23, 2022
ae857f2
Add hash tests
SkandanC Mar 24, 2022
910f0da
Update __hash__() docstring
SkandanC Mar 24, 2022
11efb64
Add base tests
SkandanC Mar 24, 2022
74d289d
Update siepichashtest.py
SkandanC Mar 28, 2022
1abc4f8
Update hash test files
SkandanC Apr 14, 2022
df5b128
Linting
SkandanC Apr 14, 2022
00ec666
Linting
SkandanC Apr 14, 2022
434ec55
Remove unused import
SkandanC Apr 14, 2022
6186a5e
Add SiPANN to tox deps
SkandanC Apr 14, 2022
ff07d54
Update test_hash.py
SkandanC Apr 14, 2022
721f295
Update assert statements
SkandanC Apr 15, 2022
4446369
Add SiPANN and numpy version to deps
SkandanC Apr 15, 2022
b68326c
Update test_hash.py
SkandanC Apr 15, 2022
db4cd99
Update tox.ini
SkandanC Apr 15, 2022
b3d9000
Add numpy version and remove py37
SkandanC Apr 15, 2022
1728617
Remove python version 3.7
SkandanC Apr 15, 2022
3f1b19c
Remove numpy version requirement
SkandanC Apr 15, 2022
284f228
Update build-and-test.yml
SkandanC Apr 15, 2022
b26f29e
Temporarily disable SiPANN hash tests
SkandanC Apr 19, 2022
3e1c516
Uncomment SiPANN hash tests
SkandanC Apr 26, 2022
799ebe2
Merge branch 'BYUCamachoLab:hash-test' into hash-test
SkandanC Apr 29, 2022
10d252e
Remove unnecessary tests and add tests to test every parameter
SkandanC May 23, 2022
4dcdf4b
Fix linting errors
SkandanC May 23, 2022
4acd986
Merge branch 'master' into hash-test
SkandanC Aug 25, 2022
fdbbbb2
Merge remote-tracking branch 'upstream/master' into hash-test
SkandanC Oct 27, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions simphony/libraries/siepic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,12 @@ class BidirectionalCoupler(SiEPIC_PDK_Base):
r"(?:\.sparam)"
)

def __hash__(self) -> int:

"""Gets a hash for the BidirectionalCoupler component based on component type, and component parameters"""

return hash(hash(type(self)) + hash(self.thickness) + hash(self.width))

def __init__(self, thickness=220e-9, width=500e-9, **kwargs):
super().__init__(**kwargs, thickness=thickness, width=width)

Expand Down Expand Up @@ -584,6 +590,12 @@ class HalfRing(SiEPIC_PDK_Base):
r"(?:m\.dat)"
)

def __hash__(self) -> int:

"""Gets a hash for the HalfRing component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.gap) + hash(self.radius) + hash(self.thickness) + hash(self.width) + hash(self.couple_length))

def __init__(
self,
gap=30e-9,
Expand Down Expand Up @@ -660,6 +672,12 @@ class DirectionalCoupler(SiEPIC_PDK_Base):
r"(?:m\.sparam)"
)

def __hash__(self) -> int:

"""Gets a hash for the DirectionalCoupler component based on component type, gap, and length of coupler."""

return hash(hash(type(self)) + hash(self.gap) + hash(self.Lc))

def __init__(self, gap=200e-9, Lc=10e-6, **kwargs):
super().__init__(**kwargs, gap=gap, Lc=Lc)

Expand Down Expand Up @@ -723,6 +741,12 @@ class Terminator(SiEPIC_PDK_Base):
r"(?:_TE.sparam)"
)

def __hash__(self) -> int:

"""Gets a hash for the Terminator component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.w1) + hash(self.w2) + hash(self.L))

def __init__(self, w1=500e-9, w2=60e-9, L=10e-6, **kwargs):
super().__init__(**kwargs, w1=w1, w2=w2, L=L)

Expand Down Expand Up @@ -793,6 +817,12 @@ class GratingCoupler(SiEPIC_PDK_Base):
r"(?:\.txt)"
)

def __hash__(self) -> int:

"""Gets a hash for the GratingCoupler component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.polarization) + hash(self.thickness) + hash(self.deltaw))

def __init__(self, thickness=220e-9, deltaw=0, polarization="TE", **kwargs):
super().__init__(
**kwargs, thickness=thickness, deltaw=deltaw, polarization=polarization
Expand Down Expand Up @@ -892,6 +922,12 @@ class Waveguide(SiEPIC_PDK_Base):
r"(?:\.txt)"
)

def __hash__(self) -> int:

"""Gets a hash for the Waveguide component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.length) + hash(self.width) + hash(self.height) + hash(self.polarization) + hash(self.sigma_ne) + hash(self.sigma_ng) + hash(self.sigma_nd))

def __init__(
self,
length=0.0,
Expand Down Expand Up @@ -1055,6 +1091,12 @@ class YBranch(SiEPIC_PDK_Base):
r"(?:\.sparam)"
)

def __hash__(self) -> int:

"""Gets a hash for the YBranch component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.thickness) + hash(self.width) + hash(type(self.polarization)))

def __init__(self, thickness=220e-9, width=500e-9, polarization="TE", **kwargs):
if polarization not in ["TE", "TM"]:
raise ValueError(
Expand Down
54 changes: 54 additions & 0 deletions simphony/libraries/sipann.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,12 @@ class HalfRing(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the HalfRing component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.radius) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -407,6 +413,12 @@ class HalfRacetrack(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the HalfRacetrack component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.radius) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.length) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -470,6 +482,12 @@ class StraightCoupler(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the StraightCoupler component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.length) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -539,6 +557,12 @@ class Standard(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the standard-shaped directional coupler component based on component type, and component parameters."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.length) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -609,6 +633,12 @@ class DoubleHalfRing(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the DoubleHalfRing component based on component type, gap, radius, thickness, couple length, and width."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.radius) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -677,6 +707,12 @@ class AngledHalfRing(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash for the AngledHalfRing component based on component type, gap, radius, thickness, couple length, and width."""

return hash(hash(type(self)) + hash(self.model.gap) + hash(self.model.radius) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.theta) + hash(self.model.sw_angle))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -744,6 +780,12 @@ def __init__(
**kwargs
)

def __hash__(self) -> int:

"""Gets a hash for the staright waveguide component based on component type, gap, radius, thickness, couple length, and width."""

return hash(hash(type(self)) + hash(self.model.thickness) + hash(self.model.width) + hash(self.model.length) + hash(self.model.sw_angle))


class Racetrack(SipannWrapper):
"""Racetrack waveguide arc, used to connect to a racetrack directional
Expand Down Expand Up @@ -789,6 +831,12 @@ class Racetrack(SipannWrapper):

pin_count = 2

def __hash__(self) -> int:

"""Gets a hash for the Racetrack component based on component type, gap, radius, thickness, couple length, and width."""

return hash(hash(type(self)) + hash(self.gap) + hash(self.radius) + hash(self.thickness) + hash(self.width) + + hash(self.length) + hash(self.sw_angle) + hash(self.sigmas))

def __init__(
self,
width: Union[float, np.array],
Expand Down Expand Up @@ -831,6 +879,12 @@ class PremadeCoupler(SipannWrapper):

pin_count = 4

def __hash__(self) -> int:

"""Gets a hash value for the premade coupler component based on type, and 'split' parameter value."""

return hash(hash(type(self)) + hash(self.split))

def __init__(self, split: int, sigmas: Dict[str, float] = dict(), **kwargs) -> None:
"""Loads the premade coupler based on the given split value.

Expand Down
5 changes: 5 additions & 0 deletions simphony/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ class Model:
pins: ClassVar[Optional[Tuple[str, ...]]]
pins: PinList # additional type hint for instance.pins

def __hash__(self) -> int:
"""Gets a hash for the model based on pin count and freq range."""

return hash(hash(self.pin_count) + hash(self.freq_range))

def __getitem__(self, item: Union[int, str]) -> Pin:
return self.pins[item]

Expand Down
Loading