Skip to content

Wrong parameter information in gensim.models.keyedvectors.KeyedVectors.save() docstring. #3528

Open
@Stfort52

Description

@Stfort52

Problem description

Wrong parameter docstrings are in gensim.models.keyedvectors.KeyedVectors.save().

Steps/code/corpus to reproduce

Its docstrings say it has fname as its first parameter,

def save(self, *args, **kwargs):
"""Save KeyedVectors to a file.
Parameters
----------
fname : str
Path to the output file.

but gensim.utils.SaveLoad.save()'s fname parameter was changed into fname_or_handle about 9 years ago(fcf12fa), which can be puzzling.

gensim/gensim/utils.py

Lines 724 to 734 in 645c2d1

def save(
self, fname_or_handle,
separately=None, sep_limit=10 * 1024**2, ignore=frozenset(), pickle_protocol=PICKLE_PROTOCOL,
):
"""Save the object to a file.
Parameters
----------
fname_or_handle : str or file-like
Path to output file or already opened file-like object. If the object is a file handle,
no special array handling will be performed, all attributes will be saved to the same file.

Could open a PR for this, but some docstrings like gensim.models.poincare.PoincareModel.save() has a different flavor, so I couldn't decide which one should I follow.

def save(self, *args, **kwargs):
"""Save complete model to disk, inherited from :class:`~gensim.utils.SaveLoad`.
See also
--------
:meth:`~gensim.models.poincare.PoincareModel.load`
Parameters
----------
*args
Positional arguments passed to :meth:`~gensim.utils.SaveLoad.save`.

Could be a nice idea to clean things up, I guess.

Versions

Pretty sure it's not going to matter, but here it is.

Linux-3.10.0-1160.el7.x86_64-x86_64-with-glibc2.17
Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
Bits 64
NumPy 1.26.4
SciPy 1.12.0
gensim 4.3.2
FAST_VERSION 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions