Skip to content

Commit

Permalink
Merge pull request #30 from BYUCamachoLab/Version-2.0.0
Browse files Browse the repository at this point in the history
Bump Version 1.4.0 -> 2.0.0
  • Loading branch information
SkandanC authored Jul 7, 2022
2 parents 1e37e48 + a5971b3 commit 27dfe52
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.4.0
current_version = 2.0.0
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)?
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration-pip-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7]
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7]
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
**************************
SiPANN 1.4.0
SiPANN 2.0.0
**************************
.. image:: https://img.shields.io/pypi/v/SiPANN.svg
:target: https://pypi.python.org/pypi/SiPANN
Expand Down
5 changes: 4 additions & 1 deletion SiPANN/LR/regress.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
print("Multivariate linear regression MSE: {:e}".format(MSE_REGRESION))

# Save so our ImportLR can use it
d = {"coef_": model.named_steps["linear"].coef_, "degree_": model.named_steps["poly"].degree}
d = {
"coef_": model.named_steps["linear"].coef_,
"degree_": model.named_steps["poly"].degree,
}

n_features = model.named_steps["poly"].n_input_features_
n_out = 1 if len(d["coef_"].shape) == 1 else d["coef_"].shape[0]
Expand Down
2 changes: 1 addition & 1 deletion SiPANN/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
photonic device circuits.
"""

__version__ = "1.4.0"
__version__ = "2.0.0"
__author__ = "Easton Potokar, Alec Hammond, R Scott Collings <[email protected]>"
__all__ = []
11 changes: 3 additions & 8 deletions SiPANN/comp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings
from abc import ABC
from abc import abstractmethod
from abc import ABC, abstractmethod

import gdspy
import numpy as np
Expand All @@ -9,12 +8,8 @@
import scipy.special as special

from SiPANN.import_nn import ImportLR
from SiPANN.nn import bentWaveguide
from SiPANN.nn import straightWaveguide
from SiPANN.scee import clean_inputs
from SiPANN.scee import get_coeffs
from SiPANN.scee import HalfRacetrack

from SiPANN.nn import bentWaveguide, straightWaveguide
from SiPANN.scee import HalfRacetrack, clean_inputs, get_coeffs

"""
Similarly to before, we initialize all ANN's and regressions as global objects to speed things up.
Expand Down
9 changes: 7 additions & 2 deletions SiPANN/import_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,18 @@ def __init__(self, directory):
self.sess = tf.compat.v1.Session(graph=self.graph)
with self.graph.as_default():
# Import graph
imported_meta = tf.compat.v1.train.import_meta_graph(f"{directory}/model.meta")
imported_meta = tf.compat.v1.train.import_meta_graph(
f"{directory}/model.meta"
)
imported_meta.restore(self.sess, f"{directory}/model")

# get all tensor names
self.output_tf = self.graph.get_tensor_by_name("OUTPUT:0")
self.input_tf = self.graph.get_tensor_by_name("INPUT:0")
self.input_tf_parts = [self.graph.get_tensor_by_name(f"INPUT_{i}:0") for i in range(self.s_data[0])]
self.input_tf_parts = [
self.graph.get_tensor_by_name(f"INPUT_{i}:0")
for i in range(self.s_data[0])
]

self.keep_prob = self.graph.get_tensor_by_name("KEEP_PROB:0")
tf.compat.v1.disable_eager_execution()
Expand Down
3 changes: 1 addition & 2 deletions SiPANN/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import pkg_resources
import skrf as rf
from scipy.interpolate import UnivariateSpline
from scipy.signal import find_peaks
from scipy.signal import peak_widths
from scipy.signal import find_peaks, peak_widths

from SiPANN import import_nn

Expand Down
62 changes: 53 additions & 9 deletions SiPANN/scee.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings
from abc import ABC
from abc import abstractmethod
from abc import ABC, abstractmethod

