![](https://secure.gravatar.com/avatar/a2c1b891fe9dd5c60430e823bfe8c298.jpg?s=120&d=mm&r=g)
Ralf Gommers wrote:
This sounds quite reasonable to me. The `k=0` keyword is quite badly named, which is my one concern. Especially when tacking it on at the end of a signature with already 3-4 keywords, it's not a good name. How about something like `diag_offset`?
FWIW, we chose `offset` for `array_api_extra.create_diagonal`, instead of inheriting `k` from `np.diag`. `np.diagonal` and `np.linalg.trace` also use `offset`. Given that all of the proposed functions apart from `np.identity` already have "diag" as a substring of their name, I think just `offset` would be fine. What else could `offset` mean in the case of `np.identity`? I suppose there is an argument for actually leaving `np.identity` as is—if someone wants a square off-diagonal matrix of ones, which isn't an identity matrix, their code might be more readable with `np.diag(np.ones(...), k=1)` or just `np.eye` instead, right? Maybe it is weird for "eye" but not "identity" to have this capability, though. Cheers, Lucas