scippneutron.io.cif.Chunk#

class scippneutron.io.cif.Chunk(pairs, /, *, comment='', schema=None)[source]#

A group of CIF key-value pairs.

Chunks contain one or more key-value pairs where values are scalars, i.e., not arrays. Chunks are represented in files as a group of pairs separated from other chunks and loops by empty lines.

Note that CIF has no concept of chunks; they are only used for organizing data in ScippNeutron.

__init__(pairs, /, *, comment='', schema=None)[source]#

Create a new CIF chunk.

Parameters:
  • pairs (Mapping[str, Any] | Iterable[tuple[str, Any]] | None) – Defines a mapping from keys (a.k.a. tags) to values.

  • comment (str, default: '') – Optional comment that can be written above the chunk in the file.

  • schema (Union[CIFSchema, Iterable[CIFSchema], None], default: None) – CIF schemas used for the chunk. Content is not checked against the schema, but the schema is written to the file.

Methods

__init__(pairs, /, *[, comment, schema])

Create a new CIF chunk.

write(f)

Write this chunk to a file.

Attributes

comment

Optional comment that can be written above the object in the file.

schema

CIF schemas used for the object.

write(f)[source]#

Write this chunk to a file.

Used mainly internally, use scippneutron.io.cif.save_cif() instead.

Parameters:

f (TextIOBase) – File handle.

Return type:

None