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

Using list comp #291

Merged
merged 4 commits into from
Jan 3, 2022
Merged
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions mltrace/db/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,10 +1114,8 @@ def compute_metric_from_view(
stmt = "SELECT feedback_value, output_value FROM {}".format(view_name)
res = self.session.execute(stmt).fetchall()

y_true = []
y_pred = []
for elem in res:
y_true.append(float(elem[0]))
y_pred.append(float(elem[1]))
# Apply the function to each pair of outputs and feedback
y_true = [float(out[0]) for out in res]
y_pred = [float(out[1]) for out in res]

return metric_fn(y_true, y_pred)
7 changes: 5 additions & 2 deletions tests/test_dags.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ def testStaleTime(self):

# Create first component
cr = self.store.initialize_empty_component_run("component_1")
cr.set_start_timestamp(now.replace(month=now.month - 2))
start_month = now.month - 2 if now.month > 2 else (12 + now.month) - 2
start_year = now.year if now.month > 2 else now.year - 1
start_date = now.replace(month=start_month, year=start_year)
cr.set_start_timestamp(start_date)
cr.set_end_timestamp()
cr.add_input(iop1)
cr.add_output(iop2)
Expand All @@ -229,7 +232,7 @@ def testStaleTime(self):
2,
[
"component_1 (ID 1) was run "
+ f"{(now - now.replace(month=now.month - 2)).days} days"
+ f"{(now - start_date).days} days"
+ " ago."
],
),
Expand Down