Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create record array #5245

Open
2 tasks done
TomGoBravo opened this issue Feb 13, 2020 · 1 comment
Open
2 tasks done

Unable to create record array #5245

TomGoBravo opened this issue Feb 13, 2020 · 1 comment
Labels
bug - failure to compile Bugs: failed to compile valid code

Comments

@TomGoBravo
Copy link

Reporting a bug

I'm trying to use numba to run a function that updates a numpy array of records.

Here's a snippet from a complete running example at https://repl.it/@TomGoBravo/numba-create-record

rec_dtype = np.dtype([('a', 'int32'), ('b', 'float64')])
rec = from_dtype(rec_dtype)

# With njit commented out this code runs without error.
# With njit enabled np.array fails to compile and raises
# Cannot cast int32 to Record(a[type=int32;offset=0],b[type=float64;offset=4];12;False): %".88"
@njit # (rec[:](numba.int32, numba.float64))
def make_record(a_val, b_val):
  return np.array((a_val, b_val), dtype=rec_dtype)

From https://gitter.im/numba/numba?at=5e4517b2cd2d737bb0758426

the lowering fail is because the array ctor code expects each tuple element to correspond to the dtype of the array, so it's trying to shove an int32 into a slot of the dtype type.

@stuartarchibald
Copy link
Contributor

Thanks for the report, I can reproduce. Cause diagnosed on gitter link above.

@stuartarchibald stuartarchibald added bug - failure to compile Bugs: failed to compile valid code and removed bug labels Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug - failure to compile Bugs: failed to compile valid code
Projects
None yet
Development

No branches or pull requests

2 participants