From e0103959dde4d0753d21edb800ccf95a4ac36392 Mon Sep 17 00:00:00 2001 From: "Nicolas P. Rougier" Date: Thu, 14 Jul 2016 17:47:38 -0500 Subject: [PATCH] Added a pad example --- README.html | 8 +++++++- README.rst | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.html b/README.html index 19ccbc8..0ad54c6 100644 --- a/README.html +++ b/README.html @@ -116,12 +116,18 @@ python -c "import numpy; numpy.info(num print(m) -
  • Create a 2d array with 1 on the border and 0 inside (★☆☆)

    +
  • Create a 2d array with 1 on the border and 0 inside (★☆☆)

     Z = np.ones((10,10))
     Z[1:-1,1:-1] = 0
     
  • +
  • How to add a border (filled with 0's) around an existing array ? (★☆☆)

    +
    +Z = np.ones((5,5))
    +Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
    +
    +
  • What is the result of the following expression? (★☆☆)

     0 * np.nan
    diff --git a/README.rst b/README.rst
    index d5ef71a..9b30529 100644
    --- a/README.rst
    +++ b/README.rst
    @@ -141,14 +141,20 @@ Thanks to Michiaki Ariga, there is now a
           print(m)
     
           
    -#. Create a 2d array with 1 on the border and 0 inside  (★☆☆) 
    +#. Create a 2d array with 1 on the border and 0 inside (★☆☆) 
     
        .. code-block:: python
     
           Z = np.ones((10,10))
           Z[1:-1,1:-1] = 0
     
    -                   
    +#. How to add a border (filled with 0's) around an existing array ? (★☆☆)
    +   
    +   .. code-block:: python
    +
    +      Z = np.ones((5,5))
    +      Z = np.pad(Z, pad_width=1, mode='constant', constant_values=0)
    +
     #. What is the result of the following expression? (★☆☆)
     
        .. code-block:: python