diff --git a/Python/Module3_IntroducingNumpy/AdvancedIndexing.md b/Python/Module3_IntroducingNumpy/AdvancedIndexing.md index 769b5373..a6ef69fd 100644 --- a/Python/Module3_IntroducingNumpy/AdvancedIndexing.md +++ b/Python/Module3_IntroducingNumpy/AdvancedIndexing.md @@ -695,6 +695,13 @@ This will return a tuple of two integer-valued index-arrays. These contain the i ... [ 0.84, 0.76, 0.25, 0.07]]) >>> x[np.arange(4), np.arange(4)] = range(4) +# equivalent (works for the general case of a square matrix of N-dims) +# x[tuple(np.arange(x) for x in x.shape)] = range(x.shape[0]) + +# equivalent (using numpy built-in functions): +# x[np.diag_indices_from(x)] = np.arange(4) +# np.fill_diagonal(x, np.arange(4)) + >>> x[0.8 < x] += 1 >>> x array([[ 0. , 0.05, 1.84, 0.21], diff --git a/Python/Module4_OOP/Methods.md b/Python/Module4_OOP/Methods.md index 92d9723a..6bf8e4fc 100644 --- a/Python/Module4_OOP/Methods.md +++ b/Python/Module4_OOP/Methods.md @@ -200,7 +200,7 @@ __main__.Dummy `dict.fromkeys` is an example of a class method that takes in an iterable, and returns a dictionary whose keys are the elements of that iterable, and whose values all default to `None`. ```python ->>> dict.fromkeys("abcd") +>>> dict.fromkeys("abcd", 2.3) {'a': 2.3, 'b': 2.3, 'c': 2.3, 'd': 2.3} ``` diff --git a/README.md b/README.md index f1170581..d1929075 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Once this environment is created activate it. You may need to manually install a ```shell pip install sphinx-rtd-theme==0.4.3 -pip install jupytext-1.3.0rc1 +pip install jupytext==1.4.2 ``` and install the `plymi` code base from this repo. Clone the present repository and run: