0

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

1
  • 1
    range = ":100,300:" and then mask[eval(range)] could do it. Commented Apr 28, 2022 at 10:34

1 Answer 1

2

You can use the built-in slice

ranges = slice(0, 100), slice(300, None)
mask[ranges]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.