Skip to content

Commit

Permalink
more type hints!
Browse files Browse the repository at this point in the history
  • Loading branch information
CDonnerer committed Jan 1, 2022
1 parent 5f7da5a commit b74d5b7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/shellplot/axis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Module that contains Axis class (usable for both x and y axis)
"""
from typing import Any, Optional
from typing import Optional

import numpy as np

from shellplot.utils import (
array_like,
difference_round,
is_datetime,
numpy_1d,
Expand All @@ -16,8 +17,6 @@
tolerance_round,
)

array_like = Any


class Axis:
"""Enables mapping from data to display / plot coordinates.
Expand Down
10 changes: 5 additions & 5 deletions src/shellplot/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from shellplot._plotting import PlotCall, Plotter, _barh, _boxplot, _hist, _plot
from shellplot.axis import Axis
from shellplot.drawing import LINE_STYLES, MARKER_STYLES, draw
from shellplot.utils import get_index, numpy_1d, numpy_2d, remove_any_nan
from shellplot.utils import array_like, get_index, numpy_1d, numpy_2d, remove_any_nan


def figure(figsize=None, **kwargs):
Expand Down Expand Up @@ -72,7 +72,7 @@ def _init_figure_elements(self):
self.markers = cycle(MARKER_STYLES.keys())
self.lines = cycle(LINE_STYLES.keys())

def plot(self, x, y, color=None, **kwargs):
def plot(self, x: array_like, y: array_like, color=None, **kwargs):
"""Plot x versus y as scatter.
Parameters
Expand Down Expand Up @@ -101,7 +101,7 @@ def plot(self, x, y, color=None, **kwargs):
call = PlotCall(func=_plot, args=[x, y], kwargs=kwargs)
self.plotter.add(call)

def hist(self, x, **kwargs):
def hist(self, x: array_like, **kwargs):
"""Plot a histogram of x
Parameters
Expand All @@ -117,7 +117,7 @@ def hist(self, x, **kwargs):
call = PlotCall(func=_hist, args=[x], kwargs=kwargs)
self.plotter.add(call)

def barh(self, x, **kwargs):
def barh(self, x: array_like, **kwargs):
"""Plot horizontal bars
Parameters
Expand All @@ -133,7 +133,7 @@ def barh(self, x, **kwargs):
call = PlotCall(func=_barh, args=[x], kwargs=kwargs)
self.plotter.add(call)

def boxplot(self, x, **kwargs):
def boxplot(self, x: array_like, **kwargs):
"""Plot a boxplot of x
Note that currently this makes a boxplot using the quantiles:
Expand Down
2 changes: 2 additions & 0 deletions src/shellplot/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import math
import os
from functools import singledispatch
from typing import Any

import numpy as np
import pandas as pd

__all__ = ["load_dataset"]

ANCHOR_DATETIME = np.datetime64("1970-01-01") # I remember the day well
array_like = Any


def load_dataset(name: str) -> pd.DataFrame:
Expand Down

0 comments on commit b74d5b7

Please sign in to comment.