From 9deef427d9c47df292287895c5e33bb6423924fc Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Sun, 6 Sep 2020 23:58:32 +0300 Subject: [PATCH] MAINT: Change OrderedDict to dict --- plotnine/doctools.py | 17 ++++++++++------- plotnine/guides/guide_legend.py | 3 +-- plotnine/scales/scale.py | 3 +-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plotnine/doctools.py b/plotnine/doctools.py index ddc90b8c6..cf273b414 100644 --- a/plotnine/doctools.py +++ b/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 @@ -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}``. @@ -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'): @@ -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 @@ -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) diff --git a/plotnine/guides/guide_legend.py b/plotnine/guides/guide_legend.py index 35317c5fc..4fe7b11db 100644 --- a/plotnine/guides/guide_legend.py +++ b/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 @@ -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)): diff --git a/plotnine/scales/scale.py b/plotnine/scales/scale.py index 544d24222..16f4a548f 100644 --- a/plotnine/scales/scale.py +++ b/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 @@ -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): """