File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 37
37
import tempfile
38
38
import warnings
39
39
40
- from six import add_metaclass , PY2
40
+ import six
41
41
from six .moves .urllib .request import urlopen
42
42
43
43
import pytest
44
44
import numpy as np
45
45
46
46
47
- if PY2 :
47
+ if six . PY2 :
48
48
def abstractstaticmethod (func ):
49
49
return func
50
50
def abstractclassmethod (func ):
@@ -54,7 +54,7 @@ def abstractclassmethod(func):
54
54
abstractclassmethod = abc .abstractclassmethod
55
55
56
56
57
- @add_metaclass (abc .ABCMeta )
57
+ @six . add_metaclass (abc .ABCMeta )
58
58
class BaseDiff (object ):
59
59
60
60
@abstractstaticmethod
@@ -136,8 +136,15 @@ def read(filename):
136
136
137
137
@staticmethod
138
138
def write (filename , data , ** kwargs ):
139
- if 'fmt' not in kwargs :
140
- kwargs ['fmt' ] = '%g'
139
+ fmt = kwargs .get ('fmt' , '%g' )
140
+ # Workaround for a known issue in `numpy.savetxt` for the `fmt` argument:
141
+ # https://github.com/numpy/numpy/pull/4053#issuecomment-263808221
142
+ # Convert `unicode` to `str` (i.e. bytes) on Python 2
143
+ if six .PY2 and isinstance (fmt , six .text_type ):
144
+ fmt = fmt .encode ('ascii' )
145
+
146
+ kwargs ['fmt' ] = fmt
147
+
141
148
return np .savetxt (filename , data , ** kwargs )
142
149
143
150
You can’t perform that action at this time.
0 commit comments