connect (function)

Connect to a Loom file.

loompy.connect(filename: str, mode: str = 'r+', *, validate: bool = True, spec_version: str = '3.0.0') → loompy.loompy.LoomConnection[source]

Establish a connection to a .loom file.

Parameters
  • filename – Path to the Loom file to open

  • mode – Read/write mode, ‘r+’ (read/write) or ‘r’ (read-only), defaults to ‘r+’

  • validate – Validate the file structure against the Loom file format specification

  • spec_version – The loom file spec version to validate against (e.g. “2.0.1” or “old”)

Returns

A LoomConnection instance.

Remarks:

This function should typically be used as a context manager (i.e. inside a with-block):

import loompy
with loompy.connect("mydata.loom") as ds:
        print(ds.ca.keys())

This ensures that the file will be closed automatically when the context block ends

Note: if validation is requested, an exception is raised if validation fails.