Skip to content

Commit 5678567

Browse files
jbrockmendelproost
authored andcommitted
CLN: remove never-used kwargs, make kwargs explicit (pandas-dev#29873)
1 parent f03d78c commit 5678567

File tree

1 file changed

+47
-54
lines changed

1 file changed

+47
-54
lines changed

pandas/io/pytables.py

+47-54
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,6 @@ def select_as_coordinates(
779779
where=None,
780780
start: Optional[int] = None,
781781
stop: Optional[int] = None,
782-
**kwargs,
783782
):
784783
"""
785784
return the selection as an Index
@@ -795,7 +794,7 @@ def select_as_coordinates(
795794
tbl = self.get_storer(key)
796795
if not isinstance(tbl, Table):
797796
raise TypeError("can only read_coordinates with a table")
798-
return tbl.read_coordinates(where=where, start=start, stop=stop, **kwargs)
797+
return tbl.read_coordinates(where=where, start=start, stop=stop)
799798

800799
def select_column(self, key: str, column: str, **kwargs):
801800
"""
@@ -2286,7 +2285,7 @@ def set_atom_data(self, block):
22862285
self.typ = self.get_atom_data(block)
22872286
self.set_data(block.values.astype(self.typ.type, copy=False))
22882287

2289-
def set_atom_categorical(self, block, items, info=None, values=None):
2288+
def set_atom_categorical(self, block, items, info=None):
22902289
# currently only supports a 1-D categorical
22912290
# in a 1-D block
22922291

@@ -2314,17 +2313,15 @@ def set_atom_categorical(self, block, items, info=None, values=None):
23142313
def get_atom_datetime64(self, block):
23152314
return _tables().Int64Col(shape=block.shape[0])
23162315

2317-
def set_atom_datetime64(self, block, values=None):
2316+
def set_atom_datetime64(self, block):
23182317
self.kind = "datetime64"
23192318
self.typ = self.get_atom_datetime64(block)
2320-
if values is None:
2321-
values = block.values.view("i8")
2319+
values = block.values.view("i8")
23222320
self.set_data(values, "datetime64")
23232321

2324-
def set_atom_datetime64tz(self, block, info, values=None):
2322+
def set_atom_datetime64tz(self, block, info):
23252323

2326-
if values is None:
2327-
values = block.values
2324+
values = block.values
23282325

23292326
# convert this column to i8 in UTC, and save the tz
23302327
values = values.asi8.reshape(block.shape)
@@ -2340,11 +2337,10 @@ def set_atom_datetime64tz(self, block, info, values=None):
23402337
def get_atom_timedelta64(self, block):
23412338
return _tables().Int64Col(shape=block.shape[0])
23422339

2343-
def set_atom_timedelta64(self, block, values=None):
2340+
def set_atom_timedelta64(self, block):
23442341
self.kind = "timedelta64"
23452342
self.typ = self.get_atom_timedelta64(block)
2346-
if values is None:
2347-
values = block.values.view("i8")
2343+
values = block.values.view("i8")
23482344
self.set_data(values, "timedelta64")
23492345

23502346
@property
@@ -2532,10 +2528,6 @@ def version(self) -> Tuple[int, int, int]:
25322528
def pandas_type(self):
25332529
return _ensure_decoded(getattr(self.group._v_attrs, "pandas_type", None))
25342530

2535-
@property
2536-
def format_type(self) -> str:
2537-
return "fixed"
2538-
25392531
def __repr__(self) -> str:
25402532
""" return a pretty representation of myself """
25412533
self.infer_axes()
@@ -2633,7 +2625,13 @@ def infer_axes(self):
26332625
self.get_attrs()
26342626
return True
26352627

2636-
def read(self, **kwargs):
2628+
def read(
2629+
self,
2630+
where=None,
2631+
columns=None,
2632+
start: Optional[int] = None,
2633+
stop: Optional[int] = None,
2634+
):
26372635
raise NotImplementedError(
26382636
"cannot read on an abstract storer: subclasses should implement"
26392637
)
@@ -2797,9 +2795,7 @@ def write_index(self, key, index):
27972795
self.write_sparse_intindex(key, index)
27982796
else:
27992797
setattr(self.attrs, f"{key}_variety", "regular")
2800-
converted = _convert_index(
2801-
"index", index, self.encoding, self.errors, self.format_type
2802-
)
2798+
converted = _convert_index("index", index, self.encoding, self.errors)
28032799

28042800
self.write_array(key, converted.values)
28052801

@@ -2848,9 +2844,7 @@ def write_multi_index(self, key, index):
28482844
"Saving a MultiIndex with an extension dtype is not supported."
28492845
)
28502846
level_key = f"{key}_level{i}"
2851-
conv_level = _convert_index(
2852-
level_key, lev, self.encoding, self.errors, self.format_type
2853-
)
2847+
conv_level = _convert_index(level_key, lev, self.encoding, self.errors)
28542848
self.write_array(level_key, conv_level.values)
28552849
node = getattr(self.group, level_key)
28562850
node._v_attrs.kind = conv_level.kind
@@ -3190,10 +3184,6 @@ def __init__(self, *args, **kwargs):
31903184
def table_type_short(self) -> str:
31913185
return self.table_type.split("_")[0]
31923186

3193-
@property
3194-
def format_type(self) -> str:
3195-
return "table"
3196-
31973187
def __repr__(self) -> str:
31983188
""" return a pretty representation of myself """
31993189
self.infer_axes()
@@ -3544,14 +3534,17 @@ def create_index(self, columns=None, optlevel=None, kind=None):
35443534
)
35453535
v.create_index(**kw)
35463536

