Skip to content

Commit

Permalink
Fix compatibility with Python 2, and make property order deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
astrofrog committed Jun 21, 2019
1 parent 8339f23 commit 2412e3c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions glue/core/state_objects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from __future__ import absolute_import, division, print_function

from textwrap import indent
import os

try:
from textwrap import indent
except ImportError: # PY2
def indent(text, prefix):
return os.linesep.join([prefix + line for line in text.splitlines()])

from collections import defaultdict

import numpy as np
Expand Down Expand Up @@ -84,7 +91,9 @@ def as_dict(self):

def __str__(self):
s = ""
for key, value in self.as_dict().items():
state_dict = self.as_dict()
for key in sorted(state_dict):
value = state_dict[key]
if np.isscalar(value):
s += "{0}: {1}\n".format(key, value)
else:
Expand Down

0 comments on commit 2412e3c

Please sign in to comment.