Skip to content

Commit 4189458

Browse files
committed
remove Py2vs3 code hybridized using sys.version
1 parent 051cfde commit 4189458

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

nixio/block.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from collections.abc import OrderedDict
1616
except ImportError:
1717
from collections import OrderedDict
18-
import sys
1918

2019
from .util import find as finders
2120
from .compression import Compression
@@ -299,13 +298,6 @@ def create_data_frame(self, name="", type_="", col_dict=None,
299298
return self.data_frames[objid]
300299

301300
util.check_entity_name_and_type(name, type_)
302-
if (isinstance(col_dict, dict)
303-
and not isinstance(col_dict, OrderedDict)
304-
and sys.version_info[0] < 3):
305-
raise TypeError("Cannot create a DataFrame from a dictionary "
306-
"in Python 2 as the order of keys is not "
307-
"preserved. Please use the OrderedDict class "
308-
"from the collections module instead.")
309301

310302
if data is not None:
311303
shape = len(data)

nixio/test/test_data_array.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
# LICENSE file in the root of the Project.
99
import os
1010
import time
11-
import sys
1211
import unittest
1312
import numpy as np
1413
import nixio as nix
@@ -277,8 +276,7 @@ def test_data_array_dtype(self):
277276
assert da.dtype == test_data.dtype
278277

279278
bdata = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
280-
if sys.version_info[0] == 3:
281-
bdata = [bytes(x, 'UTF-8') for x in bdata]
279+
bdata = [bytes(x, 'UTF-8') for x in bdata]
282280

283281
void_data = np.array(bdata, dtype='V1')
284282
da = self.block.create_data_array('dtype_opaque', 'b', data=void_data)

nixio/test/test_data_frame.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from collections.abc import OrderedDict
1010
except ImportError:
1111
from collections import OrderedDict
12-
import sys
1312

1413

1514
class TestDataFrame(unittest.TestCase):
@@ -219,11 +218,10 @@ def test_df_shape(self):
219218
assert tuple(self.df1.df_shape) == (10, 5)
220219
# create df with incorrect dimension to see if Error is raised
221220
arr = np.arange(1000).reshape(10, 10, 10)
222-
if sys.version_info[0] == 3:
223-
with self.assertRaises(ValueError):
224-
self.block.create_data_frame('err', 'err',
225-
{'name': np.int64},
226-
data=arr)
221+
with self.assertRaises(ValueError):
222+
self.block.create_data_frame('err', 'err',
223+
{'name': np.int64},
224+
data=arr)
227225

228226
def test_data_type(self):
229227
assert self.df1.dtype[4] == np.int32

0 commit comments

Comments
 (0)