Comments (12)
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.
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.
@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.
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.
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.
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.
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.
I'm strongly 👍.
from pytensor.
@jessegrabowski can you expand on what the api
module does? I am not familiar with it
from pytensor.
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.
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.
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)
- ENH: Detect clang++ as a g++ alternative on Linux HOT 2
- Don't run mypy in pre-commit HOT 2
- BUG: <```uint64 dtype``` is broken for ```Max```> HOT 3
- Handle more AdvancedSetSubtensor ops in numba HOT 1
- Update xfail reason "Omnistaging can't be disabled" in JAX tests
- Missed scan rewrites
- CI is randomly skipping some jobs
- Add graph transformation to propagate new static shape info
- Error with Slogdet returning floats instead of arrays
- Consider using pr-labeler-action HOT 7
- Test issue
- Another test issue
- Get rid of pre-defined inplace Elemwise Operators?
- numba: Incorrect gradient and typing error
- Default typify in JITLinkers expects tensors/arrays, why?
- Torch: Investigate if `set_default_device/with_device` is a deal-breaker HOT 1
- Implement all Ops in PyTorch (help welcome!) HOT 29
- Update APIs to be compatible with NumPy 2.0 or pin NumPy to latest 1.x version HOT 1
- `tensor.where` does not behave like `np.where` when only one input (condition) is passed
- Default MvNormal covariance doesn't make sense HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytensor.