Skip to content

Commit

Permalink
feat: update altair to 5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ankeko committed Jan 23, 2024
1 parent 686f55c commit 3243166
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 36 deletions.
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

0 comments on commit 3243166

Please sign in to comment.