Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate inefficient Python for loops #1877

Merged
merged 4 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions ravenframework/SupervisedLearning/GaussPolynomialRom.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,7 @@ def __trainLocal__(self,featureVals,targetVals):
missing.append(pt)
if len(missing)>0:
msg='\n'
msg+='DEBUG missing feature vals:\n'
for i in missing:
msg+=' '+str(i)+'\n'
msg+='DEBUG missing feature vals:\n' + '\n'.join(map(lambda x:' '+str(x),missing))+ '\n'
self.raiseADebug(msg)
self.raiseADebug('sparse:',sgs)
self.raiseADebug('solns :',fvs)
Expand Down
4 changes: 1 addition & 3 deletions ravenframework/SupervisedLearning/MSR.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,7 @@ def __evaluateLocal__(self,featureVals):
#############
## OR
#############
weights[key] = 0
for idx in indices:
weights[key] += self.__kernel(dists[:,idx]/h)
weights[key] = np.sum([self.__kernel(dists[:,idx]/h) for idx in indices], axis=0)
weights[key]
#############

Expand Down
2 changes: 1 addition & 1 deletion ravenframework/contrib/pyDOE/var_regression_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ def var_regression_matrix(H, x, model, sigma=1):
raise ValueError("model and DOE don't suit together")

x_mod = build_regression_matrix(x, model)
var = sigma**2*np.dot(np.dot(x_mod.T, np.linalg.inv(np.dot(H.T, H))), x_mod)
var = sigma**2*np.linalg.multi_dot([x_mod.T, np.linalg.inv(np.dot(H.T, H)), x_mod])
return var