Skip to content

Use lyse.data()'s new n_sequences argument when possible #7

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: master
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
15 changes: 13 additions & 2 deletions mloop_multishot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def verify_globals(config):
requested_dict = dict(zip(config['mloop_params'], requested_values))

# Get the parameter values for the shot we just computed the cost for
df = lyse.data()
df = _get_dataframe()
shot_values = [df[name].iloc[-1] for name in config['mloop_params']]

# Verify integrity by cross-checking against what was requested
Expand All @@ -61,6 +61,17 @@ def verify_globals(config):
return True


def _get_dataframe():
"""Get the lyse dataframe, using n_sequences if lyse supports it."""
try:
df = lyse.data(n_sequences=1)
except (TypeError, ValueError):
# TypeError is raised if client's lyse doesn't support n_sequences and
# ValueError is raised if server's lyse doesn't support n_sequences.
df = lyse.data()
return df


def cost_analysis(cost_key=(None,), maximize=True, x=None):
"""Return a cost dictionary to M-LOOP with at least:
{'bad': True} or {'cost': float}.
Expand All @@ -73,7 +84,7 @@ def cost_analysis(cost_key=(None,), maximize=True, x=None):
cost_dict = {'bad': False}

# Retrieve current lyse DataFrame
df = lyse.data()
df = _get_dataframe()

# Use the most recent shot
ix = -1
Expand Down