Skip to content

Commit

Permalink
Merge pull request #2655 from SasView/release_6.0.0_numpy_fix
Browse files Browse the repository at this point in the history
Cherry-picked new_numpy_behaviour
  • Loading branch information
Wojciech Potrzebowski authored Oct 2, 2023
2 parents 0a9baf5 + 8910849 commit cee4343
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sas/qtgui/Calculators/SlitSizeCalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def calculateSlitSize(self, data=None):
try:
xdata = data.x
ydata = data.y
if xdata == [] or xdata is None or ydata == [] or ydata is None:
if xdata.size == 0 or xdata is None or ydata.size == 0 or ydata is None:
msg = "The current data is empty please check x and y"
logging.error(msg)
return
Expand Down
3 changes: 2 additions & 1 deletion src/sas/qtgui/Perspectives/Fitting/FittingUtilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ def calculateChi2(reference_data, current_data, weight):

if index is None:
index = numpy.ones(len(current_data.y), dtype=bool)
if current_data.dy is None or current_data.dy == []:
# if current_data.dy is None or not len(current_data.dy):
if current_data.dy is None or current_data.dy.size == 0:
dy = numpy.ones(len(current_data.y))
else:
dy = weight
Expand Down
4 changes: 2 additions & 2 deletions src/sas/sascalc/fit/AbstractFitEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class DataLoader.data_info.Data1D
# Check error bar; if no error bar found, set it constant(=1)
# TODO: Should provide an option for users to set it like percent,
# constant, or dy data
if dy is None or dy == [] or dy.all() == 0:
if dy is None or dy.size == 0 or np.all(dy == 0):
self.dy = np.ones(len(y))
else:
self.dy = np.asarray(dy).copy()
Expand Down Expand Up @@ -299,7 +299,7 @@ def set_data(self, sas_data2d, qmin=None, qmax=None):
if qmax is None:
self.qmax = math.sqrt(x_max * x_max + y_max * y_max)
## new error image for fitting purpose
if self.err_data is None or self.err_data == []:
if self.err_data is None or self.err_data.size == 0:
self.res_err_data = np.ones(len(self.data))
else:
self.res_err_data = copy.deepcopy(self.err_data)
Expand Down

0 comments on commit cee4343

Please sign in to comment.