title: Fill diagonal and anti-diagonal offsetted by row, column indices in array - NumPy / Python
body: <p>I have an n by n matrix. Given a position, I would like to replace the diagonals of that position with a specific value.</p>
  
  <p>I tried using <code>np.fill_diagonal</code> but I don't get the correct result.</p>
  
  <pre><code>import numpy as np
  
  n = 8
  available = np.array([["O" for _ in range(n)] for _ in range(n)])
  
  def update_available(column, row):
      available[column][row] = "X"
      np.fill_diagonal(available[column-row:],"X")
      np.fill_diagonal(available[::-1,:][column-row-1:],"X")
  
  </code></pre>
  
  <p>For <code>update_available(4,1)</code> I want to get the following output:   </p>
  
  <pre><code>   0  1  2  3  4  5  6  7
  0  O  O  O  O  O  X  O  O
  1  O  O  O  O  X  O  O  O
  2  O  O  O  X  O  O  O  O
  3  X  O  X  O  O  O  O  O
  4  O  X  O  O  O  O  O  O
  5  X  O  X  O  O  O  O  O
  6  O  O  O  X  O  O  O  O
  7  O  O  O  O  X  O  O  O
  </code></pre>