Skip to content

Commit fd5a39e

Browse files
committed
renamed the LArray class as Array -> larray/inout
1 parent 1c4d909 commit fd5a39e

File tree

10 files changed

+55
-55
lines changed

10 files changed

+55
-55
lines changed

larray/inout/common.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
from collections import OrderedDict
55

6-
from larray.core.array import LArray
6+
from larray.core.array import Array
77

88

99
def _get_index_col(nb_axes=None, index_col=None, wide=True):
@@ -112,7 +112,7 @@ def read(self, keys, *args, **kwargs):
112112
-------
113113
Metadata
114114
List of metadata to load.
115-
OrderedDict(str, LArray/Axis/Group)
115+
OrderedDict(str, Array/Axis/Group)
116116
Dictionary containing the loaded objects.
117117
"""
118118
display = kwargs.pop('display', False)
@@ -144,7 +144,7 @@ def dump(self, metadata, key_values, *args, **kwargs):
144144
----------
145145
metadata: Metadata
146146
List of metadata to dump.
147-
key_values : list of (str, LArray/Axis/Group) pairs
147+
key_values : list of (str, Array/Axis/Group) pairs
148148
Name and data of objects to dump.
149149
kwargs :
150150
* display: whether or not to display when the dump of each object is started/done.
@@ -155,7 +155,7 @@ def dump(self, metadata, key_values, *args, **kwargs):
155155
if metadata is not None:
156156
self._dump_metadata(metadata)
157157
for key, value in key_values:
158-
if isinstance(value, LArray) and value.ndim == 0:
158+
if isinstance(value, Array) and value.ndim == 0:
159159
if display:
160160
print('Cannot dump {}. Dumping 0D arrays is currently not supported.'.format(key))
161161
continue

larray/inout/csv.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pandas as pd
1010
import numpy as np
1111

12-
from larray.core.array import LArray, aslarray, ndtest
12+
from larray.core.array import Array, aslarray, ndtest
1313
from larray.core.axis import Axis
1414
from larray.core.constants import nan
1515
from larray.core.group import Group
@@ -42,7 +42,7 @@ def read_csv(filepath_or_buffer, nb_axes=None, index_col=None, sep=',', headerse
4242
Separator.
4343
headersep : str or None, optional
4444
Separator for headers.
45-
fill_value : scalar or LArray, optional
45+
fill_value : scalar or Array, optional
4646
Value used to fill cells corresponding to label combinations which are not present in the input.
4747
Defaults to NaN.
4848
sort_rows : bool, optional
@@ -61,7 +61,7 @@ def read_csv(filepath_or_buffer, nb_axes=None, index_col=None, sep=',', headerse
6161
6262
Returns
6363
-------
64-
LArray
64+
Array
6565
6666
Notes
6767
-----
@@ -251,7 +251,7 @@ def read_eurostat(filepath_or_buffer, **kwargs):
251251
252252
Returns
253253
-------
254-
LArray
254+
Array
255255
"""
256256
return read_csv(filepath_or_buffer, sep='\t', headersep=',', **kwargs)
257257

@@ -351,7 +351,7 @@ def _read_item(self, key, type, *args, **kwargs):
351351
raise TypeError()
352352

353353
def _dump_item(self, key, value, *args, **kwargs):
354-
if isinstance(value, LArray):
354+
if isinstance(value, Array):
355355
value.to_csv(self._to_filepath(key), *args, **kwargs)
356356
elif isinstance(value, Axis):
357357
self.axes[key] = value

larray/inout/excel.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
except ImportError:
1212
xw = None
1313

