question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

write seems to be broken on master

See original GitHub issue

adata = sc.datasets.pbmc3k() adata.write('test.h5ad') sc.read('test.h5ad') and after trying to read i get

Error --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-11-ea34a1ff06f9> in <module> ----> 1 sc.read('test.h5ad')

~\Apps\Miniconda3\envs\work38\lib\site-packages\scanpy\readwrite.py in read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, **kwargs) 110 filename = Path(filename) # allow passing strings 111 if is_valid_filename(filename): –> 112 return _read( 113 filename, 114 backed=backed,

~\Apps\Miniconda3\envs\work38\lib\site-packages\scanpy\readwrite.py in _read(filename, backed, sheet, ext, delimiter, first_column_names, backup_url, cache, cache_compression, suppress_cache_warning, **kwargs) 711 if ext in {‘h5’, ‘h5ad’}: 712 if sheet is None: –> 713 return read_h5ad(filename, backed=backed) 714 else: 715 logg.debug(f’reading sheet {sheet} from file {filename}')

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\h5ad.py in read_h5ad(filename, backed, as_sparse, as_sparse_fmt, chunk_size) 236 elif k in {“obs”, “var”}: 237 # Backwards compat –> 238 d[k] = read_dataframe(f[k]) 239 else: # Base case 240 d[k] = read_elem(f[k])

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\h5ad.py in read_dataframe(group) 301 return read_dataframe_legacy(group) 302 else: –> 303 return read_elem(group) 304 305

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\specs\registry.py in read_elem(elem, modifiers) 178 def read_elem(elem, modifiers: frozenset(str) = frozenset()): 179 “”“Read an element from an on disk store.”“” –> 180 return _REGISTRY.get_reader(type(elem), get_spec(elem), frozenset(modifiers))(elem) 181 182

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\specs\methods.py in read_dataframe(elem) 520 df = pd.DataFrame( 521 {k: read_elem(elem[k]) for k in columns}, –> 522 index=read_elem(elem[idx_key]), 523 columns=list(columns), 524 )

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\specs\registry.py in read_elem(elem, modifiers) 178 def read_elem(elem, modifiers: frozenset(str) = frozenset()): 179 “”“Read an element from an on disk store.”“” –> 180 return _REGISTRY.get_reader(type(elem), get_spec(elem), frozenset(modifiers))(elem) 181 182

~\Apps\Miniconda3\envs\work38\lib\site-packages\anndata_io\specs\methods.py in read_string_array(d) 323 @_REGISTRY.register_read(H5Array, IOSpec(“string-array”, “0.2.0”)) 324 def read_string_array(d): –> 325 return read_array(d.asstr()) 326 327

AttributeError: ‘Dataset’ object has no attribute ‘asstr’

Versions PIL 8.1.2 absl NA anndata 0.7.7.dev20+g286bc7f autoreload NA backcall 0.2.0 brotli NA cairo 1.20.0 certifi 2021.05.30 cffi 1.14.5 chardet 4.0.0 cloudpickle 1.6.0 colorama 0.4.4 cycler 0.10.0 cython_runtime NA cytoolz 0.11.0 dask 2021.03.0 dateutil 2.8.1 decorator 4.4.2 deprecate 0.3.0 docrep 0.3.2 fsspec 2021.11.0 google NA h5py 2.10.0 idna 2.10 igraph 0.8.3 ipykernel 5.3.4 ipython_genutils 0.2.0 ipywidgets 7.6.3 jedi 0.17.0 joblib 1.0.1 kiwisolver 1.3.1 leidenalg 0.8.3 llvmlite 0.35.0 louvain 0.7.0 matplotlib 3.3.4 mkl 2.3.0 mpl_toolkits NA natsort 7.1.1 nt NA ntsecuritycon NA numba 0.52.0 numexpr 2.7.3 numpy 1.19.2 opt_einsum v3.1.0 packaging 20.9 pandas 1.2.3 parso 0.8.1 pickleshare 0.7.5 pkg_resources NA prompt_toolkit 3.0.8 psutil 5.8.0 pycparser 2.20 pygments 2.8.1 pyparsing 2.4.7 pyro 1.6.0 pythoncom NA pytorch_lightning 1.3.8 pytz 2021.1 pywintypes NA regex 2.5.91 requests 2.25.1 rich NA scanpy 1.8.0.dev65+g0712d9ab scarches 0.4.1 scipy 1.6.1 scvi 0.14.3 seaborn 0.11.1 setuptools_scm NA sinfo 0.3.1 six 1.15.0 sklearn 0.24.1 socks 1.7.1 sphinxcontrib NA statsmodels 0.12.2 storemagic NA tables 3.6.1 tblib 1.7.0 tensorboard 2.4.1 texttable 1.6.3 threadpoolctl 2.1.0 tlz 0.11.0 toolz 0.11.1 torch 1.8.0 torchmetrics 0.6.0 torchvision 0.9.0 tornado 6.1 tqdm 4.59.0 traitlets 5.0.5 typing_extensions NA urllib3 1.26.4 wcwidth 0.2.5 win32api NA win32com NA win32security NA yaml 5.4.1 zmq 20.0.0 zope NA ----- IPython 7.21.0 jupyter_client 6.1.7 jupyter_core 4.7.1 notebook 6.2.0 ----- Python 3.8.8 (default, Feb 24 2021, 15:54:32) [MSC v.1928 64 bit (AMD64)] Windows-10-10.0.19041-SP0 8 logical CPU cores, Intel64 Family 6 Model 142 Stepping 12, GenuineIntel

Reading adata files written with older versions is fine. I am on 0.8.0.dev0 now and it is fine.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ivirshupcommented, Jan 20, 2022

Thanks for catching!

I’m 95% sure this is due to h5py 2.

0reactions
ivirshupcommented, Jan 24, 2022

I’m tentatively dropping h5py 2 for the release.

If there are many complaints, I’ll undo it, but it’s been a while and is a continuous source of pain.

Read more comments on GitHub >

github_iconTop Results From Across the Web

write seems to be broken on master · Issue #691
Reading adata files written with older versions is fine. I am on 0.8.0.dev0 now and it is fine.
Read more >
How to fix committing to the wrong Git branch?
If you forgot to create a new branch before committing and committed all on master, no matter how many commits you did, the...
Read more >
Why Most Writing Rules Can Be Broken
Almost every writing rule you can think of has exceptions. Why? And if breaking writing rules is possible, why pay any attention to...
Read more >
Dr. Jekyll and Mr. Hyde
Then, back in the kitchen, he asks Utterson, "Was that my master's voice?" Utterson grows pale. "It seems much changed," he says, trying...
Read more >
Show, Don't Tell: Tips and Examples of The Golden Rule
Show, don't tell is a writing technique in which story and characters are related through sensory details and actions rather than exposition ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found