self.assertEqual(result_R.shape,image_dims,"not the correct dimensions")
result_R=result_R.reshape(-1)
result_RW=result_RW.reshape(-1)
val=val.reshape(-1)
else:
# if the test isn't scalar/spectrum or image its wrong
self.assertEqual(1,2," {} is not a valid test_type. please use either scalar, spectrum or image".format(test_type))
iftest_type=="scalar":
comparison=result_RW==val
self.assertTrue(comparison," Value could not be handled by the atrribute_wrappers internal RW storer. attempted to write: {}".format(val))
comparison=result_R==val
self.assertTrue(comparison," value in the clients R attribute not equal to what was written. read: {}, wrote {}".format(result_R,val))
elifdtype!=str:
comparison=result_RW==val
equal_arrays=comparison.all()
self.assertTrue(equal_arrays," Value could not be handled by the atrribute_wrappers internal RW storer. attempted to write: {}".format(val))
comparison=result_R==val
equal_arrays=comparison.all()
self.assertTrue(equal_arrays," value in the clients R attribute not equal to what was written. read: {}, wrote {}".format(result_R,val))
else:
iftest_type=="image":
self.assertEqual(len(result_RW)*len(result_RW[0]),6,"array dimensions do not match the expected dimensions. expected {}, got: {}".format(val,len(result_RW)*len(result_RW[0])))
self.assertEqual(len(result_RW)*len(result_RW[0]),6,"array dimensions do not match the expected dimensions. expected {}, got: {}".format(val,len(result_R)*len([0])))
else:
self.assertEqual(len(result_RW),4,"array dimensions do not match the expected dimensions. expected {}, got: {}".format(4,len(result_RW)))
self.assertEqual(len(result_R),4,"array dimensions do not match the expected dimensions. expected {}, got: {}".format(4,len(result_R)))
print(" Test passed! Managed write and read back a value: {}".format(val))
exceptExceptionase:
info="Test failure in {} {} readback test \n\tW: {} \n\tRW: {} \n\tR: {}".format(test_type,dtype,val,result_RW,result_R)
raiseException(info)frome
"""
List of different types to be used with attributes testing, using any other
might have unexpected results. Each type is bound to a device scalar,