Skip to content

Commit

Permalink
Remove cif.Block.save
Browse files Browse the repository at this point in the history
  • Loading branch information
jl-wynen committed Dec 11, 2023
1 parent 19cbab0 commit 903e440
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 48 deletions.
34 changes: 3 additions & 31 deletions src/scippneutron/io/cif.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,6 @@ def save_cif(
Path or file handle for the output file.
blocks:
One or more CIF data blocks to write to the file.
See also
--------
scippneutron.io.cif.Block.save:
Method for saving a single block.
"""
if isinstance(blocks, Block):
blocks = (blocks,)
Expand Down Expand Up @@ -173,8 +168,7 @@ def schema(self) -> set[CIFSchema]:
def write(self, f: io.TextIOBase) -> None:
"""Write this chunk to a file.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif`
or :meth:`scippneutron.io.cif.Block.save` instead.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif` instead.
Parameters
----------
Expand Down Expand Up @@ -261,8 +255,7 @@ def __setitem__(self, name: str, value: sc.Variable) -> None:
def write(self, f: io.TextIOBase) -> None:
"""Write this loop to a file.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif`
or :meth:`scippneutron.io.cif.Block.save` instead.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif` instead.
Parameters
----------
Expand Down Expand Up @@ -470,8 +463,7 @@ def add_powder_calibration(self, cal: sc.DataArray, *, comment: str = '') -> Non
def write(self, f: io.TextIOBase) -> None:
"""Write this block to a file.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif`
or :meth:`scippneutron.io.cif.Block.save` instead.
Used mainly internally, use :func:`scippneutron.io.cif.save_cif` instead.
Parameters
----------
Expand All @@ -487,26 +479,6 @@ def write(self, f: io.TextIOBase) -> None:
f.write('\n')
_write_multi(f, self._content)

def save(
self,
fname: Union[str, Path, io.TextIOBase],
) -> None:
"""Save this block to a CIF file.
Equivalent to ``cif.save_cif(fname, self)``.
Parameters
----------
fname:
Path or file handle for the output file.
See also
--------
scippneutron.io.cif.save_cif:
Free function for saving one or more blocks.
"""
save_cif(fname, self)


def _convert_input_content(
content: Iterable[Union[Mapping[str, Any], Loop, Chunk]]
Expand Down
17 changes: 0 additions & 17 deletions tests/io/cif_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,23 +714,6 @@ def test_save_cif_one_block_buffer():
)


def test_save_method_one_block_buffer():
block1 = cif.Block(
'block-1', [{'audit.creation_method': 'written by scippneutron'}]
)
buffer = io.StringIO()
block1.save(buffer)
buffer.seek(0)
assert (
buffer.read()
== r'''#\#CIF_1.1
data_block-1
_audit.creation_method 'written by scippneutron'
'''
)


def test_save_cif_two_blocks_buffer():
env = sc.array(dims=['env'], values=['water', 'sulfur'])
block1 = cif.Block(
Expand Down

0 comments on commit 903e440

Please sign in to comment.