Skip to content
Snippets Groups Projects
Commit 6bfd895c authored by Florstedt, Julius's avatar Florstedt, Julius
Browse files

Merge branch '29-confidential-issue' into 'main'

Resolve "Refactor/Documentation?"

Closes #29

See merge request !41
parents 7d42c098 ca024fd0
No related branches found
No related tags found
1 merge request!41Resolve "Refactor/Documentation?"
Pipeline #1631467 passed
......@@ -46,7 +46,7 @@ PloSe also allows for deserialization of JSON-ized plots into matplotlib.
:hidden:
:caption: Deserializing with PloSe
Deserializer
deserializer
json_deserializer
.. toctree::
......
This diff is collapsed.
......@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
import numpy as np
from matplotlib.axes import Axes as MplAxes
from matplotlib.figure import Figure as MplFigure
from mpl_toolkits.mplot3d.axes3d import Axes3D as MplAxes3D # type: ignore[import-untyped]
from mpl_toolkits.mplot3d.axes3d import Axes3D as MplAxes3D
from plot_serializer.model import (
BarTrace2D,
......
This diff is collapsed.
......@@ -9,13 +9,15 @@ from typing import (
overload,
)
from matplotlib.axes import Axes as MplAxes
from matplotlib.figure import Figure as MplFigure
from plot_serializer.matplotlib.axesproxy import AxesProxy, AxesProxy3D
from plot_serializer.serializer import Serializer
class MatplotlibSerializer(Serializer):
# Fancy way of properly type hinting the subplots method...
# Overload for when subplot_kw is provided, in our case when 3d axes is create
# as subplot_kw is used for a manner of attributes this only holds for the dimension specification and with other
# settings falsely flags the type as AxesProxy3D
@overload
def subplots(
self,
......@@ -27,10 +29,25 @@ class MatplotlibSerializer(Serializer):
squeeze: bool = True,
width_ratios: Optional[Sequence[float]] = None,
height_ratios: Optional[Sequence[float]] = None,
subplot_kw: None = None,
subplot_kw: Dict[str, Any],
gridspec_kw: Optional[Dict[str, Any]] = None,
**fig_kw: Any,
) -> Tuple[MplFigure, MplAxes]: ...
) -> Tuple[MplFigure, AxesProxy3D]: ...
@overload
def subplots(
self,
nrows: Literal[1] = 1,
ncols: Literal[1] = 1,
*,
sharex: Union[bool, Literal["none", "all", "row", "col"]] = False,
sharey: Union[bool, Literal["none", "all", "row", "col"]] = False,
squeeze: bool = True,
width_ratios: Optional[Sequence[float]] = None,
height_ratios: Optional[Sequence[float]] = None,
subplot_kw: Optional[Dict[str, Any]] = None,
gridspec_kw: Optional[Dict[str, Any]] = None,
**fig_kw: Any,
) -> Tuple[MplFigure, AxesProxy]: ...
@overload
def subplots(
self,
......
......@@ -36,7 +36,7 @@ class Axis(BaseModel):
logging.warning("%s is not set for Axis object.", msg)
@model_validator(mode="before")
def cast_numpy_types(cls: Any, values: Any) -> Any: # noqa: N805 # noqa: N805
def cast_numpy_types(cls: Any, values: Any) -> Any: # noqa: N805
def convert(value: Any) -> Any:
if isinstance(value, np.generic):
return value.item()
......@@ -342,9 +342,9 @@ class BarTrace2D(BaseModel):
class Box(BaseModel):
metadata: Metadata = {}
x_i: Any
tick_label: Any = None # used to be: Optional[str]
usermedian: Any = None # used to be: Optional[float]
conf_interval: Any = None # used to be: Optional[Tuple[float, float]]
tick_label: Any = None
usermedian: Any = None
conf_interval: Any = None
def emit_warnings(self) -> None:
msg: List[str] = []
......@@ -399,9 +399,9 @@ class BoxTrace2D(BaseModel):
class ErrorPoint2D(BaseModel):
metadata: Metadata = {}
x: Any # used to be: float
y: Any # used to be: float
xerr: Any # should always be: Optional[Tuple[float, float]], however matplotlib stub does not specify
x: Any
y: Any
xerr: Any
yerr: Any
def emit_warnings(self) -> None:
......
......@@ -62,10 +62,13 @@ module = [
"matplotlib",
"matplotlib.axes",
"matplotlib.pyplot",
"OMPython"
"OMPython",
"mpl_toolkits.*"
]
ignore_missing_imports = true
[tool.ruff]
line-length = 120
......
......@@ -3,6 +3,7 @@
{
"type": "pie",
"title": "My amazing pie",
"radius": 1.0,
"slices": [
{
"x": 15.0,
......
......@@ -3,6 +3,7 @@
{
"type": "pie",
"title": "Array-like pie",
"radius": 1.0,
"slices": [
{
"x": 15.0,
......
......@@ -3,6 +3,7 @@
{
"type": "pie",
"title": "",
"radius": 1.0,
"slices": [
{
"x": 15.0,
......
......@@ -9,6 +9,7 @@
"key": "value"
},
"title": "",
"radius": 1.0,
"slices": [
{
"x": 15.0,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment