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

I1673 add support for Nan values in the N2 diagram #1677

Merged
merged 4 commits into from Sep 10, 2020

Conversation

hschilling
Copy link
Member

Summary

The N2 diagram did not handle the case where initial values had Nan values in them.

Also did some re-factoring of related JavaScript code to reduce code duplication.

Related Issues

Backwards incompatibilities

None

New Dependencies

None

@project-bot project-bot bot added this to In progress in OpenMDAO Dev [Read only] Sep 10, 2020
@@ -77,7 +94,7 @@ def _get_var_dict(system, typ, name):
var_dict['value'] = type(meta['value']).__name__
else:
if meta['value'].size < _MAX_ARRAY_SIZE_FOR_REPR_VAL:
var_dict['value'] = meta['value']
var_dict['value'] = _convert_to_support_nans_in_json(meta['value'])
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can probably add a test for this if calling n2 on a prob with NaN formerly raised an exception. Just do n2(p, show_browser=False) so that it doesn't open the browser or write a file.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great point. I had that in my head as a to do yesterday and then forgot today. Will add

Copy link
Contributor

@swryan swryan Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to other comment..
I think you could replace this single use function with something like:
var_dict['value'] = _convert_nans_in_nested_list(meta['value'].tolist())

OpenMDAO Dev [Read only] automation moved this from In progress to Reviewer approved Sep 10, 2020
val_string = val_float_formatter(element);
}
} else {
val_string = stringify_with_support_for_nan(element);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is only used in this one place
since it's a simple if/else, I think you could just inline it and avoid a function call

@@ -77,7 +94,7 @@ def _get_var_dict(system, typ, name):
var_dict['value'] = type(meta['value']).__name__
else:
if meta['value'].size < _MAX_ARRAY_SIZE_FOR_REPR_VAL:
var_dict['value'] = meta['value']
var_dict['value'] = _convert_to_support_nans_in_json(meta['value'])
else:
Copy link
Contributor

@swryan swryan Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similar to other comment..
I think you could replace this single use function with something like:
var_dict['value'] = _convert_nans_in_nested_list(meta['value'].tolist())

@swryan swryan merged commit 069b050 into OpenMDAO:master Sep 10, 2020
OpenMDAO Dev [Read only] automation moved this from Reviewer approved to Done Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Problem with N2 generation
4 participants