Skip to content

Commit 79733fb

Browse files
committed
fixed #737 : cleanup modules namespaces
1 parent d1f9808 commit 79733fb

22 files changed

+100
-122
lines changed

larray/__init__.py

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,97 @@
11
from __future__ import absolute_import, division, print_function
22

3-
from larray.core import *
4-
from larray.inout import *
5-
from larray.util import *
6-
from larray.example import *
7-
from larray.extra import *
8-
from larray.viewer import *
3+
__version__ = '0.30-dev'
4+
5+
6+
from larray.core.axis import Axis, AxisCollection, X
7+
from larray.core.group import Group, LGroup, LSet, IGroup, union
8+
from larray.core.array import (LArray, zeros, zeros_like, ones, ones_like, empty, empty_like, full,
9+
full_like, sequence, labels_array, ndtest, aslarray, identity, diag,
10+
eye, all, any, sum, prod, cumsum, cumprod, min, max, mean, ptp, var,
11+
std, median, percentile, stack)
12+
from larray.core.session import Session, local_arrays, global_arrays, arrays
13+
from larray.core.constants import nan, inf, pi, e, euler_gamma
14+
from larray.core.metadata import Metadata
15+
from larray.core.ufuncs import maximum, minimum, where
16+
from larray.core.npufuncs import (sin, cos, tan, arcsin, arccos, arctan, hypot, arctan2, degrees,
17+
radians, unwrap, sinh, cosh, tanh, arcsinh, arccosh, arctanh,
18+
angle, real, imag, conj,
19+
round, around, round_, rint, fix, floor, ceil, trunc,
20+
exp, expm1, exp2, log, log10, log2, log1p, logaddexp, logaddexp2,
21+
i0, sinc, signbit, copysign, frexp, ldexp,
22+
convolve, clip, sqrt, absolute, fabs, sign, fmax, fmin, nan_to_num,
23+
real_if_close, interp, isnan, isinf, inverse)
24+
25+
from larray.inout.misc import from_lists, from_string
26+
from larray.inout.pandas import from_frame, from_series
27+
from larray.inout.csv import read_csv, read_tsv, read_eurostat
28+
from larray.inout.excel import read_excel
29+
from larray.inout.hdf import read_hdf
30+
from larray.inout.sas import read_sas
31+
from larray.inout.xw_excel import open_excel, Workbook
32+
33+
from larray.viewer import view, edit, compare
34+
35+
from larray.extra.ipfp import ipfp
36+
37+
from larray.example import get_example_filepath, load_example_data
38+
939
import larray.random
1040

11-
__version__ = '0.30-dev'
41+
42+
__all__ = [
43+
# axis
44+
'Axis', 'AxisCollection', 'X',
45+
# group
46+
'Group', 'LGroup', 'LSet', 'IGroup', 'union',
47+
# array
48+
'LArray', 'zeros', 'zeros_like', 'ones', 'ones_like', 'empty', 'empty_like', 'full',
49+
'full_like', 'sequence', 'labels_array', 'ndtest', 'aslarray', 'identity', 'diag', 'eye',
50+
'all', 'any', 'sum', 'prod', 'cumsum', 'cumprod', 'min', 'max', 'mean', 'ptp', 'var', 'std',
51+
'median', 'percentile', 'stack',
52+
# session
53+
'Session', 'local_arrays', 'global_arrays', 'arrays',
54+
# constants
55+
'nan', 'inf', 'pi', 'e', 'euler_gamma',
56+
# metadata
57+
'Metadata',
58+
# ufuncs
59+
'maximum', 'minimum', 'where',
60+
'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'hypot', 'arctan2', 'degrees', 'radians',
61+
'unwrap', 'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh',
62+
'angle', 'real', 'imag', 'conj',
63+
'round', 'around', 'round_', 'rint', 'fix', 'floor', 'ceil', 'trunc',
64+
'exp', 'expm1', 'exp2', 'log', 'log10', 'log2', 'log1p', 'logaddexp', 'logaddexp2',
65+
'i0', 'sinc', 'signbit', 'copysign', 'frexp', 'ldexp',
66+
'convolve', 'clip', 'sqrt', 'absolute', 'fabs', 'sign', 'fmax', 'fmin', 'nan_to_num',
67+
'real_if_close', 'interp', 'isnan', 'isinf', 'inverse',
68+
# inout
69+
'from_lists', 'from_string', 'from_frame', 'from_series', 'read_csv', 'read_tsv',
70+
'read_eurostat', 'read_excel', 'read_hdf', 'read_sas', 'open_excel', 'Workbook',
71+
# viewer
72+
'view', 'edit', 'compare',
73+
# ipfp
74+
'ipfp',
75+
# example
76+
'get_example_filepath', 'load_example_data',
77+
]
78+
79+
80+
# ==== DEPRECATED API ====
81+
82+
from larray.core.axis import x
83+
from larray.core.group import PGroup
84+
from larray.core.array import (create_sequential, ndrange, larray_equal, larray_nan_equal,
85+
nan_equal, element_equal)
86+
87+
88+
_deprecated = [
89+
# axis
90+
'x',
91+
# group
92+
'PGroup',
93+
# array
94+
'create_sequential', 'ndrange', 'larray_equal', 'larray_nan_equal', 'nan_equal', 'element_equal',
95+
]
96+
97+
__all__ += _deprecated