3547-
def read_axes(self, where, **kwargs) -> bool:
3537+
def read_axes(
3538+
self, where, start: Optional[int] = None, stop: Optional[int] = None
3539+
) -> bool:
35483540
"""
35493541
Create the axes sniffed from the table.
35503542
35513543
Parameters
35523544
----------
35533545
where : ???
3554-
**kwargs
3546+
start: int or None, default None
3547+
stop: int or None, default None
35553548
35563549
Returns
35573550
-------
@@ -3567,21 +3560,19 @@ def read_axes(self, where, **kwargs) -> bool:
35673560
return False
35683561

35693562
# create the selection
3570-
selection = Selection(self, where=where, **kwargs)
3563+
selection = Selection(self, where=where, start=start, stop=stop)
35713564
values = selection.select()
35723565

35733566
# convert the data
35743567
for a in self.axes:
35753568
a.set_info(self.info)
3576-
# `kwargs` may contain `start` and `stop` arguments if passed to
3577-
# `store.select()`. If set they determine the index size.
35783569
a.convert(
35793570
values,
35803571
nan_rep=self.nan_rep,
35813572
encoding=self.encoding,
35823573
errors=self.errors,
3583-
start=kwargs.get("start"),
3584-
stop=kwargs.get("stop"),
3574+
start=start,
3575+
stop=stop,
35853576
)
35863577

35873578
return True
@@ -3636,7 +3627,6 @@ def create_axes(
36363627
nan_rep=None,
36373628
data_columns=None,
36383629
min_itemsize=None,
3639-
**kwargs,
36403630
):
36413631
""" create and return the axes
36423632
legacy tables create an indexable column, indexable index,
@@ -3706,9 +3696,7 @@ def create_axes(
37063696

37073697
if i in axes:
37083698
name = obj._AXIS_NAMES[i]
3709-
new_index = _convert_index(
3710-
name, a, self.encoding, self.errors, self.format_type
3711-
)
3699+
new_index = _convert_index(name, a, self.encoding, self.errors)
37123700
new_index.axis = i
37133701
index_axes_map[i] = new_index
37143702

@@ -3948,11 +3936,7 @@ def create_description(
39483936
return d
39493937

39503938
def read_coordinates(
3951-
self,
3952-
where=None,
3953-
start: Optional[int] = None,
3954-
stop: Optional[int] = None,
3955-
**kwargs,
3939+
self, where=None, start: Optional[int] = None, stop: Optional[int] = None,
39563940
):
39573941
"""select coordinates (row numbers) from a table; return the
39583942
coordinates object
@@ -4061,15 +4045,22 @@ def write(
40614045
chunksize=None,
40624046
expectedrows=None,
40634047
dropna=False,
4064-
**kwargs,
4048+
nan_rep=None,
4049+
data_columns=None,
4050+
errors="strict", # not used hre, but passed to super
40654051
):
40664052

40674053
if not append and self.is_exists:
40684054
self._handle.remove_node(self.group, "table")
40694055

40704056
# create the axes
40714057
self.create_axes(
4072-
axes=axes, obj=obj, validate=append, min_itemsize=min_itemsize, **kwargs
4058+
axes=axes,
4059+
obj=obj,
4060+
validate=append,
4061+
min_itemsize=min_itemsize,
4062+
nan_rep=nan_rep,
4063+
data_columns=data_columns,
40734064
)
40744065

40754066
for a in self.axes:
@@ -4219,11 +4210,7 @@ def write_data_chunk(self, rows, indexes, mask, values):
42194210
self.table.flush()
42204211

42214212
def delete(
4222-
self,
4223-
where=None,
4224-
start: Optional[int] = None,
4225-
stop: Optional[int] = None,
4226-
**kwargs,
4213+
self, where=None, start: Optional[int] = None, stop: Optional[int] = None,
42274214
):
42284215

42294216
# delete all rows (and return the nrows)
@@ -4303,9 +4290,15 @@ def get_object(self, obj):
43034290
obj = obj.T
43044291
return obj
43054292

4306-
def read(self, where=None, columns=None, **kwargs):
4293+
def read(
4294+
self,
4295+
where=None,
4296+
columns=None,
4297+
start: Optional[int] = None,
4298+
stop: Optional[int] = None,
4299+
):
43074300

4308-
if not self.read_axes(where=where, **kwargs):
4301+
if not self.read_axes(where=where, start=start, stop=stop):
43094302
return None
43104303

43114304
info = (
@@ -4349,7 +4342,7 @@ def read(self, where=None, columns=None, **kwargs):
43494342
else:
43504343
df = concat(frames, axis=1)
43514344

4352-
selection = Selection(self, where=where, **kwargs)
4345+
selection = Selection(self, where=where, start=start, stop=stop)
43534346
# apply the selection filters & axis orderings
43544347
df = self.process_axes(df, selection=selection, columns=columns)
43554348

@@ -4573,7 +4566,7 @@ def _set_tz(values, tz, preserve_UTC: bool = False, coerce: bool = False):
45734566
return values
45744567

45754568

4576-
def _convert_index(name: str, index, encoding=None, errors="strict", format_type=None):
4569+
def _convert_index(name: str, index, encoding=None, errors="strict"):
45774570
assert isinstance(name, str)
45784571

45794572
index_name = getattr(index, "name", None)

0 commit comments

Comments
 (0)