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

pure python valid region does not behave as shown in docs #577

Open
butlerpd opened this issue Aug 16, 2023 · 1 comment
Open

pure python valid region does not behave as shown in docs #577

butlerpd opened this issue Aug 16, 2023 · 1 comment

Comments

@butlerpd
Copy link
Member

butlerpd commented Aug 16, 2023

If there are regions of parameter space which are not valid, a model function can exclude them from fitting according to the docs. However the C models do it differently and require a valid = (Boolean expression) while the python model is told to return np.nan.

Recent attempts at using this second version shows it does not actually work for fitting. Upon investigation @pkienzle believes that the following code placed at line 225 of kernelpy.py] might fix the problem

total = form()
if np.isnan(total).any():
    total = np.zeros(nq, 'd')

That said, a preferred solution would be to make the two interfaces the same. That however would require parsing a C style Boolean expression.

@pkienzle
Copy link
Contributor

Should avoid computing the form volume and form radius since they are also likely to be invalid. The code becomes:

if call_details.num_active == 0:
    weight_norm = 1.0
    total = form()
    if np.isnan(total).any():
        total = np.zeros(nq, 'd')
        weighted_shell = weighted_form = weighted_radius = 0
    else:
        weighted_shell, weighted_form = form_volume()
        weighted_radius = form_radius()

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

No branches or pull requests

2 participants