larray/core/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
from larray.core.constants import *
4-
from larray.core.group import *
5-
from larray.core.axis import *
6-
from larray.core.array import *
7-
from larray.core.session import *
8-
from larray.core.ufuncs import *
9-
from larray.core.npufuncs import *
10-
from larray.core.metadata import *

larray/core/array.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,6 @@
6767
renamed_to, deprecate_kwarg, LHDFStore, lazy_attribute)
6868

6969

70-
_deprecated = ['create_sequential', 'ndrange', 'larray_equal', 'larray_nan_equal', 'nan_equal', 'element_equal']
71-
72-
__all__ = [
73-
'LArray', 'zeros', 'zeros_like', 'ones', 'ones_like', 'empty', 'empty_like', 'full', 'full_like', 'sequence',
74-
'labels_array', 'ndtest', 'aslarray', 'identity', 'diag', 'eye', 'all', 'any', 'sum', 'prod', 'cumsum',
75-
'cumprod', 'min', 'max', 'mean', 'ptp', 'var', 'std', 'median', 'percentile', 'stack',
76-
] + _deprecated
77-
78-
7970
def all(values, axis=None):
8071
"""
8172
Test whether all array elements along a given axis evaluate to True.
@@ -5335,7 +5326,7 @@ def eq(self, other, rtol=0, atol=0, nans_equal=False):
53355326
if not nans_equal:
53365327
return self == other
53375328
else:
5338-
from larray.core import isnan
5329+
from larray.core.npufuncs import isnan
53395330

53405331
def general_isnan(a):
53415332
if np.issubclass_(a.dtype.type, np.inexact):
@@ -6049,7 +6040,7 @@ def clip(self, a_min, a_max, out=None):
60496040
-----
60506041
If `a_min` and/or `a_max` are array_like, broadcast will occur between self, `a_min` and `a_max`.
60516042
"""
6052-
from larray.core import clip
6043+
from larray.core.npufuncs import clip
60536044
return clip(self, a_min, a_max, out)
60546045

60556046
@deprecate_kwarg('transpose', 'wide')

larray/core/axis.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
from larray.util.misc import (basestring, PY2, unicode, long, duplicates, array_lookup2, ReprString, index_by_id,
1919
renamed_to, common_type, LHDFStore, lazy_attribute, _isnoneslice)
2020

21-
_deprecated = ['x']
22-
23-
__all__ = ['Axis', 'AxisCollection', 'X'] + _deprecated
24-
2521

2622
class Axis(ABCAxis):
2723
"""

larray/core/constants.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import numpy as np
44

5-
__all__ = ['nan', 'inf', 'pi', 'e', 'euler_gamma']
65

76
nan = np.nan
87
r"NaN (Not a Number)"

larray/core/group.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
from larray.util.misc import (basestring, PY2, unique, find_closing_chr, _parse_bound, _seq_summary, _isintstring,
1616
renamed_to, LHDFStore)
1717

18-
_deprecated = ['PGroup']
19-
20-
__all__ = ['Group', 'LGroup', 'LSet', 'IGroup', 'union'] + _deprecated
21-
2218

2319
def _slice_to_str(key, repr_func=str):
2420
"""

larray/core/metadata.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
from larray.util.misc import PY2, basestring
66

77

8-
__all__ = ['Metadata']
9-
10-
118
if PY2:
129
class AttributeDict(object):
1310
def __init__(self, *args, **kwargs):

larray/core/npufuncs.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,6 @@
66
from larray.core.ufuncs import broadcastify
77

88

9-
__all__ = [
10-
# Trigonometric functions
11-
'sin', 'cos', 'tan', 'arcsin', 'arccos', 'arctan', 'hypot', 'arctan2', 'degrees', 'radians', 'unwrap',
12-
# 'deg2rad', 'rad2deg',
13-
14-
# Hyperbolic functions
15-
'sinh', 'cosh', 'tanh', 'arcsinh', 'arccosh', 'arctanh',
16-
17-
# Rounding
18-
'round', 'around', 'round_', 'rint', 'fix', 'floor', 'ceil', 'trunc',
19-
20-
# Sums, products, differences
21-
# 'prod', 'sum', 'nansum', 'cumprod', 'cumsum',
22-
23-
# cannot use a simple wrapped ufunc because those ufuncs do not preserve shape or dimensions so labels are wrong
24-
# 'diff', 'ediff1d', 'gradient', 'cross', 'trapz',
25-
26-
# Exponents and logarithms
27-
'exp', 'expm1', 'exp2', 'log', 'log10', 'log2', 'log1p', 'logaddexp', 'logaddexp2',
28-
29-
# Other special functions
30-
'i0', 'sinc',
31-
32-
# Floating point routines
33-
'signbit', 'copysign', 'frexp', 'ldexp',
34-
35-
# Arithmetic operations
36-
# 'add', 'reciprocal', 'negative', 'multiply', 'divide', 'power', 'subtract', 'true_divide', 'floor_divide',
37-
# 'fmod', 'mod', 'modf', 'remainder',
38-
39-
# Handling complex numbers
40-
'angle', 'real', 'imag', 'conj',
41-
42-
# Miscellaneous
43-
'convolve', 'clip', 'sqrt',
44-
# 'square',
45-
'absolute', 'fabs', 'sign', 'fmax', 'fmin', 'nan_to_num', 'real_if_close',
46-
'interp', 'isnan', 'isinf', 'inverse',
47-
]
48-
49-
509
# Trigonometric functions
5110

