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

Occasional runtime warning #155

Closed
j-c-cook opened this issue Oct 27, 2021 · 3 comments · Fixed by #156
Closed

Occasional runtime warning #155

j-c-cook opened this issue Oct 27, 2021 · 3 comments · Fixed by #156
Labels

Comments

@j-c-cook
Copy link
Contributor

I occasionally get the following run time warning.

H:\Masters\ghedt\ghedt\PLAT\pygfunction\pipes.py:736: RuntimeWarning: invalid value encountered in subtract
  if (np.all(np.abs(m_flow_borehole*cp_f - stored_m_flow_cp) < np.abs(stored_m_flow_cp)*tol)
H:\Masters\ghedt\ghedt\PLAT\pygfunction\pipes.py:736: RuntimeWarning: invalid value encountered in multiply
  if (np.all(np.abs(m_flow_borehole*cp_f - stored_m_flow_cp) < np.abs(stored_m_flow_cp)*tol)
@MassimoCimmino
Copy link
Owner

This may be related to the use of numpy.empty to initialize arrays, for example here:

def _initialize_stored_coefficients(self):
nMethods = 8 # Number of class methods
self._stored_coefficients = [() for i in range(nMethods)]
self._stored_m_flow_cp = [np.empty(self.nInlets)
for i in range(nMethods)]
self._stored_nSegments = [np.nan for i in range(nMethods)]
self._m_flow_cp_model_variables = np.empty(self.nInlets)
self._nSegments_model_variables = np.nan

The proper way is probably to use numpy.zeros or numpy.nan.

@MassimoCimmino
Copy link
Owner

@j-c-cook Please let me know if the changes on the development branch issue155[...] fixes the issue.

@j-c-cook
Copy link
Contributor Author

j-c-cook commented Nov 3, 2021

The error message shown in the original post is intermittent. I'm not sure what causes it, but it occasionally happens. I don't think I've seen it since I posted this 7 days ago. Given that I don't know how to reproduce the runtime warning, I cannot verify that your fixes have resolved the issue. My proposal is that we consider it "good enough", especially given that the runtime warnings never had an effect on results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants