Home > database >  pass multi dimensional range as parameter python
pass multi dimensional range as parameter python

Time:04-29

I am using python and munpy. I have 2 dimesional object mask. It is graphic mak with integer coordinates and value.I want to use part of matrix like:

mask[:100,300:]

Is it possible to create variable like range = (:100,300:) and to use like:

mask[range]

or similar approach

CodePudding user response:

You can use the built-in slice

ranges = slice(0, 100), slice(300, None)
mask[ranges]
  • Related