Skip to content

Commit

Permalink
Merge pull request #409 from achilleas-k/lgtm-zero
Browse files Browse the repository at this point in the history
Addressing LGTM warnings
  • Loading branch information
jgrewe authored Oct 18, 2019
2 parents c8701e8 + c93856c commit ab40c0d
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 28 deletions.
10 changes: 6 additions & 4 deletions nixio/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,9 @@ def create_data_frame(self, name="", type_="", col_dict=None,
for nam, dt in zip(col_names, col_dtypes)
)
else: # col_dtypes is None and data is None
raise (ValueError,
"The data type of each column have to be specified")
raise ValueError(
"The data type of each column have to be specified"
)
else: # if col_names is None
if data is not None and type(data[0]) == np.void:
col_dtype = data[0].dtype
Expand All @@ -315,8 +316,9 @@ def create_data_frame(self, name="", type_="", col_dict=None,
else:
# data is None or type(data[0]) != np.void
# data_type doesnt matter
raise (ValueError,
"No information about column names is provided!")
raise ValueError(
"No information about column names is provided!"
)

if col_dict is not None:
for nam, dt in col_dict.items():
Expand Down
4 changes: 2 additions & 2 deletions nixio/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def __getitem__(self, identifier):
for grp in self._backend:
if identifier == grp.get_attr("name"):
return self._inst_item(grp)
else:
raise KeyError("Item not found '{}'".format(identifier))

raise KeyError("Item not found '{}'".format(identifier))

def __contains__(self, item):
# need to redefine because of id indexing/linking
Expand Down
4 changes: 2 additions & 2 deletions nixio/data_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# LICENSE file in the root of the Project.
from __future__ import (absolute_import, division, print_function)
try:
from collections.abc import Iterable, Sequence
from collections.abc import Iterable
except ImportError:
from collections import Iterable, Sequence
from collections import Iterable
from collections import OrderedDict
from inspect import isclass
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion nixio/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from .dimension_type import DimensionType
from . import util
from .container import Container
from six import string_types


class DimensionContainer(Container):
Expand Down
3 changes: 3 additions & 0 deletions nixio/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def __eq__(self, other):
return self.id == other.id
return False

def __ne__(self, other):
return not self.__eq__(other)

def __hash__(self):
"""
overwriting method __eq__ blocks inheritance of __hash__ in Python 3
Expand Down
4 changes: 3 additions & 1 deletion nixio/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Redistribution and use in source and binary forms, with or without
# modification, are permitted under the terms of the BSD License. See
# LICENSE file in the root of the Project.
from .entity import Entity
from .data_array import DataArray
from .link_type import LinkType
from six import string_types
Expand Down Expand Up @@ -103,6 +102,9 @@ def __eq__(self, other):
return self.id == other.id
return False

def __ne__(self, other):
return not self.__eq__(other)

def __hash__(self):
"""
overwriting method __eq__ blocks inheritance of __hash__ in Python 3
Expand Down
4 changes: 1 addition & 3 deletions nixio/hdf5/h5group.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import h5py
import numpy as np
from warnings import warn

from .h5dataset import H5DataSet
from ..datatype import DataType
Expand Down Expand Up @@ -172,8 +171,7 @@ def has_by_id(self, id_or_name):
for item in self:
if item.get_attr("entity_id") == id_or_name:
return True
else:
return False
return False
else:
return id_or_name in self.group

Expand Down
14 changes: 0 additions & 14 deletions nixio/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,20 +362,6 @@ def __str__(self):
def __repr__(self):
return self.__str__()

def __eq__(self, other):
if hasattr(other, "id"):
return self.id == other.id

return False

def __hash__(self):
"""
overwriting method __eq__ blocks inheritance of __hash__ in Python 3
hash has to be either explicitly inherited from parent class,
implemented or escaped
"""
return hash(self.id)

def pprint(self, indent=2, max_length=80, current_depth=-1):
"""
Pretty print method. Method is called in Section.pprint()
Expand Down
2 changes: 1 addition & 1 deletion nixio/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def __setitem__(self, key, data):
data = [data]

if key not in self.props:
prop = self.create_property(key, data)
self.create_property(key, data)
else:
prop = self.props[key]
prop.values = data
Expand Down

0 comments on commit ab40c0d

Please sign in to comment.