ColumbiaCMB / kid_readout

Code for the ROACH KID readout.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

float(0.0) being translated to False in state dict in io.nc

gitj opened this issue · comments

commented

@danielflanigan
I set up a state dict like this:
state = dict(hittite_power_dBm=0.0, mmw_atten_turns = (7,7))
but when I read it back from /data/readout/2016-04-11_000046_lo_1110.0.nc I get:
{u'hittite_power_dBm': False, u'mmw_atten_turns': [7, 7]}

This bug was caused by 0 being incorrectly recognized as a boolean. It affected all attributes and dictionary values x such that x == False or x == True evaluated to True. That is, 0, 0., 0 + 0j etc., or 1, 1., 1 + 0j etc.

I expanded the test code to ensure that these values are written and read properly in the future.