Skip to content

Commit

Permalink
update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Jul 4, 2021
1 parent 267895f commit 445f131
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/sourmash/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
class MultiIndex - in-memory storage and selection of signatures from multiple
index objects, using manifests.
class DirectoryIndex - on-disk storage and selection of signatures from
under a directory, requiring a manifest.
class LazyLoadedIndex - lazy-loading wrapper for on-disk indices, using
manifests. Signatures are kept on disk until requested; only manifests are
retained, and no open file handles or signatures.
Expand Down Expand Up @@ -386,6 +389,8 @@ class LinearIndex(Index):
"""An Index for a collection of signatures. Can load from a .sig file.
Note: does not use manifests. See MultiIndex for that functionality.
Concrete class; signatures held in memory; does not use manifests.
"""
def __init__(self, _signatures=None, filename=None):
self._signatures = []
Expand Down Expand Up @@ -437,6 +442,8 @@ def select(self, **kwargs):
class LazyLinearIndex(Index):
"""An Index for lazy linear search of another database.
Wrapper class; does not use manifests.
One of the main purposes of this class is to _force_ linear 'find'
on index objects. So if this class wraps an SBT, for example, the
SBT find method will be overriden with the linear 'find' from the
Expand Down Expand Up @@ -510,6 +517,8 @@ class ZipFileLinearIndex(Index):
A read-only collection of signatures in a zip file.
Does not support `insert` or `save`.
Concrete class; signatures dynamically loaded from disk; uses manifests.
"""
is_database = True

Expand Down Expand Up @@ -833,6 +842,8 @@ class MultiIndex(Index):
Note: this is an in-memory collection, and does not do lazy loading:
all signatures are loaded upon instantiation and kept in memory.
Concrete class; signatures held in memory; builds and uses manifests.
"""
def __init__(self, manifest, parent=None):
self.manifest = manifest
Expand Down Expand Up @@ -991,7 +1002,10 @@ def select(self, **kwargs):


class DirectoryIndex(Index):
"""
"""An Index for a collection of signature files under a directory.
Concrete class; signatures dynamically loaded from disk; uses manifests.
Notes:
* manifests for directories are _generated_ by MultiIndex :grin: :shrug:
* Lazy - loads signatures only when requested
Expand All @@ -1012,7 +1026,7 @@ def __init__(self, parent, manifest):
def load(cls, pathname):
"Create a DirectoryIndex from a directory with an existing manifest."
if not os.path.isdir(pathname):
raise ValueError(f"'{pathname}' must be a directory.")
raise ValueError(f"'{pathname}' must be a directory")

manifest_path = os.path.join(pathname, "SOURMASH-MANIFEST.csv")
if not os.path.exists(manifest_path):
Expand Down Expand Up @@ -1061,6 +1075,8 @@ class LazyLoadedIndex(Index):
from disk every time they are needed (e.g. 'find(...)', 'signatures()').
Can be used with LazyMultiIndex to support many such indices at once.
Wrapper class; signatures dynamically loaded from disk; uses manifests.
"""
def __init__(self, filename, manifest):
"Create an Index with given filename and manifest."
Expand Down Expand Up @@ -1139,6 +1155,8 @@ class LazyMultiIndex(Index):
Differs from MultiIndex in that only the manifests are held in memory,
not any of the signatures.
Wrapper class; signatures loaded index objects; uses manifests.
CTB: could we get the same functionality from MultiIndex + LazyLoadedIndex?
"""
def __init__(self, index_list, manifest_list):
Expand Down

0 comments on commit 445f131

Please sign in to comment.