Changeset 109afbd in sasview for src/sas/sascalc


Ignore:
Timestamp:
Nov 30, 2018 12:35:08 PM (6 years ago)
Author:
Jeff Krzywon <jkrzywon@…>
Branches:
master, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249
Children:
d96744de
Parents:
c7c8143
Message:

Prevent ValueErrors?

Location:
src/sas/sascalc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/cansas_reader_HDF5.py

    rc7c8143 r109afbd  
    573573                                             * dataset.qx_data 
    574574                                             + dataset.qy_data 
    575                                              * dataset.qy_data) 
     575                                             * dataset.qy_data).flatten() 
    576576            except: 
    577577                dataset.q_data = None 
  • src/sas/sascalc/file_converter/nxcansas_writer.py

    rc7c8143 r109afbd  
    328328        (n_rows, n_cols) = (len(data.y_bins), len(data.x_bins)) 
    329329 
    330         if ((n_rows == 0 and n_cols == 0) 
    331                 or (n_cols*n_rows != len(data.data.flatten()))): 
     330        if (n_rows == 0 and n_cols == 0) or (n_cols*n_rows != data.data.size): 
    332331            # Calculate rows and columns, assuming detector is square 
    333332            # Same logic as used in PlotPanel.py _get_bins 
     
    348347        qy_entry = data_entry.create_dataset('Qy', data=qy) 
    349348        qy_entry.attrs['units'] = data.Q_unit 
    350         if data.err_data is not None and not all(data.err_data == [None]): 
     349        if (data.err_data is not None 
     350                and not all(v is None for v in data.err_data)): 
    351351            d_i = np.reshape(data.err_data, (n_rows, n_cols)) 
    352352            i_entry.attrs['uncertainties'] = 'Idev' 
    353353            i_dev_entry = data_entry.create_dataset('Idev', data=d_i) 
    354354            i_dev_entry.attrs['units'] = data.I_unit 
    355         if data.dqx_data is not None and not all(data.dqx_data == [None]): 
     355        if (data.dqx_data is not None 
     356                and not all(v is None for v in data.dqx_data)): 
    356357            qx_entry.attrs['resolutions'] = 'dQx' 
    357358            dqx_entry = data_entry.create_dataset('dQx', data=data.dqx_data) 
    358359            dqx_entry.attrs['units'] = data.Q_unit 
    359         if data.dqy_data is not None and not all(data.dqy_data == [None]): 
     360        if (data.dqy_data is not None 
     361                and not all(v is None for v in data.dqy_data)): 
    360362            qy_entry.attrs['resolutions'] = 'dQy' 
    361363            dqy_entry = data_entry.create_dataset('dQy', data=data.dqy_data) 
    362364            dqy_entry.attrs['units'] = data.Q_unit 
    363         if data.mask is not None and not all(data.mask == [None]): 
     365        if data.mask is not None and not all(v is None for v in data.mask): 
    364366            data_entry.attrs['mask'] = "mask" 
    365367            mask = np.invert(np.asarray(data.mask, dtype=bool)) 
Note: See TracChangeset for help on using the changeset viewer.