Skip to content

Commit

Permalink
Merge pull request #99 from e10v/dev
Browse files Browse the repository at this point in the history
Deprecate all extras
  • Loading branch information
e10v authored Jul 12, 2023
2 parents aa62a2b + 835aac6 commit c691af7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
34 changes: 7 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,21 @@ More on the topic:

## Installation

Install the core functionality:
```bash
pip install rico
```

The core functionality has no dependencies other than the standard Python packages. Optional additional dependencies are required to support the following content types:
* Plots. Altair, Matplotlib Pyplot and Seaborn are currently supported.
**rico** has no dependencies other than the standard Python packages.

Install one or several extras to use plots or Markdown in HTML documents.

[Altair](https://altair-viz.github.io/):
```bash
pip install rico[altair]
```

[Matplotlib Pyplot](https://matplotlib.org/):
```bash
pip install rico[pyplot]
```

[Seaborn](https://seaborn.pydata.org/):
```bash
pip install rico[seaborn]
```
### Deprecated

Install `rico[seaborn]` extra only to use the [seaborn.objects](https://seaborn.pydata.org/tutorial/objects_interface.html) interface. Otherwise install `rico[pyplot]` as the old Seaborn plotting functions return Matplotlib Pyplot Axes objects.
Optional additional dependencies were required to support the following content types:
* Plots (`rico[altair]`, `rico[pyplot]`, `rico[seaborn]`).
* Markdown (`rico[markdown]`).

All extras:
```bash
pip install rico[complete]
```

### Deprecated
The `rico[complete]` extra incudes all the dependencies above.

There is also the `rico[markdown]` extra. But it's no longer needed and will be removed in version 0.4.0.
They are no longer needed and will be removed in version 0.4.0.

## User guide

Expand Down
26 changes: 23 additions & 3 deletions src/rico/_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io
from typing import TYPE_CHECKING
import urllib.request
import warnings
import xml.etree.ElementTree as ET

import rico._config
Expand Down Expand Up @@ -251,9 +252,14 @@ def __init__(
"""Create an HTML element from a plot object and wrap it in a <div> container.
The supported plot types are the following:
- Altair Chart,
- Pyplot Axes and Figure,
- Seaborn Plot (seaborn.objects interface).
- Matplotlib Pyplot Axes and Figure,
- [Deprecated] Altair Chart,
- [Deprecated] Seaborn Plot (seaborn.objects interface).
Deprecated:
Support of the Seaborn plots in this class/method is deprecated
and will be removed in version 0.4.0.
Use the rico.Obj or obj.append indstead.
Args:
obj: The plot object.
Expand All @@ -277,10 +283,24 @@ def __init__(
obj.savefig(stream, format=format, **kwargs)
image = stream.getvalue()
elif so is not None and isinstance(obj, so.Plot):
warnings.warn(
"Support of the Seaborn plots in this class/method is deprecated "
"and will be removed in version 0.4.0. "
"Use the rico.Obj or obj.append indstead.",
DeprecationWarning,
stacklevel=2,
)
stream = io.StringIO() if format == "svg" else io.BytesIO()
obj.save(stream, format=format, **kwargs)
image = stream.getvalue()
elif alt is not None and isinstance(obj, alt.TopLevelMixin):
warnings.warn(
"Support of the Altair plots in this class/method is deprecated "
"and will be removed in version 0.4.0. "
"Use the rico.Obj or obj.append indstead.",
DeprecationWarning,
stacklevel=2,
)
convert = vlc.vegalite_to_svg if format == "svg" else vlc.vegalite_to_png # type: ignore # noqa: E501
image = convert( # type: ignore
obj.to_json(), # type: ignore
Expand Down

0 comments on commit c691af7

Please sign in to comment.