Skip to content

Commit

Permalink
MAINT: Change OrderedDict to dict
Browse files Browse the repository at this point in the history
  • Loading branch information
has2k1 committed Sep 6, 2020
1 parent 8703d1b commit 9deef42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
17 changes: 10 additions & 7 deletions plotnine/doctools.py
@@ -1,6 +1,5 @@
import re
from textwrap import indent, dedent, wrap
from collections import OrderedDict
from functools import lru_cache

import numpy as np
Expand Down Expand Up @@ -287,7 +286,7 @@ def parameters_str_to_dict(param_section):
Returns
-------
d : OrderedDict
d : dict
Dictionary of the parameters in the order that they
are described in the parameters section. The dict
is of the form ``{param: all_parameter_text}``.
Expand All @@ -298,7 +297,7 @@ def parameters_str_to_dict(param_section):
--------
:func:`parameters_dict_to_str`
"""
d = OrderedDict()
d = {}
previous_param = None
param_desc = None
for line in param_section.split('\n'):
Expand Down Expand Up @@ -388,8 +387,10 @@ def document_geom(geom):
usage = GEOM_SIGNATURE_TPL.format(signature=signature)

# aesthetics
contents = OrderedDict(('**{}**'.format(ae), '')
for ae in sorted(geom.REQUIRED_AES))
contents = {
'**{}**'.format(ae): ''
for ae in sorted(geom.REQUIRED_AES)
}
if geom.DEFAULT_AES:
d = geom.DEFAULT_AES.copy()
d['group'] = '' # All geoms understand the group aesthetic
Expand Down Expand Up @@ -437,8 +438,10 @@ def document_stat(stat):
usage = STAT_SIGNATURE_TPL.format(signature=signature)

# aesthetics
contents = OrderedDict(('**{}**'.format(ae), '')
for ae in sorted(stat.REQUIRED_AES))
contents = {
'**{}**'.format(ae): ''
for ae in sorted(stat.REQUIRED_AES)
}
contents.update(sorted(stat.DEFAULT_AES.items()))
table = dict_to_table(('Aesthetic', 'Default value'), contents)
aesthetics_table = AESTHETICS_TABLE_TPL.format(table=table)
Expand Down
3 changes: 1 addition & 2 deletions plotnine/guides/guide_legend.py
@@ -1,7 +1,6 @@
import hashlib
import types
from itertools import islice
from collections import OrderedDict
from contextlib import suppress
from warnings import warn

Expand Down Expand Up @@ -70,7 +69,7 @@ def train(self, scale, aesthetic=None):
aesthetic = scale.aesthetics[0]

breaks = scale.get_breaks()
if isinstance(breaks, OrderedDict):
if isinstance(breaks, dict):
if all([np.isnan(x) for x in breaks.values()]):
return None
elif not len(breaks) or all(np.isnan(breaks)):
Expand Down
3 changes: 1 addition & 2 deletions plotnine/scales/scale.py
@@ -1,6 +1,5 @@
from contextlib import suppress
from copy import deepcopy, copy
from collections import OrderedDict
from functools import partial
from types import SimpleNamespace as NS
from warnings import warn
Expand Down Expand Up @@ -492,7 +491,7 @@ def get_breaks(self, limits=None, strict=True):
in_domain = breaks
pos = match(in_domain, breaks)
tups = zip(in_domain, pos)
return OrderedDict(sorted(tups, key=lambda t: t[1]))
return dict(sorted(tups, key=lambda t: t[1]))

def get_labels(self, breaks=None):
"""
Expand Down

0 comments on commit 9deef42

Please sign in to comment.