Git Product home page Git Product logo

Comments (4)

danielballan avatar danielballan commented on June 29, 2024 1

I'm late to the party here, just noticed this. The way to handle array creation is use np.*_like functions, as in

numpy.empty_like(some_input_whose_type_will_be_imitated, dtype=..., shape=...)

In the past, the *_like functions did not allow users to customize the shape because the whole point was to return array of the same shape. Now, they may be used to return an array of the same type but, optionally, a different shape or internal dtype. This was a added in a recent release of numpy; the PR to add it to dask is not yet merged as of this writing: dask/dask#6064

from autocorr.

tacaswell avatar tacaswell commented on June 29, 2024

can we walk back up the class / module tree of the input to sort out what version of empty to call?

from autocorr.

leofang avatar leofang commented on June 29, 2024

Looks like we need to rely on __module__? Not really a fan of it...

>>> import inspect
>>>
>>> import cupy as cp
>>> a = cp.empty(10)
>>> type(a).__module__
'cupy.core.core'
>>> inspect.getmodule(a) is None  # useless
True
>>>
>>> import numpy as np
>>> b = np.empty(10)
>>> type(b).__module__
'numpy'
>>> inspect.getmodule(b) is None  # useless
True

from autocorr.

leofang avatar leofang commented on June 29, 2024

For CuPy's uninformative __module__, just raised an issue: cupy/cupy#3266. Not sure whether other libraries are compliant on this aspect or not.

from autocorr.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.