import gdspy
import numpy as np
Expand Down Expand Up @@ -32,7 +31,7 @@ def get_neff(wavelength, width, thickness, sw_angle=90):
wavelength (Valid for 1450nm-1650nm)
width: float or ndarray
width (Valid for 400nm-600nm)
thickness: float or ndarray
thickness: float or ndarray
thickness (Valid for 180nm-240nm)
sw_angle: float or ndarray
sw_angle (Valid for 80-90 degrees)
Expand Down Expand Up @@ -812,7 +811,13 @@ def predict(self, ports, wavelength):
# determine z distance
if 1 in ports and 3 in ports:
z_dist = 2 * (radius + width / 2)
elif 1 in ports and 4 in ports or (2 not in ports or 4 not in ports) and 2 in ports and 3 in ports:
elif (
1 in ports
and 4 in ports
or (2 not in ports or 4 not in ports)
and 2 in ports
and 3 in ports
):
z_dist = np.pi * radius / 2 + radius + width / 2
elif 2 in ports and 4 in ports:
z_dist = np.pi * radius
Expand Down Expand Up @@ -997,7 +1002,13 @@ def predict(self, ports, wavelength):
# determine z distance
if 1 in ports and 3 in ports:
z_dist = 2 * (radius + width / 2) + length
elif 1 in ports and 4 in ports or (2 not in ports or 4 not in ports) and 2 in ports and 3 in ports:
elif (
1 in ports
and 4 in ports
or (2 not in ports or 4 not in ports)
and 2 in ports
and 3 in ports
):
z_dist = np.pi * radius / 2 + radius + width / 2 + length
elif 2 in ports and 4 in ports:
z_dist = np.pi * radius + length
Expand Down Expand Up @@ -1171,7 +1182,16 @@ def predict(self, ports, wavelength):
offset = np.pi / 2

# determine z distance
if 1 in ports and 3 in ports or 1 in ports and 4 in ports or 2 in ports and 4 in ports or 2 in ports and 3 in ports:
if (
1 in ports
and 3 in ports
or 1 in ports
and 4 in ports
or 2 in ports
and 4 in ports
or 2 in ports
and 3 in ports
):
z_dist = length
else:
return np.zeros(len(wavelength))
Expand Down Expand Up @@ -1363,7 +1383,16 @@ def predict(self, ports, wavelength):
z_dist = length + 2 * np.sqrt(
H ** 2 + (V * np.pi / 2) ** 2
) / np.pi * special.ellipeinc(np.pi, m)
if 1 in ports and 3 in ports or 1 in ports and 4 in ports or 2 in ports and 4 in ports or 2 in ports and 3 in ports:
if (
1 in ports
and 3 in ports
or 1 in ports
and 4 in ports
or 2 in ports
and 4 in ports
or 2 in ports
and 3 in ports
):
z_dist = z_dist
else:
return np.zeros(len(wavelength))
Expand Down Expand Up @@ -1555,7 +1584,16 @@ def predict(self, ports, wavelength):
offset = np.pi / 2

# determine z distance
if 1 in ports and 3 in ports or 1 in ports and 4 in ports or 2 in ports and 4 in ports or 2 in ports and 3 in ports:
if (
1 in ports
and 3 in ports
or 1 in ports
and 4 in ports
or 2 in ports
and 4 in ports
or 2 in ports
and 3 in ports
):
z_dist = np.pi * radius
else:
return np.zeros(len(wavelength))
Expand Down Expand Up @@ -1699,7 +1737,13 @@ def predict(self, ports, wavelength):
# determine z distance
if 1 in ports and 3 in ports:
z_dist = np.pi * (radius + width + gap)
elif 1 in ports and 4 in ports or (2 not in ports or 4 not in ports) and 2 in ports and 3 in ports:
elif (
1 in ports
and 4 in ports
or (2 not in ports or 4 not in ports)
and 2 in ports
and 3 in ports
):
z_dist = np.pi * (radius + width + gap) / 2 + np.pi * radius / 2
elif 2 in ports and 4 in ports:
z_dist = np.pi * radius
Expand Down
20 changes: 15 additions & 5 deletions SiPANN/scee_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from simphony import Model
from simphony.layout import Circuit
from simphony.pins import Pin, PinList
from simphony.tools import freq2wl
from simphony.tools import wl2freq
from simphony.tools import freq2wl, wl2freq

########################################################################
####### This file contains integration of SCEE into various other ######
Expand Down Expand Up @@ -41,7 +40,9 @@ def export_interconnect(sparams, wavelength, filename, clear=True):
temp = np.vstack((freq, np.abs(sp), np.unwrap(np.angle(sp)))).T

# Save header
header = f'("port {out+1}", "TE", 1, "port {in_+1}", 1, "transmission")\n'
header = (
f'("port {out+1}", "TE", 1, "port {in_+1}", 1, "transmission")\n'
)
header += f"{temp.shape}"

# save data
Expand All @@ -67,7 +68,14 @@ class SimphonyWrapper(Model):
def __init__(self, model, sigmas=dict()):
self.model = model
self.sigmas = sigmas
self.pins = PinList([Pin(self.model, "n1"), Pin(self.model, "n2"), Pin(self.model, "n3"), Pin(self.model, "n4")]) #: The default pin names of the device
self.pins = PinList(
[
Pin(self.model, "n1"),
Pin(self.model, "n2"),
Pin(self.model, "n3"),
Pin(self.model, "n4"),
]
) #: The default pin names of the device
self.model.pins = self.pins
self.model.circuit = Circuit(self.model)

