Skip to content

Commit f9be896

Browse files
committed
added returned type to read_XXX() functions (issue #864)
1 parent 161eaf5 commit f9be896

File tree

7 files changed

+16
-12
lines changed

7 files changed

+16
-12
lines changed

larray/inout/csv.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
2020
def read_csv(filepath_or_buffer, nb_axes=None, index_col=None, sep=',', headersep=None, fill_value=nan,
21-
na=nan, sort_rows=False, sort_columns=False, wide=True, dialect='larray', **kwargs):
21+
na=nan, sort_rows=False, sort_columns=False, wide=True, dialect='larray', **kwargs) -> Array:
2222
r"""
2323
Reads csv file and returns an array with the contents.
2424
@@ -228,11 +228,11 @@ def read_csv(filepath_or_buffer, nb_axes=None, index_col=None, sep=',', headerse
228228
return df_asarray(df, sort_rows=sort_rows, sort_columns=sort_columns, fill_value=fill_value, raw=raw, wide=wide)
229229

230230

231-
def read_tsv(filepath_or_buffer, **kwargs):
231+
def read_tsv(filepath_or_buffer, **kwargs) -> Array:
232232
return read_csv(filepath_or_buffer, sep='\t', **kwargs)
233233

234234

235-
def read_eurostat(filepath_or_buffer, **kwargs):
235+
def read_eurostat(filepath_or_buffer, **kwargs) -> Array:
236236
r"""Reads EUROSTAT TSV (tab-separated) file into an array.
237237
238238
EUROSTAT TSV files are special because they use tabs as data separators but comas to separate headers.

larray/inout/excel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
@deprecate_kwarg('sheetname', 'sheet')
3232
# We use "# doctest: +SKIP" for all tests because they work only if openpyxl (an *optional* dependency) is installed
3333
def read_excel(filepath, sheet=0, nb_axes=None, index_col=None, fill_value=nan, na=nan,
34-
sort_rows=False, sort_columns=False, wide=True, engine=None, range=slice(None), **kwargs):
34+
sort_rows=False, sort_columns=False, wide=True, engine=None, range=slice(None), **kwargs) -> Array:
3535
r"""
3636
Reads excel file from sheet name and returns an Array with the contents
3737

larray/inout/hdf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _get_type_from_attrs(attrs):
2323

2424

2525
def read_hdf(filepath_or_buffer, key, fill_value=nan, na=nan, sort_rows=False, sort_columns=False,
26-
name=None, **kwargs):
26+
name=None, **kwargs) -> Array:
2727
r"""Reads a scalar or an axis or group or array named key from a HDF5 file in filepath (path+name)
2828
2929
Parameters

larray/inout/misc.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from pandas import DataFrame, Index
44

5+
from larray.core.array import Array
56
from larray.core.constants import nan
67
from larray.util.misc import deprecate_kwarg
78
from larray.inout.common import _get_index_col
@@ -10,7 +11,8 @@
1011

1112

1213
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
13-
def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=False, sort_columns=False, wide=True):
14+
def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=False, sort_columns=False,
15+
wide=True) -> Array:
1416
r"""
1517
initialize array from a list of lists (lines)
1618
@@ -123,7 +125,7 @@ def from_lists(data, nb_axes=None, index_col=None, fill_value=nan, sort_rows=Fal
123125

124126

125127
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
126-
def from_string(s, nb_axes=None, index_col=None, sep=' ', wide=True, **kwargs):
128+
def from_string(s, nb_axes=None, index_col=None, sep=' ', wide=True, **kwargs) -> Array:
127129
r"""Create an array from a multi-line string.
128130
129131
Parameters

larray/inout/pandas.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def cartesian_product_df(df, sort_rows=False, sort_columns=False, fill_value=nan
7676
return df.reindex(index=new_index, columns=columns, fill_value=fill_value, **kwargs), labels
7777

7878

79-
def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs):
79+
def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs) -> Array:
8080
r"""
8181
Converts Pandas Series into Array.
8282
@@ -145,7 +145,7 @@ def from_series(s, sort_rows=False, fill_value=nan, meta=None, **kwargs):
145145

146146

147147
def from_frame(df, sort_rows=False, sort_columns=False, parse_header=False, unfold_last_axis_name=False,
148-
fill_value=nan, meta=None, cartesian_prod=True, **kwargs):
148+
fill_value=nan, meta=None, cartesian_prod=True, **kwargs) -> Array:
149149
r"""
150150
Converts Pandas DataFrame into Array.
151151
@@ -275,7 +275,7 @@ def set_dataframe_index_by_position(df, index_col_indices):
275275

276276

277277
def df_asarray(df, sort_rows=False, sort_columns=False, raw=False, parse_header=True, wide=True, cartesian_prod=True,
278-
**kwargs):
278+
**kwargs) -> Array:
279279
r"""
280280
Prepare Pandas DataFrame and then convert it into Array.
281281

larray/inout/sas.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import numpy as np
44
import pandas as pd
55

6+
from larray.core.array import Array
67
from larray.core.constants import nan
78
from larray.inout.pandas import df_asarray
89
from larray.util.misc import deprecate_kwarg
910

1011

1112
@deprecate_kwarg('nb_index', 'nb_axes', arg_converter=lambda x: x + 1)
1213
def read_sas(filepath, nb_axes=None, index_col=None, fill_value=nan, na=nan, sort_rows=False, sort_columns=False,
13-
**kwargs):
14+
**kwargs) -> Array:
1415
r"""
1516
Reads sas file and returns an Array with the contents
1617
nb_axes: number of axes of the output array

larray/inout/stata.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import pandas as pd
22

3+
from larray.core.array import Array
34
from larray.inout.pandas import from_frame
45

56
__all__ = ['read_stata']
67

78

8-
def read_stata(filepath_or_buffer, index_col=None, sort_rows=False, sort_columns=False, **kwargs):
9+
def read_stata(filepath_or_buffer, index_col=None, sort_rows=False, sort_columns=False, **kwargs) -> Array:
910
r"""
1011
Reads Stata .dta file and returns an Array with the contents
1112

0 commit comments

Comments
 (0)