8000 fixed code style errors raised by flake8 · alixdamman/larray@7fc6420 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7fc6420

Browse files
committed
fixed code style errors raised by flake8
1 parent 26d63b7 commit 7fc6420

File tree

16 files changed

+53
-51
lines changed

16 files changed

+53
-51
lines changed

larray/core/array.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# * use larray "utils" in LIAM2 (to avoid duplicated code)
2727

2828
from collections import OrderedDict
29-
from itertools import product, chain, groupby, islice, repeat
29+
from itertools import product, chain, groupby
3030
from collections.abc import Iterable, Sequence
3131
import builtins
3232
import os
@@ -53,7 +53,7 @@
5353
from larray.core.expr import ExprNode
5454
from larray.core.group import (Group, IGroup, LGroup, remove_nested_groups, _to_key, _to_keys,
5555
_translate_sheet_name, _translate_group_key_hdf)
56-
from larray.core.axis import Axis, AxisReference, AxisCollection, X, _make_axis
56+
from larray.core.axis import Axis, AxisReference, AxisCollection, X, _make_axis # noqa: F401
5757
from larray.util.misc import (table2str, size2str, ReprString,
5858
float_error_handler_factory, light_product, common_type,
5959
renamed_to, deprecate_kwarg, LHDFStore, lazy_attribute, unique_multi, SequenceZip,
@@ -3567,7 +3567,7 @@ def unique(self, axes=None, sort=False, sep='_'):
35673567
for labels, value in self.items(axes):
35683568
hashable_value = value.data.tobytes() if isinstance(value, Array) else value
35693569
if hashable_value not in seen:
3570-
list_append((sep_join(str(l) for l in labels), value))
3570+
list_append((sep_join(str(label) for label in labels), value))
35713571
seen_add(hashable_value)
35723572
res_arr = stack(unq_list, axis_name)
35733573
# transpose the combined axis at the position where the first of the combined axes was
@@ -8689,6 +8689,7 @@ def array_or_full(a, axis, initial):
86898689
res[axis.i[1:]] = ((1 - cum_mult) / (1 - mult)) * inc + initial * cum_mult
86908690
return res
86918691

8692+
86928693
create_sequential = renamed_to(sequence, 'create_sequential')
86938694

86948695

larray/core/axis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from larray.core.expr import ExprNode
1212
from larray.core.group import (Group, LGroup, IGroup, IGroupMaker, _to_tick, _to_ticks, _to_key, _seq_summary,
1313
_idx_seq_to_slice, _seq_group_to_name, _translate_group_key_hdf, remove_nested_groups)
14-
from larray.util.oset import *
14+
from larray.util.oset import OrderedSet
1515
from larray.util.misc import (duplicates, array_lookup2, ReprString, index_by_id, renamed_to, common_type, LHDFStore,
16-
lazy_attribute, _isnoneslice, unique_multi, Product)
16+
lazy_attribute, _isnoneslice, unique_list, unique_multi, Product)
1717

1818

1919
np_frompyfunc = np.frompyfunc
@@ -321,7 +321,7 @@ def split(self, sep='_', names=None, regex=None, return_labels=False):
321321
split_labels = np.char.split(labels, sep)
322322
else:
323323
match = re.compile(regex).match
324-
split_labels = [match(l).groups() for l in self.labels]
324+
split_labels = [match(label).groups() for label in self.labels]
325325
if names is None:
326326
names = [None] * len(split_labels)
327327
indexing_labels = zip(*split_labels)
@@ -1183,7 +1183,7 @@ def intersection(self, other):
11831183
if isinstance(other, Axis):
11841184
other = other.labels
11851185
to_keep = set(other)
1186-
return Axis([l for l in self.labels if l in to_keep], self.name)
1186+
return Axis([label for label in self.labels if label in to_keep], self.name)
11871187

