Changeset 574adc7 in sasview for src/sas/sascalc/invariant/invariant.py
- Timestamp:
- Sep 22, 2017 4:01:32 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 34d7b35
- Parents:
- 9706d88
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sascalc/invariant/invariant.py
rb1f20d1 r574adc7 424 424 if not issubclass(data.__class__, LoaderData1D): 425 425 #Process only data that inherited from DataLoader.Data_info.Data1D 426 raise ValueError , "Data must be of type DataLoader.Data1D"426 raise ValueError("Data must be of type DataLoader.Data1D") 427 427 #from copy import deepcopy 428 428 new_data = (self._scale * data) - self._background … … 484 484 msg = "Length x and y must be equal" 485 485 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 486 raise ValueError , msg486 raise ValueError(msg) 487 487 else: 488 488 # Take care of smeared data … … 507 507 #iterate between for element different 508 508 #from the first and the last 509 for i in xrange(1, n - 1):509 for i in range(1, n - 1): 510 510 dxi = (data.x[i + 1] - data.x[i - 1]) / 2 511 511 total += gx[i] * data.y[i] * dxi … … 533 533 msg = "Length of data.x and data.y must be equal" 534 534 msg += " and greater than 1; got x=%s, y=%s" % (len(data.x), len(data.y)) 535 raise ValueError , msg535 raise ValueError(msg) 536 536 else: 537 537 #Create error for data without dy error … … 560 560 #iterate between for element different 561 561 #from the first and the last 562 for i in xrange(1, n - 1):562 for i in range(1, n - 1): 563 563 dxi = (data.x[i + 1] - data.x[i - 1]) / 2 564 564 total += (gx[i] * dy[i] * dxi) ** 2 … … 742 742 range = range.lower() 743 743 if range not in ['high', 'low']: 744 raise ValueError , "Extrapolation range should be 'high' or 'low'"744 raise ValueError("Extrapolation range should be 'high' or 'low'") 745 745 function = function.lower() 746 746 if function not in ['power_law', 'guinier']: 747 747 msg = "Extrapolation function should be 'guinier' or 'power_law'" 748 raise ValueError , msg748 raise ValueError(msg) 749 749 750 750 if range == 'high': 751 751 if function != 'power_law': 752 752 msg = "Extrapolation only allows a power law at high Q" 753 raise ValueError , msg753 raise ValueError(msg) 754 754 self._high_extrapolation_npts = npts 755 755 self._high_extrapolation_power = power … … 852 852 """ 853 853 if contrast <= 0: 854 raise ValueError , "The contrast parameter must be greater than zero"854 raise ValueError("The contrast parameter must be greater than zero") 855 855 856 856 # Make sure Q star is up to date … … 859 859 if self._qstar <= 0: 860 860 msg = "Invalid invariant: Invariant Q* must be greater than zero" 861 raise RuntimeError , msg861 raise RuntimeError(msg) 862 862 863 863 # Compute intermediate constant … … 869 869 if discrim < 0: 870 870 msg = "Could not compute the volume fraction: negative discriminant" 871 raise RuntimeError , msg871 raise RuntimeError(msg) 872 872 elif discrim == 0: 873 873 return 1 / 2 … … 881 881 return volume2 882 882 msg = "Could not compute the volume fraction: inconsistent results" 883 raise RuntimeError , msg883 raise RuntimeError(msg) 884 884 885 885 def get_qstar_with_error(self, extrapolation=None):
Note: See TracChangeset
for help on using the changeset viewer.