Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0730eb1
bumped vega embed version
franzhaas Apr 21, 2025
270fb61
- bumped at referenced places
franzhaas Apr 21, 2025
601fff9
- more
franzhaas Apr 21, 2025
919c538
- bumped vegalite
franzhaas Apr 22, 2025
45237a1
- moved from 5 to 6
franzhaas Apr 22, 2025
de33ed4
update tools
mattijn Apr 25, 2025
efae777
more tools
mattijn Apr 25, 2025
db94f28
changes to sphinx extension
mattijn Apr 25, 2025
d690ba0
renamed tests
mattijn Apr 25, 2025
42c744a
changes docs
mattijn Apr 25, 2025
e317393
auto generated files mods
mattijn Apr 25, 2025
650e2ef
changes to chore
mattijn Apr 25, 2025
a798ddc
python changes
mattijn Apr 25, 2025
9f0bfff
more python changes
mattijn Apr 25, 2025
2aeb0ca
first line is written by `update_vega_embed` function within `version…
mattijn Apr 25, 2025
e783706
- bumped vegalite
franzhaas Apr 22, 2025
92b5204
- moved from 5 to 6
franzhaas Apr 22, 2025
2819d47
update tools
mattijn Apr 25, 2025
4ff40c3
more tools
mattijn Apr 25, 2025
f350603
changes to sphinx extension
mattijn Apr 25, 2025
39a74ae
renamed tests
mattijn Apr 25, 2025
e5170a4
changes docs
mattijn Apr 25, 2025
04efccc
auto generated files mods
mattijn Apr 25, 2025
7ecffad
changes to chore
mattijn Apr 25, 2025
6490e0d
python changes
mattijn Apr 25, 2025
1262ec0
more python changes
mattijn Apr 25, 2025
3f52e71
first line is written by `update_vega_embed` function within `version…
mattijn Apr 25, 2025
d306fb7
build: run `generate-schema-wrapper`
dangotbanned Apr 28, 2025
4ee5e89
Merge branch 'bumpvegalight' of https://github.com/franzhaas/altair i…
mattijn Apr 30, 2025
6630d8b
bump vlc to 1.8.0
mattijn Jun 1, 2025
8fbddfd
vega & vl to 6
mattijn Jun 1, 2025
4126246
add new expressions
mattijn Jun 1, 2025
d521b6c
catch inf recursion
mattijn Jun 1, 2025
c5376c5
update test to new height
mattijn Jun 1, 2025
9ed9643
had to remove the `+` after `v6`
mattijn Jun 1, 2025
bf320d7
catch py3.13: BufferError: Existing exports of data: object cannot be…
mattijn Jun 1, 2025
5137efb
Merge branch 'main' of https://github.com/vega/altair into pr/franzha…
mattijn Jun 1, 2025
2d4531d
apply changes within tools
mattijn Jun 1, 2025
246b4ee
picnic?
mattijn Jun 3, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ jobs:
# uri-reference check is disabled as the URIs in the Vega-Lite schema do
# not conform RFC 3986.
uv pip install 'jsonschema[format]' check-jsonschema --upgrade
uv run check-jsonschema --check-metaschema altair/vegalite/v5/schema/vega-lite-schema.json --disable-formats uri-reference
uv run check-jsonschema --check-metaschema altair/vegalite/v6/schema/vega-lite-schema.json --disable-formats uri-reference
4 changes: 2 additions & 2 deletions NOTES_FOR_MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

The core Python API for Altair can be found in the following locations:

- ``altair/vegalite/v5/schema/``
- ``altair/vegalite/v6/schema/``