11881188
def difference(self, other):
11891189
r"""Returns axis with the (set) difference of this axis labels and other labels.
@@ -1220,7 +1220,7 @@ def difference(self, other):
12201220
if isinstance(other, Axis):
12211221
other = other.labels
12221222
to_drop = set(other)
1223- C3FE
return Axis([l for l in self.labels if l not in to_drop], self.name)
1223+
return Axis([label for label in self.labels if label not in to_drop], self.name)
12241224

12251225
def align(self, other, join='outer'):
12261226
r"""Align axis with other object using specified join method.
@@ -3186,7 +3186,7 @@ def combine_axes(self, axes=None, sep='_', wildcard=False, front_if_spread=False
31863186
combined_labels = _axes[0].labels
31873187
else:
31883188
sepjoin = sep.join
3189-
axes_labels = [np.array(l, np.str, copy=False) for l in _axes.labels]
3189+
axes_labels = [np.array(label, np.str, copy=False) for label in _axes.labels]
31903190
combined_labels = [sepjoin(p) for p in product(*axes_labels)]
31913191
combined_axis = Axis(combined_labels, combined_name)
31923192
new_axes = new_axes - _axes

larray/core/group.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pandas as pd
99

1010
from larray.core.abstractbases import ABCAxis, ABCAxisReference, ABCArray
11-
from larray.util.oset import *
11+
from larray.util.oset import OrderedSet
1212
from larray.util.misc import (unique, find_closing_chr, _parse_bound, _seq_summary, _isintstring, renamed_to, LHDFStore)
1313

1414

@@ -867,7 +867,7 @@ def __len__(self):
867867
if hasattr(value, '__len__'):
868868
return len(value)
869869
elif isinstance(value, slice):
870-
F438 start, stop, key_step = value.start, value.stop, value.step
870+
start, stop = value.start, value.stop
871871
# not using stop - start because that does not work for string bounds
872872
# (and it is different for LGroup & IGroup)
873873
start_pos = self.translate(start)
@@ -1715,4 +1715,5 @@ def eval(self):
17151715
def __hash__(self):
17161716
return hash(('IGroup', _to_tick(self.key)))
17171717

1718+
17181719
PGroup = renamed_to(IGroup, 'PGroup')

larray/core/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from larray.core.group import Group
1313
from larray.core.axis import Axis
1414
from larray.core.constants import nan
15-
from larray.core.array import Array, get_axes, ndtest, zeros, zeros_like, sequence, asarray
15+
from larray.core.array import Array, get_axes, ndtest, zeros, zeros_like, sequence # noqa: F401
1616
from larray.util.misc import float_error_handler_factory, is_interactive_interpreter, renamed_to, inverseop
1717
from larray.inout.session import ext_default_engine, get_file_handler
1818

larray/inout/csv.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import csv
33
import warnings
44
from glob import glob
5-
from collections import OrderedDict
65

76
import pandas as pd
87
import numpy as np
@@ -14,7 +13,7 @@
1413
from larray.inout.session import register_file_handler
1514
from larray.inout.common import _get_index_col, FileHandler
1615
from larray.inout.pandas import df_asarray
17-
from larray.example import get_example_filepath
16+
from larray.example import get_example_filepath # noqa: F401
1817

1918

2019
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)

larray/inout/excel.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import os
21
import warnings
3-
from collections import OrderedDict
42

53
import numpy as np
64
import pandas as pd
@@ -10,16 +8,15 @@
108
xw = None
119

1210
from larray.core.array import Array, asarray
13-
from larray.core.axis import Axis
1411
from larray.core.constants import nan
15-
from larray.core.group import Group, _translate_sheet_name
12+
from larray.core.group import _translate_sheet_name
1613
from larray.core.metadata import Metadata
1714
from larray.util.misc import deprecate_kwarg
1815
from larray.inout.session import register_file_handler
1916
from larray.inout.common import _get_index_col, FileHandler
2017
from larray.inout.pandas import df_asarray
2118
from larray.inout.xw_excel import open_excel
22-
from larray.example import get_example_filepath
19+
from larray.example import get_example_filepath # noqa: F401
2320

2421

2522
__all__ = ['read_excel']

larray/inout/hdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from larray.inout.session import register_file_handler
1414
from larray.inout.common import FileHandler, _supported_typenames, _supported_scalars_types
1515
from larray.inout.pandas import df_asarray
16-
from larray.example import get_example_filepath
16+
from larray.example import get_example_filepath # noqa: F401
1717

1818

1919
# for backward compatibility (larray < 0.29) but any object read from an hdf file should have
@@ -103,7 +103,7 @@ def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, s
103103
# np.char.decode does not work
104104
# this is at least the case for Python2 + Pandas 0.24.2 combination
105105
if labels.dtype.kind == 'O':
106-
labels = np.array([l.decode('utf-8') for l in labels], dtype='U')
106+
labels = np.array([label.decode('utf-8') for label in labels], dtype='U')
107107
else:
108108
labels = np.char.decode(labels, 'utf-8')
109109
res = Axis(labels=labels, name=name)

larray/inout/pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def index_to_labels(idx, sort=True):
4848
if sort:
4949
return list(idx.levels)
5050
else:
51-
return [list(unique(idx.get_level_values(l))) for l in range(idx.nlevels)]
51+
return [list(unique(idx.get_level_values(label))) for label in range(idx.nlevels)]
5252
else:
5353
assert isinstance(idx, pd.Index)
5454
labels = list(idx.values)

larray/inout/xw_excel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
except ImportError:
88
xw = None
99

10-
from larray.core.array import Array, ndtest
10+
from larray.core.array import Array, ndtest # noqa: F401
1111
from larray.core.axis import Axis
1212
from larray.core.constants import nan
1313
from larray.core.group import _translate_sheet_name

larray/random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2626
import numpy as np
2727

28-
from larray.core.axis import Axis, AxisCollection
28+
from larray.core.axis import Axis, AxisCollection # noqa: F401
2929
from larray.core.array import Array, asarray
3030
from larray.core.array import raw_broadcastable
31-
import larray as la
31+
import larray as la # noqa: F401
3232

3333

3434
__all__ = ['randint', 'normal', 'uniform', 'permutation', 'choice']

0 commit comments

Comments
 (0)
0