You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What should we export from where in v0.7? My instinct is that any class a user could come in contact with should be exported at a relatively shallow depth. I'm thinking the main anndata namespace could be a good option.
Advantages:
No reliance on module structure for the rest of the code
I think that any class or function from a private submodule that a user gets in contact with should be exported in the main namespace. I think, .core should be private and hence better named ._core.
We can simply point @davidsebfischer to the fact that anndata.base.Raw will be gone from that location. anndata.base was never meant as a user module, and it should have been prefixed by an underscore anndata._base, but I wasn't that aware of these issues at the time and never renamed it in order to maintain backwards compat. As we're breaking it now, anyway, it would be a good time to also go for ._core.
I agree get the reasoning behind naming it ._core but I'd have to think about why others use .core (xarray, pandas, dask (also has base), and zarr). Possibly due to PEP8 conventions?
I think it's also fair to say undocumented stuff has no guarantees. Raw was documented, so it's reasonable to rely on it. (update: maybe not)
I think that recently, quite a few packages went away from a ton of public modules (like .core), with no real public use, to having dedicated private modules like ._core. I think that in Scanpy, it made a lot of sense. Some while ago, @flying-sheep also shared the API design of a package he liked a lot; and they also went down this road. But I don't remember the name.
So, to answer your question more directly: Maybe they have it for backward compat reasons as well. It just doesn't make sense to have a non-user module in the high-level lookup menus, in my opinion. The lookup should direct the user to the functions and classes he/she needs.
I'll adapt this in any way necessary, just do whatever is best for you! I just needed this for typing. I think it relevant for related packages to distinguish between the full anndata and the raw objects through isinstance() calls though? So exposing the class in some way would be crucial.
This import in batchglm is hidden from the user and I'll switch the scanpy version dependency accordingly once you made this change! So do not worry too much about backwards compatibility for batchglm.
I added a conditional import of this object in v0.6.1, so diffxpy and batchglm can handle both the old and new interface to the location of anndata raw objects now.
We need to decide which of them to export/document and which where we simply want to replace the type hints with some annotation, like LayersBase → MutableMapping[Union[ndarray, csr_matrix]]
I’m thinking that we should export and document them all. Raw is its own beast and should be documented separately from the rest, and we should create a little section introducing all copy-on-write classes.
They all need to be renamed. We don’t want to expose the internals, just the final classes, so ArrayView→COWMatrix, LayersBase→Layers, AxisArraysBase→AlignedMatrices, and PairwiseArraysBase→SquareMatrices or so.
I ran into this issue too when upgrading to the latest anndata. Previously, if someone sends a file with input columns 'tSNE_1' and 'tSNE_2' I'd transform these into a saved analysis like this:
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
Activity
falexwolf commentedon Jul 4, 2019
I think that any class or function from a private submodule that a user gets in contact with should be exported in the main namespace. I think,
.coreshould be private and hence better named._core.We can simply point @davidsebfischer to the fact that
anndata.base.Rawwill be gone from that location.anndata.basewas never meant as a user module, and it should have been prefixed by an underscoreanndata._base, but I wasn't that aware of these issues at the time and never renamed it in order to maintain backwards compat. As we're breaking it now, anyway, it would be a good time to also go for._core.What do you think?
ivirshup commentedon Jul 5, 2019
I agree get the reasoning behind naming it
._corebut I'd have to think about why others use.core(xarray,pandas,dask(also hasbase), andzarr). Possibly due to PEP8 conventions?I think it's also fair to say undocumented stuff has no guarantees.
Rawwas documented, so it's reasonable to rely on it. (update: maybe not)falexwolf commentedon Jul 5, 2019
I think that recently, quite a few packages went away from a ton of public modules (like
.core), with no real public use, to having dedicated private modules like._core. I think that in Scanpy, it made a lot of sense. Some while ago, @flying-sheep also shared the API design of a package he liked a lot; and they also went down this road. But I don't remember the name.falexwolf commentedon Jul 5, 2019
So, to answer your question more directly: Maybe they have it for backward compat reasons as well. It just doesn't make sense to have a non-user module in the high-level lookup menus, in my opinion. The lookup should direct the user to the functions and classes he/she needs.

Export Raw (#177)
davidsebfischer commentedon Jul 8, 2019
I'll adapt this in any way necessary, just do whatever is best for you! I just needed this for typing. I think it relevant for related packages to distinguish between the full anndata and the raw objects through isinstance() calls though? So exposing the class in some way would be crucial.
This import in batchglm is hidden from the user and I'll switch the scanpy version dependency accordingly once you made this change! So do not worry too much about backwards compatibility for batchglm.
adapted to anndata not exporting anndata.base anymore
adapted to anndata not exporting anndata.base anymore
davidsebfischer commentedon Jul 30, 2019
I added a conditional import of this object in v0.6.1, so diffxpy and batchglm can handle both the old and new interface to the location of anndata raw objects now.
flying-sheep commentedon Aug 23, 2019
Currently the classes that appear in function/property type hints are:
anndata.core.anndata.Raw(AnnData.raw)anndata.core.views.ArrayView(AnnData.X)anndata.core.alignedmapping.LayersBase(AnnData.layers)anndata.core.alignedmapping.AxisArraysBase(AnnData.obsm,AnnData.varm)anndata.core.alignedmapping.PairwiseArraysBase(AnnData.obsp,AnnData.varp)We need to decide which of them to export/document and which where we simply want to replace the type hints with some annotation, like
LayersBase→MutableMapping[Union[ndarray, csr_matrix]]I’m thinking that we should export and document them all. Raw is its own beast and should be documented separately from the rest, and we should create a little section introducing all copy-on-write classes.
They all need to be renamed. We don’t want to expose the internals, just the final classes, so
ArrayView→COWMatrix,LayersBase→Layers,AxisArraysBase→AlignedMatrices, andPairwiseArraysBase→SquareMatricesor so.jorvis commentedon Jun 15, 2020
I ran into this issue too when upgrading to the latest anndata. Previously, if someone sends a file with input columns 'tSNE_1' and 'tSNE_2' I'd transform these into a saved analysis like this:
This now fails though because 'base' is no longer public. I'd happily take advice on a cleaner way to do this.
Edit: Well, it looks like it's just far simpler now. Just a simple array().
github-actions commentedon Jul 13, 2023
This issue has been automatically marked as stale because it has not had recent activity.
Please add a comment if you want to keep the issue open. Thank you for your contributions!
flying-sheep commentedon Jul 13, 2023
this is now under control