Skip to content

Commit b547c0b

Browse files
authored
Fix ncdump in docs, to avoid problems with pytest doctests. (#149)
1 parent 046a717 commit b547c0b

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

docs/userdocs/getting_started/introduction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Simple example:
8181
>>> filepath = "./tmp.nc"
8282
>>> to_nc4(data, filepath)
8383
84-
>>> print(check_output("ncdump -h tmp.nc", shell=True).decode()) # doctest: +NORMALIZE_WHITESPACE
84+
>>> ncdump("tmp.nc") # utility calling 'ncdump -h' (not shown)
8585
netcdf tmp {
8686
dimensions:
8787
x = 3 ;

docs/userdocs/user_guide/howtos.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ i.e. wrong turns and gotchas, with brief descriptions of why.
1616
>>> from pprint import pprint
1717
>>> import numpy as np
1818
>>> from subprocess import check_output
19+
>>> def ncdump(path):
20+
... text = check_output(f'ncdump -h {path}', shell=True).decode()
21+
... text = text.replace("\t", " " * 3)
22+
... print(text)
23+
1924

2025
.. _howto_access:
2126

@@ -351,7 +356,7 @@ Use the :func:`ncdata.netcdf4.to_nc4` function to write data to a file:
351356

352357
>>> from ncdata.netcdf4 import to_nc4
353358
>>> to_nc4(data, filepath)
354-
>>> print(check_output(f"ncdump -h {filepath}", shell=True).decode()) # doctest: +NORMALIZE_WHITESPACE
359+
>>> ncdump(filepath) # utility calling 'ncdump -h' (not shown)
355360
netcdf ...{
356361
dimensions:
357362
x = 3 ;

0 commit comments

Comments
 (0)