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.

TypeError: ‘float’ object does not support item assignment

See original GitHub issue
  • MNE-Python version: 0.22.0
  • operating system: Windows & Mac

Describe the bug

TypeError: ‘float’ object does not support item assignment

I was trying to read in a hypnogram edf file using python. The data is directly from PhysioNet For example, when I tried to process this file using my code below, it threw an error.

Steps to reproduce

import mne

data = mne.io.read_raw_edf("SC4001EC-Hypnogram.edf")

ERROR results

Extracting EDF parameters from C:\Users\yxie\Desktop\healthcare\SC4001EC-Hypnogram.edf...
EDF file detected
Traceback (most recent call last):

  File "<ipython-input-77-d358ed2921e8>", line 4, in <module>
    data = mne.io.read_raw_edf(localpath)

  File "C:\Users\yxie\Anaconda3\lib\site-packages\mne\io\edf\edf.py", line 1217, in read_raw_edf
    return RawEDF(input_fname=input_fname, eog=eog, misc=misc,

  File "<decorator-gen-182>", line 24, in __init__

  File "C:\Users\yxie\Anaconda3\lib\site-packages\mne\io\edf\edf.py", line 114, in __init__
    info, edf_info, orig_units = _get_info(input_fname,

  File "C:\Users\yxie\Anaconda3\lib\site-packages\mne\io\edf\edf.py", line 358, in _get_info
    edf_info, orig_units = _read_header(fname, exclude)

  File "C:\Users\yxie\Anaconda3\lib\site-packages\mne\io\edf\edf.py", line 345, in _read_header
    return _read_edf_header(fname, exclude)

  File "C:\Users\yxie\Anaconda3\lib\site-packages\mne\io\edf\edf.py", line 598, in _read_edf_header
    record_length = record_length[0] = 1.

TypeError: 'float' object does not support item assignment

Additional information

Note: I’m only showing my Windows setup here. But it also failed on my Mac.

Platform: Windows-10-10.0.18362-SP0 Python: 3.8.3 (default, Jul 2 2020, 17:30:36) [MSC v.1916 64 bit (AMD64)] Executable: C:\Users\yxie\Anaconda3\python.exe CPU: Intel64 Family 6 Model 158 Stepping 13, GenuineIntel: 12 cores Memory: 15.8 GB

mne: 0.22.0 numpy: 1.19.5 {blas=D:\a\1\s\numpy\build\openblas_info, lapack=D:\a\1\s\numpy\build\openblas_lapack_info} scipy: 1.5.0 matplotlib: 3.2.2 {backend=module://ipykernel.pylab.backend_inline}

sklearn: 0.23.2 numba: 0.50.1 nibabel: Not found nilearn: Not found dipy: Not found cupy: Not found pandas: 1.2.2 mayavi: Not found pyvista: Not found vtk: Not found

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
agramfortcommented, Apr 11, 2021

Nice, thanks @agramfort https://github.com/agramfort, this works! What do you mean by “point to this”? When reading such a file with read_raw_edf, what should happen? Just issue a more informative error?

I mean raise an exception with a meaningful error message saying to use read_annotations

0reactions
cbrnrcommented, Apr 11, 2021

Nice, thanks @agramfort, this works! What do you mean by “point to this”? When reading such a file with read_raw_edf, what should happen? Just issue a more informative error?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: 'float' object does not support item assignment
The Python "TypeError: 'float' object does not support item assignment" occurs when we try to assign a value to a float using square...
Read more >
TypeError: 'float' object does not support item assignment
The python error TypeError: 'float' object does not support item assignment occurs when a value is inserted or changed in a float variable...
Read more >
python - Error: 'float' object does not support item assignment
This last line gives me an error that says: float object does not support item assigment. I don't understand how y2 can be...
Read more >
'numpy.float64' object does not support item assignment
This error usually occurs when you attempt to use brackets to assign a new value to a NumPy variable that has a type...
Read more >
TypeError: 'float' object does not support item assignment
TypeError : 'float' object does not support item assignment · Output · How to reproduce this error · Solution 1 · Solution 2...
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