Skip to content

Commit

Permalink
Merge pull request #140 from davidhassell/master
Browse files Browse the repository at this point in the history
umfile.py docstrings
  • Loading branch information
davidhassell committed Nov 2, 2020
2 parents 53e777c + 3dc39e2 commit ca226ef
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions cf/umread_lib/umfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,16 @@ def __init__(self, int_hdr, real_hdr, hdr_offset, data_offset, disk_length,
'''Default instantiation, which stores the supplied headers and
offsets.
The *file* argument, used to set the `!file` attribute, does not
need to be supplied, but if it is not then it will have to be set
on the returned object (to the containing `File` object) before
calling `get_data` will work. Normally this would be done by the
calling code instantiating via `File` rather than directly.
:Parameters:
file: `File`, optional
Used to set the `!file` attribute. Does not need to be
supplied, but if it is not then it will have to be set on
the returned `Rec` object before calling `get_data` will
work. If set it should be set to the `File` object that
contains the returned `Rec` object. Normally this would be
done by the calling code instantiating via `File` rather
than directly.
'''
self.int_hdr = int_hdr
Expand All @@ -275,14 +280,30 @@ def __init__(self, int_hdr, real_hdr, hdr_offset, data_offset, disk_length,
self.file = file

@classmethod
def from_file_and_offsets(cls, file, hdr_offset, data_offset, disk_length):
def from_file_and_offsets(cls, file, hdr_offset, data_offset,
disk_length):
'''Instantiate a `Rec` object from the `File` object and the header
and data offsets.
The headers are read in, and also the record object is ready for
calling `get_data`.
:Returns:
:Parameters:
file: `File`
A view of a file including sets of PP records combined
into variables.
hdr_offset: `int`
The start word in the file of the header.
data_offset: `int`
The start word in the file of the data.
disk_length: `int`
The length in words of the data in the file.
:Returns:
`Rec`
Expand All @@ -296,7 +317,9 @@ def from_file_and_offsets(cls, file, hdr_offset, data_offset, disk_length):
)

return cls(
int_hdr, real_hdr, hdr_offset, data_offset, disk_length, file=file)
int_hdr, real_hdr, hdr_offset, data_offset, disk_length,
file=file
)

def read_extra_data(self):
'''Read the extra data associated with the record.
Expand Down

0 comments on commit ca226ef

Please sign in to comment.