llnl / llnl/LEAP

load_tif_python ignores a provided array and crashes when called without one

Open Beginner friendly
#213 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Cuda
Stars
249
Forks
37
PR merge metrics
No merged PRs in 30d

Description

Hi, I've been reading through the Python fallback readers in
leapctype.py and noticed something in load_tif_python that looks
like a typo:

if x is not None:
x = np.zeros((numRows, numCols), dtype=np.float32)
elif x.shape[0] != numRows or x.shape[1] != numCols:
return None

If you pass an array in `x` it gets silently overwritten with a
fresh zero array, and if you don't pass one it crashes on
`x.shape` since x is None. Should be `if x is None:` so the shape
check applies to a passed-in array. The other readers in the file
(load_data for example) use the is None pattern, so this one just
looks inverted. Happy to open a PR if that'd help.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in leapctype.py at the load_tif_python entry point and compare its handling of x with the load_data reader mentioned in the issue. Verify that both calls with a supplied array and calls without one complete correctly, while preserving the shape check for supplied arrays.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
88/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.