Skip to content

Commit a031e0c

Browse files
committed
Fix documentation
1 parent 48b5685 commit a031e0c

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

mplaltair/_axis.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ def _set_limits(channel, scale):
99
1010
Parameters
1111
----------
12+
channel : dict
13+
The mapping of the channel data and metadata
1214
scale : dict
1315
The mapping of the scale metadata and the scale data
14-
1516
"""
1617

1718
_axis_kwargs = {
@@ -61,8 +62,20 @@ def _set_limits(channel, scale):
6162

6263
def _set_scale_type(channel, scale):
6364
"""If the scale is non-linear, change the scale and return appropriate axis limits.
64-
Note: The 'linear' and 'time' scale types are not included here because quantitative defaults to 'linear'
65-
and temporal defaults to 'time'. The 'utc' and 'sequential' are currently not supported.
65+
The 'linear' and 'time' scale types are not included here because quantitative defaults to 'linear'
66+
and temporal defaults to 'time'. The 'utc' and 'sequential' scales are currently not supported.
67+
68+
Parameters
69+
----------
70+
channel : dict
71+
The mapping of the channel data and metadata
72+
scale : dict
73+
The mapping of the scale metadata and the scale data
74+
75+
Returns
76+
-------
77+
lims : dict
78+
The axis limit mapped to the appropriate axis parameter for scales that change axis limit behavior
6679
"""
6780
lims = {}
6881
if scale['type'] == 'log':
@@ -107,9 +120,15 @@ def _set_scale_type(channel, scale):
107120

108121

109122
def _set_tick_locator(channel, axis):
110-
"""Set the tick locator if it needs to vary from the default"""
111-
# Works for quantitative and temporal
112-
# The auto locator has similar (if not the same) defaults as Altair
123+
"""Set the tick locator if it needs to vary from the default locator
124+
125+
Parameters
126+
----------
127+
channel : dict
128+
The mapping of the channel data and metadata
129+
axis : dict
130+
The mapping of the axis metadata and the scale data
131+
"""
113132
current_axis = {'x': channel['ax'].xaxis, 'y': channel['ax'].yaxis}
114133
if 'values' in axis:
115134
if channel['dtype'] == 'temporal':
@@ -125,6 +144,15 @@ def _set_tick_locator(channel, axis):
125144

126145

127146
def _set_tick_formatter(channel, axis):
147+
"""Set the tick formatter
148+
149+
Parameters
150+
----------
151+
channel : dict
152+
The mapping of the channel data and metadata
153+
axis : dict
154+
The mapping of the axis metadata and the scale data
155+
"""
128156
current_axis = {'x': channel['ax'].xaxis, 'y': channel['ax'].yaxis}
129157
format_str = ''
130158

mplaltair/_data.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def _handle_timeUnit():
6969

7070

7171
def _locate_channel_scale(chart, channel):
72-
"""Locates the channel's scale information. Note that this implementation is a little
73-
different (and a little cleaner) than the other locate functions in this module.
72+
"""Locates the channel's scale information.
7473
7574
Parameters
7675
----------
@@ -91,8 +90,7 @@ def _locate_channel_scale(chart, channel):
9190

9291

9392
def _locate_channel_axis(chart, channel):
94-
"""Locates the channel's scale information. Note that this implementation is a little
95-
different (and a little cleaner) than the other locate functions in this module.
93+
"""Locates the channel's scale information.
9694
9795
Parameters
9896
----------
@@ -116,13 +114,13 @@ def _convert_to_mpl_date(data):
116114
117115
Parameters
118116
----------
119-
data
120-
The data to be converted to a Matplotlib date.
117+
data : datetime.datetime, numpy.datetime64, str, Altair DateTime, or sequences of any of these
118+
The data to be converted to a Matplotlib date
121119
122120
Returns
123121
-------
124122
new_data : list
125-
A list containing the converted date(s).
123+
A list containing the converted date(s)
126124
"""
127125

128126
if cbook.iterable(data) and not isinstance(data, str) and not isinstance(data, dict):
@@ -143,7 +141,8 @@ def _convert_to_mpl_date(data):
143141

144142

145143
def _altair_DateTime_to_datetime(dt):
146-
"""Convert dictionary representation of an Altair DateTime to datetime object.
144+
"""Convert dictionary representation of an Altair DateTime to datetime object
145+
147146
Parameters
148147
----------
149148
dt : dict

mplaltair/tests/test_axis.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from .._axis import convert_axis
77
import pytest
88

9-
# from .._data import _locate_channel_dtype
10-
119
df_quant = pd.DataFrame({
1210
"a": [1, 2, 3], "b": [1.2, 2.4, 3.8], "c": [7, 5, -3],
1311
"s": [50, 100, 200.0], "alpha": [0, .5, .8], "shape": [1, 2, 3], "fill": [1, 2, 3],
@@ -24,14 +22,6 @@
2422
"combination": pd.to_datetime(['1/1/2015 00:00', '1/4/2016 10:00', '5/1/2016', '5/1/2016 10:10', '3/3/2016'])
2523
})
2624

27-
# def test_axis_dtype():
28-
# chart = alt.Chart(df_quant).mark_point().encode(alt.X('years'), alt.Y('a'))
29-
# mapping = convert(chart)
30-
# fig, ax = plt.subplots()
31-
# ax.scatter(**mapping)
32-
# convert_axis(ax, chart)
33-
# assert _locate_channel_dtype(chart, 'x') == 'temporal'
34-
3525

3626
@pytest.mark.xfail(raises=TypeError)
3727
def test_invalid_temporal():
@@ -190,7 +180,7 @@ def test_axis_scale_type_x_quantitative(column, type, base, exponent):
190180

191181

192182
@pytest.mark.mpl_image_compare(baseline_dir='baseline_images/test_axis')
193-
@pytest.mark.parametrize('column,type,base,exponent', [('log','log',10,1), ('log2','log',5,1)])
183+
@pytest.mark.parametrize('column,type,base,exponent', [('log', 'log', 10, 1), ('log2', 'log', 5, 1)])
194184
def test_axis_scale_type_y_quantitative(column, type, base, exponent):
195185
chart = alt.Chart(df_quant).mark_point().encode(
196186
alt.X('a'),

0 commit comments

Comments
 (0)