Expand All @@ -78,7 +86,9 @@ def __init__(self, model, sigmas=dict()):

self.model.s_parameters = self.s_parameters
self.model.monte_carlo_s_parameters = self.monte_carlo_s_parameters
self.model.regenerate_monte_carlo_parameters = self.regenerate_monte_carlo_parameters
self.model.regenerate_monte_carlo_parameters = (
self.regenerate_monte_carlo_parameters
)

# save actual parameters for switching back from monte_carlo
self.og_params = self.model.__dict__.copy()
Expand Down
12 changes: 4 additions & 8 deletions SiPANN/scee_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@

import matplotlib.pyplot as plt
import numpy as np
from numba import njit
from numba import vectorize
from numba import njit, vectorize
from numba.extending import get_cython_function_address
from scipy import special
from tables import ComplexCol
from tables import Float64Col
from tables import IsDescription
from tables import open_file
from tables import ComplexCol, Float64Col, IsDescription, open_file
from tqdm import tqdm

from SiPANN import scee
Expand Down Expand Up @@ -44,7 +40,7 @@ def bernstein_quick(n, j, t):
test : float
Result of computing the jth berstein polynomial at t
"""
return binom_fn(n, j) * t**j * (1 - t) ** (n - j)
return binom_fn(n, j) * t ** j * (1 - t) ** (n - j)


def bezier_quick(g, length):
Expand Down Expand Up @@ -104,7 +100,7 @@ def bezier_quick(g, length):
),
axis=0,
)
/ length**2,
/ length ** 2,
}


Expand Down
14 changes: 14 additions & 0 deletions docs/changelog/2.0.0-changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## 2.0.0 - 2022-07-06

Maintenance update and drop support for Python 3.6.

### Added
- None

### Changed
- Bug fix for `SimphonyWrapper` class in `scee_int.py`. Changed tuple of `str` to `PinList`. [Check this PR for more details.](https://github.com/BYUCamachoLab/SiPANN/pull/24)
- Bug fix in `nn.py` [See here for more info.](https://github.com/BYUCamachoLab/SiPANN/pull/29)
- Code cleanup [See here for more info.](https://github.com/BYUCamachoLab/SiPANN/pull/27)

### Removed
- Support for Python 3.6
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
author = "Easton Potokar, R Scott Collings, Alec Hammond"

# The full version, including alpha/beta/rc tags
release = "1.4.0"
release = "2.0.0"


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/Tutorials/export_to_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def convert_jupyter(file):

# remove previous and move data to static
filename = file.split(".")[0]
files = fr"{filename}_files"
files = rf"{filename}_files"
os.system(f"rm -rf ../../docs/source/tutorials/{files}")
os.system(f"cp -r {files} ../../docs/source/tutorials")
os.system(f"rm {files}/**_**_**.png")
Expand Down
3 changes: 1 addition & 2 deletions examples/racetrack.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import matplotlib.pyplot as plt
import numpy as np

from SiPANN import comp
from SiPANN import dc
from SiPANN import comp, dc

# units in nanometers
r = 12e3
Expand Down
17 changes: 8 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
from io import open
from os import path

from setuptools import find_packages
from setuptools import setup
from setuptools import find_packages, setup

# io.open is needed for projects that support Python 2.7
# It ensures open() defaults to text mode with universal newlines,
Expand Down Expand Up @@ -38,7 +37,7 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version="1.4.0", # Required
version="2.0.0", # Required
# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
# https://packaging.python.org/specifications/core-metadata/#summary
Expand Down Expand Up @@ -91,8 +90,10 @@
# Specify the Python versions you support here. In particular, ensure
# that you indicate whether you support Python 2, Python 3 or both.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
# This field adds keywords for your project which will appear on the
# project page. What does your project relate to?
Expand Down Expand Up @@ -131,12 +132,10 @@
"gdspy >= 1.5.2",
"scikit-rf",
"numba",
"numpy<1.22",
"numpy>=1.22;python_version>='3.8'",
"numpy<1.22;python_version=='3.7'",
"simphony",
"nlopt<=2.7.1;python_version=='3.7'",
"nlopt<=2.7.0;python_version=='3.8'",
"nlopt==2.7.0;python_version=='3.9'",
"nlopt<2.7.0;python_version=='3.10'",
"nlopt==2.7.1",
"matplotlib",
"tables",
"tqdm",
Expand Down

0 comments on commit 27dfe52

Please sign in to comment.