Skip to content

Commit ecf14ff

Browse files
authored
docs: Run Notebook files converted to *.py files under tutorials (#729)
1 parent e91bbfc commit ecf14ff

File tree

6 files changed

+57
-373
lines changed

6 files changed

+57
-373
lines changed

ci/test_examples.sh

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
for example in $(find ./examples/ -iname *.py); do
1+
for example in $(find ./examples/ -iname *.py) $(find ./docs/examples/ -iname *.py); do
22
CI_MODE=1 python $example
33
done

docs/examples/finch_example.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ---
2+
# jupyter:
3+
# jupytext:
4+
# text_representation:
5+
# extension: .py
6+
# format_name: light
7+
# format_version: '1.5'
8+
# jupytext_version: 1.16.3
9+
# kernelspec:
10+
# display_name: sparse
11+
# language: python
12+
# name: python3
13+
# ---
14+
15+
# ## Import
16+
# Let's set the backend and import `sparse`.
17+
18+
# +
19+
import os
20+
21+
os.environ["SPARSE_BACKEND"] = "Finch"
22+
23+
import sparse
24+
25+
import numpy as np
26+
27+
# -
28+
29+
# ## Perform Operations
30+
# Let's create two arrays.
31+
32+
rng = np.random.default_rng(42) # Seed for reproducibility
33+
a = sparse.random((3, 3), density=1 / 6, random_state=rng)
34+
b = sparse.random((3, 3), density=1 / 6, random_state=rng)
35+
36+
# Now let's matrix multiply them.
37+
38+
c = a @ b
39+
40+
# And view the result as a (dense) NumPy array.
41+
42+
c.todense()

0 commit comments

Comments
 (0)