Skip to content

Commit

Permalink
Added missing utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lucastheis committed May 20, 2016
1 parent 32dc2dd commit f2c94b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions c2s/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def convert(input):
"""
Convert dictionary keys/values into something that can be saved with `scipy.io.savemat`.
"""

if isinstance(input, dict):
return dict([(convert(key), convert(value)) for key, value in input.iteritems()])
elif isinstance(input, list):
return [convert(element) for element in input]
elif isinstance(input, unicode):
return input.encode('utf-8')
else:
return input

0 comments on commit f2c94b9

Please sign in to comment.