From 6b0fd8103f3dbe4fd3accadeb90a18522b155667 Mon Sep 17 00:00:00 2001 From: Dina <1600540@eng.asu.edu.eg> Date: Sun, 22 Mar 2020 08:44:08 -0700 Subject: [PATCH 1/3] Changing all type() to _check_type() --- pydatastructs/linear_data_structures/arrays.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydatastructs/linear_data_structures/arrays.py b/pydatastructs/linear_data_structures/arrays.py index 49a419c67..cfb6b22c2 100644 --- a/pydatastructs/linear_data_structures/arrays.py +++ b/pydatastructs/linear_data_structures/arrays.py @@ -75,13 +75,13 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): if _check_type(args[0], list) and \ _check_type(args[1], int): for i in range(len(args[0])): - if dtype != type(args[0][i]): + if dtype != _check_type(args[0][i]): args[0][i] = dtype(args[0][i]) size, data = args[1], [arg for arg in args[0]] elif _check_type(args[1], list) and \ _check_type(args[0], int): for i in range(len(args[1])): - if dtype != type(args[1][i]): + if dtype != _check_type(args[1][i]): args[1][i] = dtype(args[1][i]) size, data = args[0], [arg for arg in args[1]] else: @@ -99,7 +99,7 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): obj._data = [init for i in range(args[0])] elif _check_type(args[0], (list, tuple)): for i in range(len(args[0])): - if dtype != type(args[0][i]): + if dtype != _check_type(args[0][i]): args[0][i] = dtype(args[0][i]) obj._size, obj._data = len(args[0]), \ [arg for arg in args[0]] @@ -118,7 +118,7 @@ def __setitem__(self, idx, elem): if elem is None: self._data[idx] = None else: - if type(elem) != self._dtype: + if _check_type(elem) != self._dtype: elem = self._dtype(elem) self._data[idx] = elem From 8dbb42049ccb2e27bf41026bdb78c9b8ff3834a4 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 23 Mar 2020 00:53:28 +0530 Subject: [PATCH 2/3] Apply suggestions from code review --- pydatastructs/linear_data_structures/arrays.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydatastructs/linear_data_structures/arrays.py b/pydatastructs/linear_data_structures/arrays.py index cfb6b22c2..d30eb3ba2 100644 --- a/pydatastructs/linear_data_structures/arrays.py +++ b/pydatastructs/linear_data_structures/arrays.py @@ -75,13 +75,13 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): if _check_type(args[0], list) and \ _check_type(args[1], int): for i in range(len(args[0])): - if dtype != _check_type(args[0][i]): + if _check_type(args[0][i], dtype): args[0][i] = dtype(args[0][i]) size, data = args[1], [arg for arg in args[0]] elif _check_type(args[1], list) and \ _check_type(args[0], int): for i in range(len(args[1])): - if dtype != _check_type(args[1][i]): + if _check_type(args[1][i], dtype): args[1][i] = dtype(args[1][i]) size, data = args[0], [arg for arg in args[1]] else: @@ -99,7 +99,7 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): obj._data = [init for i in range(args[0])] elif _check_type(args[0], (list, tuple)): for i in range(len(args[0])): - if dtype != _check_type(args[0][i]): + if _check_type(args[0][i], dtype): args[0][i] = dtype(args[0][i]) obj._size, obj._data = len(args[0]), \ [arg for arg in args[0]] @@ -118,7 +118,7 @@ def __setitem__(self, idx, elem): if elem is None: self._data[idx] = None else: - if _check_type(elem) != self._dtype: + if _check_type(elem, self._dtype): elem = self._dtype(elem) self._data[idx] = elem From cd578a0d4af4c88e3fd52f9adf0e48cfbcb19b7e Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 23 Mar 2020 00:56:00 +0530 Subject: [PATCH 3/3] Apply suggestions from code review --- pydatastructs/linear_data_structures/arrays.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydatastructs/linear_data_structures/arrays.py b/pydatastructs/linear_data_structures/arrays.py index d30eb3ba2..d2800a5a7 100644 --- a/pydatastructs/linear_data_structures/arrays.py +++ b/pydatastructs/linear_data_structures/arrays.py @@ -75,13 +75,13 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): if _check_type(args[0], list) and \ _check_type(args[1], int): for i in range(len(args[0])): - if _check_type(args[0][i], dtype): + if _check_type(args[0][i], dtype) is False: args[0][i] = dtype(args[0][i]) size, data = args[1], [arg for arg in args[0]] elif _check_type(args[1], list) and \ _check_type(args[0], int): for i in range(len(args[1])): - if _check_type(args[1][i], dtype): + if _check_type(args[1][i], dtype) is False: args[1][i] = dtype(args[1][i]) size, data = args[0], [arg for arg in args[1]] else: @@ -99,7 +99,7 @@ def __new__(cls, dtype=NoneType, *args, **kwargs): obj._data = [init for i in range(args[0])] elif _check_type(args[0], (list, tuple)): for i in range(len(args[0])): - if _check_type(args[0][i], dtype): + if _check_type(args[0][i], dtype) is False: args[0][i] = dtype(args[0][i]) obj._size, obj._data = len(args[0]), \ [arg for arg in args[0]] @@ -118,7 +118,7 @@ def __setitem__(self, idx, elem): if elem is None: self._data[idx] = None else: - if _check_type(elem, self._dtype): + if _check_type(elem, self._dtype) is False: elem = self._dtype(elem) self._data[idx] = elem