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

feat: update altair to 5.2.0 #113

Merged
merged 1 commit into from
Jan 23, 2024
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
18 changes: 8 additions & 10 deletions niceml/utilities/chartutils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Module for chart utilities."""
from typing import List, Optional

import altair


def generate_hover_charts( # QUEST: still in use?
def generate_hover_charts( # noqa: PLR0913
source,
x_name: str,
text_name: str,
Expand All @@ -17,9 +18,7 @@ def generate_hover_charts( # QUEST: still in use?
if additional_layers is None:
additional_layers = []
# Create a selection that chooses the nearest point & selects based on x-value
nearest = altair.selection(
type="single", nearest=True, on="mouseover", fields=[x_name], empty="none"
)
nearest = altair.selection_point(nearest=True, on="mouseover", fields=[x_name])

# Transparent selectors across the chart. This is what tells us
# the x-value of the cursor
Expand All @@ -30,7 +29,7 @@ def generate_hover_charts( # QUEST: still in use?
x=x_name,
opacity=altair.value(0),
)
.add_selection(nearest)
.add_params(nearest)
)

# Draw points on the line, and highlight based on selection
Expand All @@ -56,7 +55,8 @@ def generate_hover_charts( # QUEST: still in use?
).properties(width=width, height=height)


def generate_chart(source, metric): # TODO: rename function and add docstrings
def generate_chart(source, metric):
"""Generates Altair chart"""
line = (
altair.Chart(source)
.mark_line()
Expand All @@ -68,9 +68,7 @@ def generate_chart(source, metric): # TODO: rename function and add docstrings
)

# Create a selection that chooses the nearest point & selects based on x-value
nearest = altair.selection(
type="single", nearest=True, on="mouseover", fields=["epoch"], empty="none"
)
nearest = altair.selection_point(nearest=True, on="mouseover", fields=["epoch"])

# Transparent selectors across the chart. This is what tells us
# the x-value of the cursor
Expand All @@ -81,7 +79,7 @@ def generate_chart(source, metric): # TODO: rename function and add docstrings
x="epoch",
opacity=altair.value(0),
)
.add_selection(nearest)
.add_params(nearest)
)

# Draw points on the line, and highlight based on selection
Expand Down
40 changes: 15 additions & 25 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ scipy = ">=1.8"
protobuf = "^3.0.0"


altair = {version = "^4.2.2", optional = true}
altair = {version = "^5.2.0", optional = true}
tensorflow-macos = {version = ">=2.13,<=2.14", optional = true}
streamlit = {version = "^1.28.0", optional = true}
tensorflow = {version = ">=2.13,<=2.15", optional = true}
Expand Down