GithubHelp home page GithubHelp logo

Comments (12)

maresb avatar maresb commented on September 22, 2024 3

Just to brainstorm likely-bad ideas, I wonder if it would make sense to flip the statsmodels pattern upside down. Make the top-level pytensor namespace the user API. Then in order to ensure separation between the user API and the development library, we could move the actual code into pytensor.lib. That way we ensure no name conflicts, and the user can tab-complete all user API names.

from pytensor.

maresb avatar maresb commented on September 22, 2024 2

Importing from source is fine for dev work but not user work, such as Jupyter notebook workflows.

Ya, that's actually a really good argument. I've been doing too much library dev work. Now I'm weakly 👍.

It still would be nice to get rid of the * imports.

from pytensor.

ricardoV94 avatar ricardoV94 commented on September 22, 2024 2

@Dhruvanshu-Joshi we should probably hold on until the next major release, perhaps when we drop the C code or make numba the default we can go ahead and also do this major change

from pytensor.

ricardoV94 avatar ricardoV94 commented on September 22, 2024 1

The counter proposal doesn't make sense to me.

Are you suggesting one to do from pytensor.tensor.math/basic/elemwise import add, dot, cos, zeros...?

from pytensor.

jessegrabowski avatar jessegrabowski commented on September 22, 2024 1

I like both the proposal and the counter-proposal.

While I don't love it, I'll also throw into the mix the import statsmodels.api as sm pattern. They provide the api module as a way to organize and present all the user-facing stuff in a clean way, while still letting them organize the rest of the package in a dev friendly way.

from pytensor.

maresb avatar maresb commented on September 22, 2024

I'm weakly 👎.

I don't see any technical obstacles. But is there any benefit beyond saving users a few keystrokes?

This would introduce yet another layer of indirection. It's already pretty tricky to find the definitions of stuff. Like to find the definition of pt.dscalar I have to To look in __init__.py, and then I search for dscalar and there's no result, because it's actually pulled in implicitly pytensor.tensor.type import *. There are lots of other import * statements, so the only way I could find out which one was with a raw text search.

With various linters and type checkers I've gotten into the habit of always importing things directly from their definition, and so my personal feeling is that these types of shortcuts cost me way more time than they save.

TLDR: keystrokes are cheap, directness and clarity are priceless

Counterproposal: eliminate *-imports from the codebase.

from pytensor.

ricardoV94 avatar ricardoV94 commented on September 22, 2024

Writing pytensor.tensor is a PITA (what else would I want to use from a library with tensor in the name?), only surpassed by matplotlib.pyplot. And I have to write both everytime.

Importing from source is fine for dev work but not user work, such as Jupyter notebook workflows.

Why should the main functionality of a package require a double level import? I can't believe this would be suggested if we were writing this library from scratch.

from pytensor.

twiecki avatar twiecki commented on September 22, 2024

I'm strongly 👍.

from pytensor.

ricardoV94 avatar ricardoV94 commented on September 22, 2024

@jessegrabowski can you expand on what the api module does? I am not familiar with it

from pytensor.

jessegrabowski avatar jessegrabowski commented on September 22, 2024

It's just a script that imports from around their modules in a user-facing way.

The consequence is that you have to do import statsmodels.api as sm, but the benefit is they can organize the package in a way that makes sense for the dev team, then present it to users in a way that makes sense to them.

from pytensor.

twiecki avatar twiecki commented on September 22, 2024

FWIW I always found statsmodels' import structure pretty odd and besides matplotlib I don't know another library that does it that way.

from pytensor.

Dhruvanshu-Joshi avatar Dhruvanshu-Joshi commented on September 22, 2024

So if I correctly understand, we want to include all the pytensor.tensor functionalities in the user api right?
Easiest way I can see is to include all the imports in pytensor.tensor.__init__ in the pytensor.__init__.
Is this the what we want through this discussion?
Haven't dug into this yet but I feel * imports will come handy here. So do we want to include this as we are doing or handpick the individual imports and in other PR/issue, replace all the uses of * in the current version with the functionalities that is being used in that script?

from pytensor.

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.