14-
from larray.core.array import LArray, aslarray
14+
from larray.core.array import Array, aslarray
1515
from larray.core.axis import Axis
1616
from larray.core.constants import nan
1717
from larray.core.group import Group, _translate_sheet_name
@@ -33,7 +33,7 @@
3333
def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan, na=nan,
3434
sort_rows=False, sort_columns=False, wide=True, engine=None, range=slice(None), **kwargs):
3535
r"""
36-
Reads excel file from sheet name and returns an LArray with the contents
36+
Reads excel file from sheet name and returns an Array with the contents
3737
3838
Parameters
3939
----------
@@ -49,7 +49,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
4949
array is assumed to have one axis. Defaults to None.
5050
index_col : list, optional
5151
Positions of columns for the n-1 first axes (ex. [0, 1, 2, 3]). Defaults to None (see nb_axes above).
52-
fill_value : scalar or LArray, optional
52+
fill_value : scalar or Array, optional
5353
Value used to fill cells corresponding to label combinations which are not present in the input.
5454
Defaults to NaN.
5555
sort_rows : bool, optional
@@ -71,7 +71,7 @@ def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan,
7171
7272
Returns
7373
-------
74-
LArray
74+
Array
7575
7676
Examples
7777
--------
@@ -292,7 +292,7 @@ def _read_item(self, key, type, *args, **kwargs):
292292

293293
def _dump_item(self, key, value, *args, **kwargs):
294294
kwargs['engine'] = 'xlsxwriter'
295-
if isinstance(value, LArray):
295+
if isinstance(value, Array):
296296
value.to_excel(self.handle, key, *args, **kwargs)
297297
elif isinstance(value, Axis):
298298
self.axes[key] = value
@@ -395,7 +395,7 @@ def _read_item(self, key, type, *args, **kwargs):
395395
raise TypeError()
396396

397397
def _dump_item(self, key, value, *args, **kwargs):
398-
if isinstance(value, LArray):
398+
if isinstance(value, Array):
399399
self.handle[key] = value.dump(*args, **kwargs)
400400
elif isinstance(value, Axis):
401401
self.axes[key] = value

larray/inout/hdf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from pandas import HDFStore
77

8-
from larray.core.array import LArray
8+
from larray.core.array import Array
99
from larray.core.axis import Axis
1010
from larray.core.constants import nan
1111
from larray.core.group import Group, LGroup, _translate_group_key_hdf
@@ -27,7 +27,7 @@ def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, s
2727
Path and name where the HDF5 file is stored or a HDFStore object.
2828
key : str or Group
2929
Name of the array.
30-
fill_value : scalar or LArray, optional
30+
fill_value : scalar or Array, optional
3131
Value used to fill cells corresponding to label combinations which are not present in the input.
3232
Defaults to NaN.
3333
sort_rows : bool, optional
@@ -44,7 +44,7 @@ def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, s
4444
4545
Returns
4646
-------
47-
LArray
47+
Array
4848
4949
Examples
5050
--------
@@ -76,7 +76,7 @@ def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, s
7676
# for backward compatibility but any object read from an hdf file should have an attribute 'type'
7777
_type = attrs.type if 'type' in attrs else 'Array'
7878
_meta = attrs.metadata if 'metadata' in attrs else None
79-
if _type == 'Array':
79+
if _type in ['Array', 'LArray']:
8080
# cartesian product is not necessary if the array was written by LArray
8181
cartesian_prod = writer != 'LArray'
8282
res = df_aslarray(pd_obj, sort_rows=sort_rows, sort_columns=sort_columns, fill_value=fill_value,
@@ -141,7 +141,7 @@ def _read_item(self, key, type, *args, **kwargs):
141141
return read_hdf(self.handle, hdf_key, *args, **kwargs)
142142

143143
def _dump_item(self, key, value, *args, **kwargs):
144-
if isinstance(value, LArray):
144+
if isinstance(value, Array):
145145
hdf_key = '/' + key
146146
value.to_hdf(self.handle, hdf_key, *args, **kwargs)
147147
elif isinstance(value, Axis):

larray/inout/misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=Fal
2626
is assumed to have one axis. Defaults to None.
2727
index_col : list, optional
2828
Positions of columns for the n-1 first axes (ex. [0, 1, 2, 3]). Defaults to None (see nb_axes above).
29-
fill_value : scalar or LArray, optional
29+
fill_value : scalar or Array, optional
3030
Value used to fill cells corresponding to label combinations which are not present in the input.
3131
Defaults to NaN.
3232
sort_rows : bool, optional
@@ -41,7 +41,7 @@ def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=Fal
4141
4242
Returns
4343
-------
44-
LArray
44+
Array
4545
4646
Examples
4747
--------
@@ -144,7 +144,7 @@ def from_string(s, nb_axes=None, index_col=None, sep=' ', wide=True, **kwargs):
144144
145145
Returns
146146
-------
147-
LArray
147+
Array
148148
149149
Examples
150150
--------

larray/inout/pandas.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pandas as pd
88

9-
from larray.core.array import LArray
9+
from larray.core.array import Array
1010
from larray.core.axis import Axis, AxisCollection
1111
from larray.core.group import LGroup
1212
from larray.core.constants import nan
@@ -74,7 +74,7 @@ def cartesian_product_df(df, sort_rows=False, sort_columns=False, fill_value=nan
7474

7575
def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs):
7676
r"""
77-
Converts Pandas Series into LArray.
77+
Converts Pandas Series into Array.
7878
7979
Parameters
8080
----------
@@ -91,11 +91,11 @@ def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs):
9191
9292
Returns
9393
-------
94-
LArray
94+
Array
9595
9696
See Also
9797
--------
98-
LArray.to_series
98+
Array.to_series
9999
100100
Examples
101101
--------
@@ -137,13 +137,13 @@ def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs):
137137
name = decode(s.name, 'utf8') if s.name is not None else decode(s.index.name, 'utf8')
138138
if sort_rows:
139139
s = s.sort_index()
140-
return LArray(s.values, Axis(s.index.values, name), meta=meta)
140+
return Array(s.values, Axis(s.index.values, name), meta=meta)
141141

142142

143143
def from_frame(df, sort_rows=False, sort_columns=False, parse_header=False, unfold_last_axis_name=False,
144144
fill_value=nan, meta=None, cartesian_prod=True, **kwargs):
145145
r"""
146-
Converts Pandas DataFrame into LArray.
146+
Converts Pandas DataFrame into Array.
147147
148148
Parameters
149149
----------
@@ -171,18 +171,18 @@ def from_frame(df, sort_rows=False, sort_columns=False, parse_header=False, unfo
171171
Metadata (title, description, author, creation_date, ...) associated with the array.
172172
Keys must be strings. Values must be of type string, int, float, date, time or datetime.
173173
cartesian_prod : bool, optional
174-
Whether or not to expand the dataframe to a cartesian product dataframe as needed by LArray.
174+
Whether or not to expand the dataframe to a cartesian product dataframe as needed by Array.
175175
This is an expensive operation but is absolutely required if you cannot guarantee your dataframe is already
176176
well formed. If True, arguments `sort_rows` and `sort_columns` must be set to False.
177177
Defaults to True.
178178
179179
Returns
180180
-------
181-
LArray
181+
Array
182182
183183
See Also
184184
--------
185-
LArray.to_frame
185+
Array.to_frame
186186
187187
Examples
188188
--------
@@ -249,13 +249,13 @@ def from_frame(df, sort_rows=False, sort_columns=False, parse_header=False, unfo
249249

250250
axes = AxisCollection([Axis(labels, name) for labels, name in zip(axes_labels, axes_names)])
251251
data = df.values.reshape(axes.shape)
252-
return LArray(data, axes, meta=meta)
252+
return Array(data, axes, meta=meta)
253253

254254

255255
def df_aslarray(df, sort_rows=False, sort_columns=False, raw=False, parse_header=True, wide=True, cartesian_prod=True,
256256
**kwargs):
257257
r"""
258-
Prepare Pandas DataFrame and then convert it into LArray.
258+
Prepare Pandas DataFrame and then convert it into Array.
259259
260260
Parameters
261261
----------
@@ -280,14 +280,14 @@ def df_aslarray(df, sort_rows=False, sort_columns=False, raw=False, parse_header
280280
If False, the array is assumed to be stored in "narrow" format: one column per axis plus one value column.
281281
Defaults to True.
282282
cartesian_prod : bool, optional
283-
Whether or not to expand the dataframe to a cartesian product dataframe as needed by LArray.
283+
Whether or not to expand the dataframe to a cartesian product dataframe as needed by Array.
284284
This is an expensive operation but is absolutely required if you cannot guarantee your dataframe is already
285285
well formed. If True, arguments `sort_rows` and `sort_columns` must be set to False.
286286
Defaults to True.
287287
288288
Returns
289289
-------
290-
LArray
290+
Array
291291
"""
292292
# we could inline df_aslarray into the functions that use it, so that the original (non-cartesian) df is freed from
293293
# memory at this point, but it would be much uglier and would not lower the peak memory usage which happens during

larray/inout/pickle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from larray.core.axis import Axis
77
from larray.core.group import Group
8-
from larray.core.array import LArray
8+
from larray.core.array import Array
99
from larray.core.metadata import Metadata
1010
from larray.util.misc import pickle
1111
from larray.inout.session import register_file_handler
@@ -30,7 +30,7 @@ def list_items(self):
3030
# groups
3131
items += [(key, 'Group') for key, value in self.data.items() if isinstance(value, Group)]
3232
# arrays
33-
items += [(key, 'Array') for key, value in self.data.items() if isinstance(value, LArray)]
33+
items += [(key, 'Array') for key, value in self.data.items() if isinstance(value, Array)]
3434
return items
3535

3636
def _read_item(self, key, type, *args, **kwargs):
@@ -40,7 +40,7 @@ def _read_item(self, key, type, *args, **kwargs):
4040
raise TypeError()
4141

4242
def _dump_item(self, key, value, *args, **kwargs):
43-
if isinstance(value, (LArray, Axis, Group)):
43+
if isinstance(value, (Array, Axis, Group)):
4444
self.data[key] = value
4545
else:
4646
raise TypeError()

larray/inout/sas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
def read_sas(filepath, nb_axes=None, index_col=None, fill_value=nan, na=nan, sort_rows=False, sort_columns=False,
1515
**kwargs):
1616
r"""
17-
Reads sas file and returns an LArray with the contents
17+
Reads sas file and returns an Array with the contents
1818
nb_axes: number of axes of the output array
1919
or
2020
index_col: Positions of columns for the n-1 first axes (ex. [0, 1, 2, 3])

larray/inout/stata.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def read_stata(filepath_or_buffer, index_col=None, sort_rows=False, sort_columns=False, **kwargs):
1111
r"""
12-
Reads Stata .dta file and returns an LArray with the contents
12+
Reads Stata .dta file and returns an Array with the contents
1313
1414
Parameters
1515
----------
@@ -26,15 +26,15 @@ def read_stata(filepath_or_buffer, index_col=None, sort_rows=False, sort_columns
2626
2727
Returns
2828
-------
29-
LArray
29+
Array
3030
3131
See Also
3232
--------
33-
LArray.to_stata
33+
Array.to_stata
3434
3535
Notes
3636
-----
37-
The round trip to Stata (LArray.to_stata followed by read_stata) loose the name of the "column" axis.
37+
The round trip to Stata (Array.to_stata followed by read_stata) loose the name of the "column" axis.
3838
3939
Examples
4040
--------

0 commit comments

Comments
 (0)