From 143f1277a1e5a1d9193529c97c3e5408d90e95d3 Mon Sep 17 00:00:00 2001 From: Kimoon Han <98246499+kmnhan@users.noreply.github.com> Date: Wed, 3 Apr 2024 23:27:09 +0900 Subject: [PATCH] docs: Add docstring to load() in packed.py --- igor2/packed.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/igor2/packed.py b/igor2/packed.py index caf413a..d41ffd1 100644 --- a/igor2/packed.py +++ b/igor2/packed.py @@ -44,6 +44,28 @@ def load(filename, strict=True, ignore_unknown=True, initial_byte_order=None): + """Load a packed experiment file. + + Parameters + ---------- + filename : str or file-like object + The path to the file or a file-like object representing the packed + experiment file. + strict : bool, optional + This parameter is ignored. Defaults to True. + ignore_unknown : bool, optional + If True, ignore unknown record types. Defaults to True. + initial_byte_order : str or None, optional + The initial byte order to use for unpacking. Must be one of '>', '=', + '<'. If None, '=' is used. Defaults to None. + + Returns + ------- + records : list of Record + The records in the packed experiment file. + filesystem : dict + The filesystem structure of the packed experiment file. + """ logger.debug('loading a packed experiment file from {}'.format(filename)) records = [] if hasattr(filename, 'read'): @@ -81,7 +103,8 @@ def load(filename, strict=True, ignore_unknown=True, initial_byte_order=None): data = bytes(f.read(header['numDataBytes'])) if len(data) < header['numDataBytes']: raise ValueError( - ('not enough data for the next record ({} < {})' + ('not enough data for the next record ({} < {}), ' + 'try loading with a different initial byte order' ).format(len(b), header['numDataBytes'])) record_type = _RECORD_TYPE.get( header['recordType'] & PACKEDRECTYPE_MASK, _UnknownRecord)