5211
sin = broadcastify(np.sin)

larray/core/ufuncs.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
from larray.core.array import LArray, raw_broadcastable
77

88

9-
__all__ = ['maximum', 'minimum', 'where']
10-
11-
129
def broadcastify(func):
1310
# intentionally not using functools.wraps, because it does not work for wrapping a function from another module
1411
def wrapper(*args, **kwargs):

larray/example.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
22
import larray as la
33

4-
__all__ = ['get_example_filepath', 'load_example_data']
54

65
EXAMPLE_FILES_DIR = os.path.dirname(__file__) + '/tests/data/'
76
AVAILABLE_EXAMPLE_DATA = {

larray/extra/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
from __future__ import absolute_import
2-
3-
from larray.extra.ipfp import *

larray/extra/ipfp.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from larray.core.array import LArray, aslarray, ones, any
55
import numpy as np
66

7-
__all__ = ['ipfp']
8-
97

108
def badvalues(a, bad_filter):
119
bad_values = a[bad_filter]

larray/inout/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
from __future__ import absolute_import, division, print_function
2-
3-
from larray.inout.pandas import *
4-
from larray.inout.csv import *
5-
from larray.inout.misc import *
6-
from larray.inout.excel import *
7-
from larray.inout.hdf import *
8-
from larray.inout.sas import *
9-
from larray.inout.pickle import *
10-
from larray.inout.xw_excel import *

larray/inout/csv.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@
2121
from larray.example import get_example_filepath
2222

2323

24-
__all__ = ['read_csv', 'read_tsv', 'read_eurostat']
25-
26-
2724
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
2825
def read_csv(filepath_or_buffer, nb_axes=None, index_col=None, sep=',', headersep=None, fill_value=nan,
2926
na=nan, sort_rows=False, sort_columns=False, wide=True, dialect='larray', **kwargs):

larray/inout/hdf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
from larray.example import get_example_filepath
1818

1919

20-
__all__ = ['read_hdf']
21-
22-
2320
def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, sort_columns=False,
2421
name=None, **kwargs):
2522
"""Reads an axis or group or array named key from a HDF5 file in filepath (path+name)

larray/inout/misc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
from larray.inout.csv import read_csv
1111

1212

13-
__all__ = ['from_lists', 'from_string']
14-
15-
1613
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
1714
def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=False, sort_columns=False, wide=True):
1815
"""

larray/inout/pandas.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
from larray.util.misc import basestring, decode, unique
1414

1515

16-
__all__ = ['from_frame', 'from_series']
17-
18-
1916
def parse(s):
2017
"""
2118
Used to parse the "folded" axis ticks (usually periods).

larray/inout/pickle.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
from larray.inout.common import FileHandler
1313

1414

15-
__all__ = []
16-
17-
1815
@register_file_handler('pickle', ['pkl', 'pickle'])
1916
class PickleHandler(FileHandler):
2017
def _open_for_read(self):

larray/inout/sas.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
from larray.util.misc import deprecate_kwarg
1111

1212

13-
__all__ = ['read_sas']
14-
15-
1613
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
1714
def read_sas(filepath, nb_axes=None, index_col=None, fill_value=nan, na=nan, sort_rows=False, sort_columns=False,
1815
**kwargs):

larray/inout/xw_excel.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
from larray.util.misc import PY2, deprecate_kwarg
2020

2121

22-
__all__ = ['open_excel', 'Workbook']
23-
24-
2522
string_types = (str,)
2623

2724

larray/random.py

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

28-
from larray.core import Axis, AxisCollection, LArray, aslarray, stack, ndtest
28+
from larray.core.axis import Axis, AxisCollection
29+
from larray.core.array import LArray, aslarray, stack, ndtest
2930
from larray.core.array import raw_broadcastable
3031
import larray as la
3132

33+
3234
__all__ = ['randint', 'normal', 'uniform', 'permutation', 'choice']
3335

3436

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ addopts = -v --doctest-modules --ignore=larray/core/npufuncs.py --ignore=larray/
1414
# E202: whitespace before ']'
1515
# E241: multiple spaces after ','
1616
# E303: too many blank lines
17+
# E402 module level import not at top of file
1718
# E712: comparison to True should be 'if cond is True:' or 'if cond:'
1819
pep8ignore =
20+
__init__.py E402
1921
xw_excel.py E303
2022
test_*.py E127 E122 E201 E202 E241 E712
2123
pep8maxlinelength = 120

0 commit comments

Comments
 (0)