TypeError: unsupported operand type(s) for &: 'float' and 'float', but I have no &

Srivatsan

Here is part of my code:

import numpy as np
import pyfits 
from astropy.io import ascii

def create_randoms(min_z,max_z,min_mass):

        Do some calculations and use it to 
        write into a file 


        if (max_z == 1.0 and min_mass == 1e13):
                ascii.write(data_1, '/home/Documents/0.0_zphot_1.0.dat', Writer=ascii.FixedWidthNoHeader, delimiter=None)

Exactly in the if statement, I get the error:

TypeError: unsupported operand type(s) for &: 'float' and 'float'

I call the function by:

create_randoms(0.0,1.0,1e13)

I don't know why it doesn't seem to like the values 1.0 and 1e13. I am not using the bitwise & here, and instead I am correctly using the logical operator and. But still it is throwing me with the error.

Full error traceback:

TypeError                                 Traceback (most recent call last)
<ipython-input-83-d5f507b12cc0> in <module>()
----> 1 create_randoms(0.0,1.0,1e13,0,0,1,0,0,0,0,1)

/home/ssridhar/Documents/PhD_materials/Python/correlation_func/100_Hband_halos/jackknife_random_creation.py in create_randoms(min_z, max_z, min_mass, r1, r2, r3, r4, d1, d2, d3, d4)
    119         """ WRITING FILES ACCORDINGLY """
    120 
--> 121         if (max_z == '1.0' and min_mass == '1e13'):
    122                 ascii.write(data_1, '/home/ssridhar/Documents/PhD_materials/2pt_correlation_master_2/Input/100_Hband_halos/jackknife/M200>1e13/K1_100sq_M200>1e13_xyz_0.0<zphot0.001<1.0.dat', Writer=ascii.FixedWidthNoHeader, delimiter=None)
    123 

TypeError: unsupported operand type(s) for &: 'float' and 'float'
Martijn Pieters

Python compiles your code to bytecode, then runs that. But bytecode doesn't make for a readable error message. When an error occurs, Python loads the original source code from disk to show what lines are causing the error.

So when you edit your code, but don't reload the bytecode in Python or restart the Python interpreter, your error messages will by out of sync. Old code with the problem is run, but the traceback shows the new code.

In ipython, reload the code, or to be 100% sure, restart the interpreter.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

unsupported operand types for * : 'float' and 'decimal'

From Dev

TypeError: unsupported operand type(s) for +: 'float' and 'tuple'

From Dev

TypeError: unsupported operand type(s) for +: 'decimal' and 'float'

From Dev

TypeError: unsupported operand type(s) for -: 'float' and 'method'

From Dev

TypeError: unsupported operand type(s) for /: 'float' and 'instancemethod'

From Dev

TypeError: unsupported operand type(s) for -: 'instance' and 'float'

From Dev

TypeError: unsupported operand type(s) for <<: 'int' and 'float'

From Dev

TypeError: unsupported operand type(s) for +: 'Timestamp' and 'float'

From Dev

TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

From Dev

Python TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

From Dev

Python TypeError: unsupported operand type(s) for ^: 'float' and 'int'

From Dev

TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType' in Python 3

From Dev

Two floats throw TypeError: unsupported operand type(s) for +: 'float' and 'str'

From Dev

TypeError: Can't convert 'float' object to str implicitly or TypeError: unsupported operand type(s) for -: 'str' and 'float'

From Dev

TypeError: unsupported operand type(s) for ^: 'numpy.float64' and 'numpy.float64'

From Dev

Unsupported operand type(s) for +: 'float' and 'str' error

From Dev

Python: unsupported operand type(s) for /: 'tuple' and 'float'

From Dev

numpy.polyfit shows TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'float'

From Java

TypeError: bad operand type for unary ~: float

From Dev

TypeError: bad operand type for unary ~: float

From Dev

matplotlib candlestick chart error xy = (t-OFFSET, lower), TypeError: unsupported operand type(s) for -: 'datetime.date' and 'float'

From Dev

What does "unsupported operand type(s) for /: 'float' and 'list'" means?

From Dev

Python error: unsupported operand type(s) for -: 'float' and 'NoneType'

From Dev

Python 3: unsupported operand type(s) for /: 'float' and 'bytes'

From Dev

Barplot returns unsupported operand type(s) for -: 'str' and 'float'

From Dev

Unsupported operand types 'NoneType'

From Dev

Django unsupported operand types

From Dev

I keep getting a " TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType' "

From Dev

unsupported operand types for //: 'str', 'int'

Related Related

  1. 1

    unsupported operand types for * : 'float' and 'decimal'

  2. 2

    TypeError: unsupported operand type(s) for +: 'float' and 'tuple'

  3. 3

    TypeError: unsupported operand type(s) for +: 'decimal' and 'float'

  4. 4

    TypeError: unsupported operand type(s) for -: 'float' and 'method'

  5. 5

    TypeError: unsupported operand type(s) for /: 'float' and 'instancemethod'

  6. 6

    TypeError: unsupported operand type(s) for -: 'instance' and 'float'

  7. 7

    TypeError: unsupported operand type(s) for <<: 'int' and 'float'

  8. 8

    TypeError: unsupported operand type(s) for +: 'Timestamp' and 'float'

  9. 9

    TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

  10. 10

    Python TypeError: unsupported operand type(s) for /: 'NoneType' and 'float'

  11. 11

    Python TypeError: unsupported operand type(s) for ^: 'float' and 'int'

  12. 12

    TypeError: unsupported operand type(s) for +=: 'float' and 'NoneType' in Python 3

  13. 13

    Two floats throw TypeError: unsupported operand type(s) for +: 'float' and 'str'

  14. 14

    TypeError: Can't convert 'float' object to str implicitly or TypeError: unsupported operand type(s) for -: 'str' and 'float'

  15. 15

    TypeError: unsupported operand type(s) for ^: 'numpy.float64' and 'numpy.float64'

  16. 16

    Unsupported operand type(s) for +: 'float' and 'str' error

  17. 17

    Python: unsupported operand type(s) for /: 'tuple' and 'float'

  18. 18

    numpy.polyfit shows TypeError: unsupported operand type(s) for +: 'numpy.ndarray' and 'float'

  19. 19

    TypeError: bad operand type for unary ~: float

  20. 20

    TypeError: bad operand type for unary ~: float

  21. 21

    matplotlib candlestick chart error xy = (t-OFFSET, lower), TypeError: unsupported operand type(s) for -: 'datetime.date' and 'float'

  22. 22

    What does "unsupported operand type(s) for /: 'float' and 'list'" means?

  23. 23

    Python error: unsupported operand type(s) for -: 'float' and 'NoneType'

  24. 24

    Python 3: unsupported operand type(s) for /: 'float' and 'bytes'

  25. 25

    Barplot returns unsupported operand type(s) for -: 'str' and 'float'

  26. 26

    Unsupported operand types 'NoneType'

  27. 27

    Django unsupported operand types

  28. 28

    I keep getting a " TypeError: unsupported operand type(s) for -: 'NoneType' and 'NoneType' "

  29. 29

    unsupported operand types for //: 'str', 'int'

HotTag

Archive