Skip to content

Commit

Permalink
Fix/issue 209 (#210)
Browse files Browse the repository at this point in the history
* Fix issue 209 by using repr as alternative sort key.

* Add unit test to catch issue #209.

* Update changelog.
  • Loading branch information
csadorf committed Jul 19, 2019
1 parent ce8562a commit 09a84d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ next
- Fix issue causing a failure of the automatic conversion of valid key types (#168, #205).
- Improve the 'dots in keys' error message to make it easier to fix related issues (#170, #205).
- Update the ``__repr__`` and ``__repr_html__`` implementations of the ``Project`, ``Job``, and ``JobsCursor`` classes (#193).

- Fix issue with heterogeneous types in state point values that are lists (#209).

[1.1.0] -- 2019-05-19
---------------------
Expand Down
5 changes: 4 additions & 1 deletion signac/contrib/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def _fmt_value(x):
return str(x)

def _fmt_range(type_, values):
sorted_values = sorted(values)
try:
sorted_values = sorted(values)
except TypeError:
sorted_values = sorted(values, key=repr)
if len(values) <= max_num_range:
values_string = ', '.join((_fmt_value(v) for v in sorted_values))
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def test_schema(self):
'const2': {'const3': 0},
'a': i,
'b': {'b2': i},
'c': [i, 0, 0],
'c': [i if i % 2 else None, 0, 0],
'd': [[i, 0, 0]],
'e': {'e2': [i, 0, 0]} if i % 2 else 0, # heterogeneous!
'f': {'f2': [[i, 0, 0]]},
Expand Down

0 comments on commit 09a84d0

Please sign in to comment.