Skip to content

Commit

Permalink
style/doc improvements after review.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas loubrieu committed Feb 20, 2024
1 parent 09cabca commit aa1cef5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ccsdspy/packet_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def load(self, file, include_primary_header=False, reset_file_obj=False):
reset_file_obj : bool
If True, leave the file object, when it is file buffer, where it was before load is called.
Otherwise, (default), leave the file stream pos after the read packets.
Does not apply when file is a file location.
Does not apply when file is a string.
Returns
-------
Expand Down Expand Up @@ -282,7 +282,7 @@ def load(self, file, include_primary_header=False, reset_file_obj=False):
reset_file_obj : bool
If True, leave the file object, when it is file buffer, where it was before load is called.
Otherwise, (default), leave the file stream pos after the read packets.
Does not apply when file is a file location.
Does not apply when file is a string.
Returns
-------
Expand Down Expand Up @@ -628,7 +628,7 @@ def _load(
reset_file_obj : bool
If True, leave the file object, when it is a file buffer, where it was before _load is called.
Otherwise, (default), leave the file stream pos after the read packets.
Does not apply when file is a file location.
Does not apply when file is a string.
Returns
-------
Expand All @@ -641,7 +641,7 @@ def _load(
the decoder_name is not one of the allowed values
"""
if hasattr(file, "read"):
pos = file.tell()
file_pos = file.tell()
file_bytes = np.frombuffer(file.read(), "u1")
else:
file_bytes = np.fromfile(file, "u1")
Expand All @@ -668,7 +668,7 @@ def _load(
field_arrays = _apply_converters(field_arrays, converters)

if hasattr(file, "read") and reset_file_obj:
file.seek(pos)
file.seek(file_pos)
return field_arrays


Expand Down
1 change: 1 addition & 0 deletions ccsdspy/tests/test_packet_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def test_variable_length_rejects_bit_offset():


def test_load_without_moving_file_buffer_pos():
"""Tests that load(..., reset_file_obj=True) works as intended."""
pkts = FixedLength.from_file(random_packet_def)
with open(random_binary_file, "rb") as fp:
pos = fp.tell()
Expand Down

0 comments on commit aa1cef5

Please sign in to comment.