Skip to content

Add function to get time-dependent coefficients separate from plot_coefficients() #24

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
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
38 changes: 21 additions & 17 deletions sequencing/sequencing/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,23 +412,7 @@ def propagator(
times.append(times[-1])
return props

def plot_coefficients(self, subplots=True, sharex=True, sharey=True):
"""Plot the Hamiltionian coefficients for all channels.
Unitaries are represented by vertical lines.

Args:
subplots (optional, bool): If True, plot each channel
on a different axis. Default: True.
sharex (optional, bool): Share x axes if subplots is True.
Default: True.
sharey (optional, bool): Share y axes if subplots is True.
Default: True.

Returns:
tuple: (fig, ax): matplotlib Figure and axes.
"""
import matplotlib.pyplot as plt

def get_coefficients(self):
self._t = 0
channels = {}
for item in self:
Expand Down Expand Up @@ -469,6 +453,26 @@ def plot_coefficients(self, subplots=True, sharex=True, sharey=True):
else:
channels[name] = (new_times, info["coeffs"])
channel_names = [n for n in channels if n not in ["delay", "unitary"]]
return channel_names, channels

def plot_coefficients(self, subplots=True, sharex=True, sharey=True):
"""Plot the Hamiltionian coefficients for all channels.
Unitaries are represented by vertical lines.

Args:
subplots (optional, bool): If True, plot each channel
on a different axis. Default: True.
sharex (optional, bool): Share x axes if subplots is True.
Default: True.
sharey (optional, bool): Share y axes if subplots is True.
Default: True.

Returns:
tuple: (fig, ax): matplotlib Figure and axes.
"""
import matplotlib.pyplot as plt

channel_names, channels = self.get_coefficients()
if not channel_names:
raise ValueError("There are no channels with coefficients to plot.")
if subplots:
Expand Down