question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement `np.ascontiguousarray` for Numba scalars

See original GitHub issue

The conversion for np.ascontiguousarray doesn’t appear to handle scalar inputs:

import numpy as np
import numba as nb


@nb.njit
def test_fn(x):
    return np.ascontiguousarray(x)


test_fn(1)
# ...
# TypingError: Failed in nopython mode pipeline (step: nopython frontend)
# No implementation of function Function(<function ascontiguousarray at 0x7fdd294aab00>) found for signature:
#
#  >>> ascontiguousarray(int64)


np.ascontiguousarray(1)
# array([1])

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
JohamyBcommented, Oct 4, 2021

Hi @gmarkall , I’m new here and want to take this one as my first issue?

0reactions
esccommented, Mar 30, 2022

Hello ! Shouldn’t this issue be closed since #7700 was merged?

Indeed, thank you for the ping!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported NumPy features - Numba
Numpy arrays of any of the scalar types above are supported, regardless of the shape or layout. Array access¶. Arrays support normal iteration....
Read more >
numpy.ascontiguousarray() in Python - GeeksforGeeks
numpy.ascontiguousarray() function is used when we want to return a contiguous ... This includes scalars, lists, lists of tuples, tuples, ...
Read more >
Creating arrays on the GPU with numba in python using Cuda
So it's possible to create a vectorize ufunc that works on an array and a scalar, for example. That means each worker will...
Read more >
Only size-1 arrays can be converted to Python scalars
This error occurs most often when you attempt to use np.int() to convert a NumPy array of float values to an array of...
Read more >
numpy.array — NumPy v1.24 Manual
If object is a scalar, a 0-dimensional array containing object is returned. ... Specifies the minimum number of dimensions that the resulting array...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found