Skip to content

Commit 8cbc503

Browse files
committed
Add Jupyter notebook format check using nbstripout
1 parent 3769709 commit 8cbc503

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

scripts/format_check.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ else
9191
exit 1
9292
fi
9393

94+
# Check Jupyter Notebook format
95+
echo "Checking Jupyter Notebook format..."
96+
if ! command -v nbstripout &> /dev/null
97+
then
98+
echo "nbstripout could not be found, please install it with 'pip install nbstripout'"
99+
exit 1
100+
fi
101+
102+
for notebook in $(find . -name "*.ipynb"); do
103+
nbstripout --check "$notebook"
104+
if [ $? -ne 0 ]; then
105+
echo "Notebook $notebook is not in the correct format. Please strip output and metadata."
106+
exit 1
107+
fi
108+
done
109+
94110
echo "Checking C++ formatting...";
95111
formatting_outputs=$(find tensorflow_quantum/ -iname *.h -o -iname *.cc | xargs clang-format -style=google -output-replacements-xml);
96112
CFORMATCHECK=0

0 commit comments

Comments
 (0)