Search code examples
pythonbitwise-operatorsbitwise-and

Python: SyntaxError using bitwise function


I am trying to create a basic bitwise function that filters out a certain subset of my data for me.

>>>heads=fits.open('datafile.fits')
>>>data=heads[1].data

Now, I need to mask out data points that are in a certain column and which are set to bit 0.

>>>ind=np.where(data['COLUMN_NAME'] & np.power(2,9) = 0)

However, this input throws the error

File "<stdin>", line 1
SyntaxError: keyword cant be an expression

The error does not give the normal ^ which shows where the error is, so I'm not sure which part of my input python is having an issue with.


Solution

  • equal comparsion is ==:

    ind=np.where(data['COLUMN_NAME'] & (2**9) == 0)