2828
2929# * use larray "utils" in LIAM2 (to avoid duplicated code)
3030
31- from collections import Iterable , Sequence , OrderedDict
31+ from collections import OrderedDict
3232from itertools import product , chain , groupby , islice , repeat
3333import os
3434import sys
3535import functools
3636import warnings
3737
38- try :
39- import builtins
40- except ImportError :
41- import __builtin__ as builtins
42-
4338import numpy as np
4439import pandas as pd
4540
6055from larray .core .group import (Group , IGroup , LGroup , remove_nested_groups , _to_key , _to_keys ,
6156 _translate_sheet_name , _translate_group_key_hdf )
6257from larray .core .axis import Axis , AxisReference , AxisCollection , X , _make_axis
63- from larray .util .misc import (table2str , size2str , basestring , izip , rproduct , ReprString , duplicates ,
64- float_error_handler_factory , _isnoneslice , light_product , unique_list , common_type ,
58+ from larray .util .misc import (table2str , size2str , ReprString ,
59+ float_error_handler_factory , light_product , common_type ,
6560 renamed_to , deprecate_kwarg , LHDFStore , lazy_attribute , unique_multi , SequenceZip ,
66- Repeater , Product , ensure_no_numpy_type , PY2 )
61+ Repeater , Product , ensure_no_numpy_type )
62+ from larray .util .compat import PY2 , basestring , Iterable , Sequence , builtins
6763from larray .util .options import _OPTIONS , DISPLAY_MAXLINES , DISPLAY_EDGEITEMS , DISPLAY_WIDTH , DISPLAY_PRECISION
6864
6965
@@ -8466,7 +8462,7 @@ def full_like(array, fill_value, title=None, dtype=None, order='K', meta=None):
84668462
84678463
84688464# XXX: would it be possible to generalize to multiple axes?
8469- def sequence (axis , initial = 0 , inc = None , mult = 1 , func = None , axes = None , title = None , meta = None ):
8465+ def sequence (axis , initial = 0 , inc = None , mult = None , func = None , axes = None , title = None , meta = None ):
84708466 r"""
84718467 Creates an array by sequentially applying modifications to the array along axis.
84728468
@@ -8482,9 +8478,10 @@ def sequence(axis, initial=0, inc=None, mult=1, func=None, axes=None, title=None
84828478 initial : scalar or Array, optional
84838479 Value for the first label of axis. Defaults to 0.
84848480 inc : scalar, Array, optional
8485- Value to increment the previous value by. Defaults to 0 if mult is provided, 1 otherwise.
8481+ Value to increment the previous value by. Defaults to 1 unless mult is provided (in which case it defaults
8482+ to 0).
84868483 mult : scalar, Array, optional
8487- Value to multiply the previous value by. Defaults to 1 .
8484+ Value to multiply the previous value by. Defaults to None .
84888485 func : function/callable, optional
84898486 Function to apply to the previous value. Defaults to None.
84908487 Note that this is much slower than using inc and/or mult.
@@ -8574,10 +8571,14 @@ def sequence(axis, initial=0, inc=None, mult=1, func=None, axes=None, title=None
85748571 meta = _handle_meta (meta , title )
85758572
85768573 if inc is None :
8577- inc = 1 if mult is 1 else 0
8574+ inc = 1 if mult is None else 0
8575+ if mult is None :
8576+ mult = 1
85788577
85798578 # fast path for the most common case
8580- if (mult is 1 and isinstance (inc , (int , np .integer )) and isinstance (initial , (int , np .integer )) and
8579+ integer_types = (int , np .integer )
8580+ if (isinstance (mult , integer_types ) and mult == 1 and
8581+ isinstance (inc , integer_types ) and isinstance (initial , integer_types ) and
85818582 func is None and axes is None ):
85828583 axis = _make_axis (axis )
85838584 # stop is not included
0 commit comments