All the files within these directories are created automatically by running
the following script:
Expand Down Expand Up @@ -81,7 +81,7 @@ The Vega-Lite version for the Python code propagates to `tools.generate_schema_w
This will update all of the automatically-generated files in the ``schema``
directory for each version, but please note that it will *not* update other
pieces (for example, the core of the Altair API, including methods and
doc strings within ``altair/vegalite/v5/api.py``).
doc strings within ``altair/vegalite/v6/api.py``).
These additional methods have fairly good test coverage, so running the test
suite should identify any inconsistencies:

Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

12. On main, tag the release. If you work on a fork, replace `origin` with `upstream`:

git tag -a v5.0.0 -m "Version 5.0.0 release"
git push origin v5.0.0
git tag -a v6.0.0 -m "Version 5.0.0 release"
git push origin v6.0.0

13. Create a new branch:

Expand Down
11 changes: 9 additions & 2 deletions altair/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
"FoldTransform",
"FontStyle",
"FontWeight",
"Format",
"FormatConfig",
"Generator",
"GenericUnitSpecEncodingAnyMark",
Expand Down Expand Up @@ -389,6 +390,7 @@
"ScaleInvalidDataShowAsValuestrokeOpacity",
"ScaleInvalidDataShowAsValuestrokeWidth",
"ScaleInvalidDataShowAsValuetheta",
"ScaleInvalidDataShowAsValuetime",
"ScaleInvalidDataShowAsValuex",
"ScaleInvalidDataShowAsValuexOffset",
"ScaleInvalidDataShowAsValuey",
Expand All @@ -406,6 +408,7 @@
"ScaleInvalidDataShowAsstrokeOpacity",
"ScaleInvalidDataShowAsstrokeWidth",
"ScaleInvalidDataShowAstheta",
"ScaleInvalidDataShowAstime",
"ScaleInvalidDataShowAsx",
"ScaleInvalidDataShowAsxOffset",
"ScaleInvalidDataShowAsy",
Expand Down Expand Up @@ -489,6 +492,10 @@
"ThetaValue",
"TickConfig",
"TickCount",
"Time",
"TimeDef",
"TimeFieldDef",
"TimeFormatSpecifier",
"TimeInterval",
"TimeIntervalStep",
"TimeLocale",
Expand Down Expand Up @@ -632,7 +639,7 @@
"topo_feature",
"typing",
"utils",
"v5",
"v6",
"value",
"vconcat",
"vegalite",
Expand All @@ -647,7 +654,7 @@ def __dir__():


from altair.vegalite import *
from altair.vegalite.v5.schema.core import Dict
from altair.vegalite.v6.schema.core import Dict
from altair.jupyter import JupyterChart
from altair.expr import expr
from altair.utils import AltairDeprecationWarning, parse_shorthand, Undefined
Expand Down
14 changes: 7 additions & 7 deletions altair/_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
from IPython.core import magic_arguments
from narwhals.stable.v1.dependencies import is_pandas_dataframe

from altair.vegalite import v5 as vegalite_v5
from altair.vegalite import v6 as vegalite_v6

__all__ = ["vegalite"]

RENDERERS = {
"vega-lite": {
"5": vegalite_v5.VegaLite,
"6": vegalite_v6.VegaLite,
},
}


TRANSFORMERS = {
"vega-lite": {
"5": vegalite_v5.data_transformers,
"6": vegalite_v6.data_transformers,
},
}

Expand Down Expand Up @@ -66,21 +66,21 @@ def _get_variable(name: str) -> Any:
nargs="?",
help="local variablename of a pandas DataFrame to be used as the dataset",
)
@magic_arguments.argument("-v", "--version", dest="version", default="v5")
@magic_arguments.argument("-v", "--version", dest="version", default="v6")
@magic_arguments.argument("-j", "--json", dest="json", action="store_true")
def vegalite(line, cell) -> vegalite_v5.VegaLite:
def vegalite(line, cell) -> vegalite_v6.VegaLite:
"""
Cell magic for displaying vega-lite visualizations in CoLab.

%%vegalite [dataframe] [--json] [--version='v5']
%%vegalite [dataframe] [--json] [--version='v6']

Visualize the contents of the cell using Vega-Lite, optionally
specifying a pandas DataFrame object to be used as the dataset.

if --json is passed, then input is parsed as json rather than yaml.
"""
args = magic_arguments.parse_argstring(vegalite, line)
existing_versions = {"v5": "5"}
existing_versions = {"v6": "6"}
version = existing_versions[args.version]
assert version in RENDERERS["vega-lite"]
VegaLite = RENDERERS["vega-lite"][version]
Expand Down
54 changes: 53 additions & 1 deletion altair/expr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import TYPE_CHECKING, Any

from altair.expr.core import ConstExpression, FunctionExpression
from altair.vegalite.v5.schema.core import ExprRef as _ExprRef
from altair.vegalite.v6.schema.core import ExprRef as _ExprRef

if sys.version_info >= (3, 12):
from typing import override
Expand Down Expand Up @@ -172,8 +172,18 @@ class expr(_ExprRef, metaclass=_ExprMeta):
https://en.wikipedia.org/wiki/Continuous_uniform_distribution
.. _*unit*:
https://vega.github.io/vega/docs/api/time/#time-units
.. _ascending from Vega Utils:
https://vega.github.io/vega/docs/api/util/#ascending
.. _JavaScript's String.replace:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
.. _Base64:
https://developer.mozilla.org/en-US/docs/Glossary/Base64
.. _ASCII:
https://developer.mozilla.org/en-US/docs/Glossary/ASCII
.. _Window.btoa():
https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa
.. _Window.atob():
https://developer.mozilla.org/en-US/docs/Web/API/Window/atob
.. _d3-format specifier:
https://github.com/d3/d3-format/
.. _*units*:
Expand Down Expand Up @@ -1175,6 +1185,16 @@ def slice(
"""
return FunctionExpression("slice", (array, start, end))

@classmethod
def sort(cls, array: IntoExpression, /) -> Expression:
"""
Sorts the array in natural order using `ascending from Vega Utils`_.

.. _ascending from Vega Utils:
https://vega.github.io/vega/docs/api/util/#ascending
"""
return FunctionExpression("sort", (array,))

@classmethod
def span(cls, array: IntoExpression, /) -> Expression:
"""Returns the span of ``array``: the difference between the last and first elements, or *array[array.length-1] - array[0]*."""
Expand Down Expand Up @@ -1281,6 +1301,38 @@ def upper(cls, string: IntoExpression, /) -> Expression:
"""Transforms ``string`` to upper-case letters."""
return FunctionExpression("upper", (string,))

@classmethod
def btoa(cls, string: IntoExpression, /) -> Expression:
"""
Creates a `Base64`_-encoded `ASCII`_ string.

Same as JavaScript's `Window.alt.expr.btoa()`_.

.. _Base64:
https://developer.mozilla.org/en-US/docs/Glossary/Base64
.. _ASCII:
https://developer.mozilla.org/en-US/docs/Glossary/ASCII
.. _Window.alt.expr.btoa():
https://developer.mozilla.org/en-US/docs/Web/API/Window/btoa
"""
return FunctionExpression("btoa", (string,))

@classmethod
def atob(cls, string: IntoExpression, /) -> Expression:
"""
Decodes an `ASCII`_ string that was encoded with `Base64`_.

Same as JavaScript's `Window.alt.expr.atob()`_.

.. _ASCII:
https://developer.mozilla.org/en-US/docs/Glossary/ASCII
.. _Base64:
https://developer.mozilla.org/en-US/docs/Glossary/Base64
.. _Window.alt.expr.atob():
https://developer.mozilla.org/en-US/docs/Web/API/Window/atob
"""
return FunctionExpression("atob", (string,))

@classmethod
def merge(
cls, object1: IntoExpression, object2: IntoExpression = None, *args: Any
Expand Down
2 changes: 1 addition & 1 deletion altair/expr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from altair.utils import SchemaBase

if TYPE_CHECKING:
from altair.vegalite.v5.schema._typing import Map, PrimitiveValue_T
from altair.vegalite.v6.schema._typing import Map, PrimitiveValue_T

if sys.version_info >= (3, 10):
from typing import TypeAlias
Expand Down
2 changes: 1 addition & 1 deletion altair/jupyter/js/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import vegaEmbed from "https://esm.sh/vega-embed@7?deps=vega@5&deps=vega-lite@5.21.0";
import vegaEmbed from "https://esm.sh/vega-embed@v7?deps=vega@6&deps=vega-lite@6.1.0";
import lodashDebounce from "https://esm.sh/lodash-es@4.17.21/debounce";

// Note: For offline support, the import lines above are removed and the remaining script
Expand Down
4 changes: 2 additions & 2 deletions altair/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import TYPE_CHECKING, Any
from typing import overload as _overload

from altair.vegalite.v5.schema._config import (
from altair.vegalite.v6.schema._config import (
AreaConfigKwds,
AutoSizeParamsKwds,
AxisConfigKwds,
Expand Down Expand Up @@ -77,7 +77,7 @@
ViewBackgroundKwds,
ViewConfigKwds,
)
from altair.vegalite.v5.theme import themes as _themes
from altair.vegalite.v6.theme import themes as _themes

if TYPE_CHECKING:
import sys
Expand Down
4 changes: 2 additions & 2 deletions altair/typing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
]

from altair.utils.schemapi import Optional
from altair.vegalite.v5.api import ChartType, is_chart_type
from altair.vegalite.v5.schema.channels import (
from altair.vegalite.v6.api import ChartType, is_chart_type
from altair.vegalite.v6.schema.channels import (
ChannelAngle,
ChannelColor,
ChannelColumn,
Expand Down
4 changes: 2 additions & 2 deletions altair/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
from narwhals.stable.v1.typing import IntoExpr

from altair.utils._dfi_types import DataFrame as DfiDataFrame
from altair.vegalite.v5.schema._typing import StandardType_T as InferredVegaLiteType
from altair.vegalite.v6.schema._typing import StandardType_T as InferredVegaLiteType

_PandasDataFrameT = TypeVar("_PandasDataFrameT", bound="pd.DataFrame")

Expand Down Expand Up @@ -912,7 +912,7 @@ def _init_channel_to_name():
-------
mapping: dict[type[`<subclass of FieldChannelMixin and SchemaBase>`] | type[`<subclass of ValueChannelMixin and SchemaBase>`] | type[`<subclass of DatumChannelMixin and SchemaBase>`], str]
"""
from altair.vegalite.v5.schema import channels as ch
from altair.vegalite.v6.schema import channels as ch

mixins = ch.FieldChannelMixin, ch.ValueChannelMixin, ch.DatumChannelMixin

Expand Down
2 changes: 1 addition & 1 deletion altair/utils/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def is_data_type(obj: Any) -> TypeIs[DataType]:
# ==============================================================================

P = ParamSpec("P")
# NOTE: `Any` required due to the complexity of existing signatures imported in `altair.vegalite.v5.data.py`
# NOTE: `Any` required due to the complexity of existing signatures imported in `altair.vegalite.v6.data.py`
R = TypeVar("R", VegaLiteDataDict, Any)
DataTransformerType = Callable[Concatenate[DataType, P], R]

Expand Down
2 changes: 1 addition & 1 deletion altair/utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def default_renderer_base(
how to render the custom VegaLite MIME type listed above.
"""
# Local import to avoid circular ImportError
from altair.vegalite.v5.display import VEGA_MIME_TYPE, VEGALITE_MIME_TYPE
from altair.vegalite.v6.display import VEGA_MIME_TYPE, VEGALITE_MIME_TYPE

assert isinstance(spec, dict)
bundle: dict[str, str | dict] = {}
Expand Down
2 changes: 1 addition & 1 deletion altair/utils/mimebundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _spec_to_mimebundle_with_engine(
vg = spec
else:
vg = vlc.vegalite_to_vega(spec, vl_version=vl_version)
return {"application/vnd.vega.v5+json": vg}
return {"application/vnd.vega.v6+json": vg}
elif format == "svg":
if mode == "vega":
svg = vlc.vega_to_svg(
Expand Down
2 changes: 1 addition & 1 deletion altair/utils/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from altair.utils._vegafusion_data import using_vegafusion
from altair.utils.deprecation import deprecated_warn
from altair.vegalite.v5.data import data_transformers
from altair.vegalite.v6.data import data_transformers

from .mimebundle import spec_to_mimebundle

Expand Down
22 changes: 13 additions & 9 deletions altair/utils/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,17 @@ def _deduplicate_by_message(errors: ValidationErrorList) -> ValidationErrorList:

def _subclasses(cls: type[Any]) -> Iterator[type[Any]]:
"""Breadth-first sequence of all classes which inherit from cls."""
seen = set()
seen = {cls}
current_set = {cls}
while current_set:
seen |= current_set
current_set = set.union(*(set(cls.__subclasses__()) for cls in current_set))
for cls in current_set - seen:
yield cls
next_set = set()
for base in current_set:
for sub in base.__subclasses__():
if sub not in seen:
yield sub
seen.add(sub)
next_set.add(sub)
current_set = next_set


def _from_array_like(obj: Iterable[Any], /) -> list[Any]:
Expand Down Expand Up @@ -1688,11 +1692,11 @@ def with_property_setters(cls: type[TSchemaBase]) -> type[TSchemaBase]:
],
str,
] = {
"vega-datasets": "v2.11.0",
"vega-embed": "7",
"vega-lite": "v5.21.0",
"vega-datasets": "v3",
"vega-embed": "v7",
"vega-lite": "v6.1.0",
"vegafusion": "1.6.6",
"vl-convert-python": "1.7.0",
"vl-convert-python": "1.8.0",
}
"""
Version pins for non-``python`` `vega projects`_.
Expand Down
2 changes: 1 addition & 1 deletion altair/vegalite/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# ruff: noqa: F403
from .v5 import *
from .v6 import *
2 changes: 1 addition & 1 deletion altair/vegalite/api.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# ruff: noqa
from .v5.api import *
from .v6.api import *
2 changes: 1 addition & 1 deletion altair/vegalite/schema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Altair schema wrappers."""

# ruff: noqa: F403
from .v5.schema import *
from .v6.schema import *
Loading