Skip to content

Commit 05a3aa0

Browse files
authored
Apply suggestions from code review
Co-authored-by: Athan <kgryte@gmail.com>
1 parent e382094 commit 05a3aa0

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

spec/draft/tutorial_basic.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
# Array API Tutorial
44

5-
In this tutorial we're going to show the migration from the array consumer
5+
In this tutorial, we're going to demonstrate how to migrate to the Array API from the array consumer's
66
point of view for a simple graph algorithm.
77

8-
The example presented here comes from [`graphblas-algorithms`](https://github.com/python-graphblas/graphblas-algorithms).
9-
library. There we can find [the HITS algorithm](https://github.com/python-graphblas/graphblas-algorithms/blob/35dbc90e808c6bf51b63d51d8a63f59238c02975/graphblas_algorithms/algorithms/link_analysis/hits_alg.py#L9),
10-
used for the link analysis for estimating prominence in sparse networks.
8+
The example presented here comes from the [`graphblas-algorithms`](https://github.com/python-graphblas/graphblas-algorithms).
9+
library. In particular, we'll be migrating [the HITS algorithm](https://github.com/python-graphblas/graphblas-algorithms/blob/35dbc90e808c6bf51b63d51d8a63f59238c02975/graphblas_algorithms/algorithms/link_analysis/hits_alg.py#L9), which is
10+
used for the link analysis for estimating prominence in sparse networks, to be Array API compliant.
1111

1212
The inlined and slightly simplified (without "authority" feature)
13-
implementation looks like this:
13+
implementation looks similar to the following:
1414

1515
```python
1616
def hits(G, max_iter=100, tol=1.0e-8, normalized=True):
@@ -42,18 +42,18 @@ def is_converged(xprev, x, tol):
4242
```
4343

4444
We can see that the API is specific to the GraphBLAS array object.
45-
There is `Vector` constructor, overloaded `<<` for assigning new values,
45+
There is a `Vector` constructor, overloaded `<<` for assigning new values,
4646
and `reduce`/`get` for reductions. We need to replace them, and, by convention,
4747
we will use `xp` namespace for calling respective functions.
4848

49-
First we want to make sure we construct arrays in an agnostic way:
49+
First, we want to make sure we construct arrays in an agnostic way:
5050

5151
```python
5252
h = xp.full(N, 1.0 / N)
5353
A = xp.asarray(G.A)
5454
```
5555

56-
Then, instead of `reduce` calls we use appropriate reducing
56+
Then, instead of `reduce` calls, we will use appropriate reduction
5757
functions from the Array API:
5858

5959
```python
@@ -65,13 +65,13 @@ a = a / xp.sum(xp.abs(a))
6565
err = xp.sum(xp.abs(...))
6666
```
6767

68-
We replace custom binary operation with the Array API counterpart:
68+
We replace the custom binary operation with the Array API counterpart:
6969

7070
```python
7171
...(x - xprev)
7272
```
7373

74-
And last but not least, let's ensure that the result of the convergence
74+
And finally, let's ensure that the result of the convergence
7575
condition is a scalar coming from our API:
7676

7777
```python
@@ -106,9 +106,9 @@ def is_converged(xprev, x, N, tol):
106106
return err < xp.asarray(N * tol)
107107
```
108108

109-
At this point the actual execution depends only on `xp` namespace,
110-
and replacing that one variable allow us to switch from e.g. NumPy arrays
111-
to a JAX execution on a GPU. This lets us be more flexible, and, for example,
109+
At this point, the actual execution depends only on `xp` namespace,
110+
and replacing that one variable will allow us to switch from, e.g., NumPy arrays on the CPU
111+
to JAX arrays for running on a GPU. This lets us be more flexible, and, for example,
112112
use lazy evaluation and JIT compile a loop body with JAX's JIT compilation:
113113

114114
```python

0 commit comments

Comments
 (0)