Giter VIP home page Giter VIP logo

Comments (2)

falexwolf avatar falexwolf commented on July 18, 2024

I agree that splats are nicer... and they have been used in Scanpy since the very beginning, e.g. here.

However, both pandas and numpy don't use it in their concat function
(np, pd) and I took these as the model for AnnDatas concat function.

Hence, I'm not sure whether we should deviate from this - I think we should be as close as possible to numpy and pandas whenever it's not completely outrageous.

PS: The Scanpy users are often not very python experienced, and they are used to passing lists without a splat star (*alist) also in many other places, like plotting an AnnData with several colors

sc.pl.scatter(adata, color=['anno1', 'anno2', 'anno3'])

from anndata.

flying-sheep avatar flying-sheep commented on July 18, 2024

i see. that’s unfortunate, since numpy’s API is confusing for newbies as well. the linked question shows why that API violates several parts of the zen of python.

so we’re stuck between a rock and a hard place: be confusing for python beginners or be confusing for numpy-experienced users.

i think that a good error message goes a long way – using splats means the user can’t pass further arguments by position but only by keyword (which is a good thing), and we could provide either a custom error message, or special handling of sequences being passed as only positional argument, like:

def concatenate(*adatas, batch_key='batch', batch_categories=None):
    if len(adatas) == 1 and not isinstance(adatas[0], AnnData):
        try:  # convert iterable into tuple
            adatas = tuple(adatas[0])
        except Exception:
            pass

from anndata.

Related Issues (20)

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.