Skip to content

Commit

Permalink
Merge pull request #3030 from neutrinoceros/ordered_dict_no_more
Browse files Browse the repository at this point in the history
switch internal instances of collections.OrderedDict to regular dict
  • Loading branch information
cphyc committed Jan 22, 2021
2 parents aeb4947 + 8fbf151 commit 6dd525c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 11 deletions.
8 changes: 3 additions & 5 deletions doc/source/cookbook/simulation_analysis.py
@@ -1,5 +1,3 @@
import collections

import yt

yt.enable_parallelism()
Expand Down Expand Up @@ -27,13 +25,13 @@
# Fill the dictionary with extrema and redshift information for each dataset
data[ds.basename] = (extrema, ds.current_redshift)

# Convert dictionary to ordered dictionary to get the right order
od = collections.OrderedDict(sorted(data.items()))
# Sort dict by keys
data = {k: v for k, v in sorted(data.items())}

# Print out all the values we calculated.
print("Dataset Redshift Density Min Density Max")
print("---------------------------------------------------------")
for key, val in od.items():
for key, val in data.items():
print(
"%s %05.3f %5.3g g/cm^3 %5.3g g/cm^3"
% (key, val[1], val[0][0], val[0][1])
Expand Down
3 changes: 0 additions & 3 deletions yt/data_objects/particle_trajectories.py
@@ -1,5 +1,3 @@
from collections import OrderedDict

import numpy as np

from yt.config import ytcfg
Expand Down Expand Up @@ -69,7 +67,6 @@ def __init__(

if fields is None:
fields = []
fields = list(OrderedDict.fromkeys(fields))

if self.suppress_logging:
old_level = int(ytcfg.get("yt", "log_level"))
Expand Down
4 changes: 1 addition & 3 deletions yt/data_objects/profiles.py
Expand Up @@ -582,12 +582,10 @@ def to_dataframe(self, fields=None, only_used=False):
>>> df1 = p.to_dataframe()
>>> df2 = p.to_dataframe(fields="density", only_used=True)
"""
from collections import OrderedDict

import pandas as pd

idxs, masked, fields = self._export_prep(fields, only_used)
pdata = OrderedDict([(self.x_field[-1], self.x[idxs])])
pdata = {self.x_field[-1]: self.x[idxs]}
for field in fields:
pdata[field[-1]] = self[field][idxs]
df = pd.DataFrame(pdata)
Expand Down

0 comments on commit 6dd525c

Please sign in to comment.