Skip to content

Commit 444aae5

Browse files
authored
Merge pull request #541 from a-detiste/master
remove Python2 crumbs
2 parents 915a232 + 9f3d24c commit 444aae5

25 files changed

+48
-84
lines changed

docs/source/examples/lif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import numpy as np
1414

1515

16-
class LIF(object):
16+
class LIF:
1717

1818
def __init__(self, stepsize=0.0001, offset=1.6, tau_m=0.025, tau_a=0.02, da=0.0, D=3.5):
1919
self.stepsize = stepsize # simulation stepsize [s]

nixio/block.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
# modification, are permitted under the terms of the BSD License. See
88
# LICENSE file in the root of the Project.
99

10-
try:
11-
from sys import maxint
12-
except ImportError:
13-
from sys import maxsize as maxint
10+
from sys import maxsize
11+
1412
import numpy as np
1513
from inspect import isclass
16-
from six import string_types
1714
try:
1815
from collections.abc import OrderedDict
1916
except ImportError:
2017
from collections import OrderedDict
21-
import sys
2218

2319
from .util import find as finders
2420
from .compression import Compression
@@ -302,13 +298,6 @@ def create_data_frame(self, name="", type_="", col_dict=None,
302298
return self.data_frames[objid]
303299

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

313302
if data is not None:
314303
shape = len(data)
@@ -358,8 +347,7 @@ def create_data_frame(self, name="", type_="", col_dict=None,
358347
if col_dict is not None:
359348
for nam, dt in col_dict.items():
360349
if isclass(dt):
361-
if any(issubclass(dt, st) for st in string_types) \
362-
or issubclass(dt, np.string_):
350+
if issubclass(dt, str) or issubclass(dt, np.string_):
363351
col_dict[nam] = util.vlen_str_dtype
364352
if 'U' in str(dt) or dt == np.string_:
365353
col_dict[nam] = util.vlen_str_dtype
@@ -398,7 +386,7 @@ def find_sources(self, filtr=lambda _: True, limit=None):
398386
:rtype: list of nixio.Source
399387
"""
400388
if limit is None:
401-
limit = maxint
389+
limit = maxsize
402390
return finders._find_sources(self, filtr, limit)
403391

404392
def pprint(self, indent=2, max_length=120, extra=True, start_depth=0):

nixio/container.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from . import util
77

88

9-
class Container(object):
9+
class Container:
1010
"""
1111
Container acts as an interface to container groups in the backend. In the
1212
case of HDF5, this is a group that is used as a container for other groups.

nixio/data_frame.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# Redistribution and use in source and binary forms, with or without
77
# modification, are permitted under the terms of the BSD License. See
88
# LICENSE file in the root of the Project.
9-
from __future__ import (absolute_import, division, print_function)
109
try:
1110
from collections.abc import Iterable
1211
except ImportError:
@@ -20,7 +19,6 @@
2019
from .data_set import DataSet
2120
from .datatype import DataType
2221
from .section import Section
23-
from six import string_types
2422
import csv
2523

2624

@@ -56,8 +54,7 @@ def append_column(self, column, name, datatype=None):
5654
raise ValueError("Too much entries for column in this dataframe")
5755
if datatype is None:
5856
datatype = DataType.get_dtype(column[0])
59-
if isclass(datatype) and any(issubclass(datatype, st)
60-
for st in string_types):
57+
if isclass(datatype) and issubclass(datatype, str):
6158
datatype = util.vlen_str_dtype
6259
dt_arr = [(n, dty) for n, dty in zip(self.column_names, self.dtype)]
6360
dt_arr.append((name, datatype))

nixio/data_set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010

1111

12-
class DataSet(object):
12+
class DataSet:
1313
"""
1414
Data IO object for DataArray.
1515
"""

nixio/datatype.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# modification, are permitted under the terms of the BSD License. See
88
# LICENSE file in the root of the Project.
99
from numbers import Integral, Real
10-
from six import string_types
1110
from packaging import version
1211

1312
import numpy as np
@@ -16,7 +15,7 @@
1615
BOOLS = (bool, np.bool_)
1716

1817

19-
class DataType(object):
18+
class DataType:
2019
UInt8 = np.uint8
2120
UInt16 = np.uint16
2221
UInt32 = np.uint32
@@ -45,7 +44,7 @@ def get_dtype(cls, value):
4544
return cls.Int64
4645
elif isinstance(value, Real):
4746
return cls.Double
48-
elif isinstance(value, string_types):
47+
elif isinstance(value, str):
4948
return cls.String
5049
else:
5150
raise ValueError("Unknown type for value {}".format(value))

nixio/dimensions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def _inst_item(self, item):
6464
return cls(self._parent, idx)
6565

6666

67-
class DimensionLink(object):
67+
class DimensionLink:
6868
"""
6969
Links a Dimension to a data object (DataArray or DataFrame).
7070
@@ -223,7 +223,7 @@ def _data_object_type(self):
223223
return self._h5group.get_attr("data_object_type")
224224

225225

226-
class Dimension(object):
226+
class Dimension:
227227

228228
def __init__(self, nixfile, data_array, index):
229229
dimgroup = data_array._h5group.open_group("dimensions")

nixio/entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from . import util
1111

1212

13-
class Entity(object):
13+
class Entity:
1414

1515
def __init__(self, nixfile, nixparent, h5group):
1616
util.check_entity_id(h5group.get_attr("entity_id"))

nixio/feature.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
from .data_frame import DataFrame
1111
from .link_type import LinkType
1212
from .exceptions import UnsupportedLinkType
13-
from six import string_types
1413
from .util import util
1514

1615

17-
class Feature(object):
16+
class Feature:
1817

1918
def __init__(self, nixfile, nixparent, h5group):
2019
util.check_entity_id(h5group.get_attr("entity_id"))
@@ -53,7 +52,7 @@ def link_type(self):
5352

5453
@link_type.setter
5554
def link_type(self, link_type):
56-
if isinstance(link_type, string_types):
55+
if isinstance(link_type, str):
5756
link_type = link_type.lower()
5857
link_type = LinkType(link_type)
5958
self._h5group.set_attr("link_type", link_type.value)

nixio/file.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99
import os
1010
import gc
1111
import numpy as np
12+
from sys import maxsize
1213
from warnings import warn
1314

14-
try:
15-
from sys import maxint
16-
except ImportError:
17-
from sys import maxsize as maxint
1815
import h5py
1916

2017
from .hdf5.h5group import H5Group
@@ -54,7 +51,7 @@ def can_read(nixfile):
5451
return False
5552

5653

57-
class FileMode(object):
54+
class FileMode:
5855
ReadOnly = 'r'
5956
ReadWrite = 'a'
6057
Overwrite = 'w'
@@ -82,7 +79,7 @@ def make_fcpl():
8279
return fcpl
8380

8481

85-
class File(object):
82+
class File:
8683

8784
def __init__(self, path, mode=FileMode.ReadWrite,
8885
compression=Compression.Auto,
@@ -478,7 +475,7 @@ def find_sections(self, filtr=lambda _: True, limit=None):
478475
:rtype: list of nixio.Section
479476
"""
480477
if limit is None:
481-
limit = maxint
478+
limit = maxsize
482479
return finders._find_sections(self, filtr, limit)
483480

484481
@property

0 commit comments

Comments
 (0)