lanl / SEPIA

Simulation-Enabled Prediction, Inference, and Analysis: physics-informed statistical learning.
Other
29 stars 6 forks source link

Dev #38

Closed granthutchings closed 3 years ago

granthutchings commented 3 years ago

Great work, @granthutchings!

I left some comments and suggestions. If any of them are too annoying, feel free to ignore.

Since I'm not familiar with the source and I don't know what the changes actually do, the changes I suggested mainly concern readability.

If possible, lines should be restricted to no longer than 90 characters in length. (If you are using a text editor like vim or vscode, there are options to enforce that of hard-wrap long lines.)

Possible ways for breaking down long lines include storing long function arguments in a variable before using them as function arguments.

To enhance readability, you can also rewrite long lines or sequence of operations as functions. (Be mindful, though, of declaring functions in functions that are used in time-critical code.

For example, I noticed some long function arguments are passed to some plot functions. They should probably be defined prior to the plt.plot function for better readability. (Please double check to make sure I didn't mess up in the suggestions.)

Also, small commits which provide one (maybe two) new features are usually preferred. In the case of rewriting tests, that's probably unreasonable. But, something to keep in mind.

NOTE: you can click commit suggestion where applicable in this review. In other places, you can just commit your changes if you want to address any of the comments.

Thanks @luiarthur, ill commit some revisions in the next couple of days.

granthutchings commented 3 years ago

@luiarthur revisions done in commits d11720f, d0992cd

natalieklein229 commented 3 years ago

Apologies that I have not had a chance to look yet. I should be able to take a glance ths afternoon!

From: Arthur Lui @.> Reply-To: lanl/SEPIA @.> Date: Tuesday, August 31, 2021 at 12:32 PM To: lanl/SEPIA @.> Cc: "Klein, Natalie Elizabeth" @.>, Mention @.***> Subject: [EXTERNAL] Re: [lanl/SEPIA] Dev (#38)

@luiarthur requested changes on this pull request.

Excellent, @granthutchingshttps://github.com/granthutchings!

I just made a few formatting suggestions. If they look correct, then you can hit commit suggestions.

I'm fine with merging this unless anyone else wanted to take a look.

cc: @jgattikerhttps://github.com/jgattiker @natalieklein229https://github.com/natalieklein229


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699564054:

@@ -755,62 +755,68 @@ def pca_projected_data(data):

         # show data - observation and simulations

         plt.subplot(2,2,1)

         n_obs_lines = data.obs_data.y.T.shape[1]

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699566476:

  • y_obs_pca = @.**_data.K)

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699569057:

  • y_sim_pca = @.**_data.K)

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699569257:

         plt.legend()
         plt.title('Data: sims, obs')

         # show obs and reconstructed obs alone

         plt.subplot(2,2,2)

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699569455:

         plt.legend()
         plt.title('PCA truncation effect on observation')

         # show data projected and reconstructed through K basis

         # (this is the problem being solved given PCA truncation)

         plt.subplot(2,2,3)

         # add the obs projected and reconstructed through the K basis

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699569844:

         plt.legend()
         plt.title('Data: sims, obs')

         # show obs and reconstructed obs alone

         plt.subplot(2,2,2)

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699570374:

         plt.legend()
         plt.title('PCA truncation effect on observation')

         # show data projected and reconstructed through K basis

         # (this is the problem being solved given PCA truncation)

         plt.subplot(2,2,3)

         # add the obs projected and reconstructed through the K basis

⬇️ Suggested change


In test/test_Neddermeyer.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699573082:

  • y_ind_obs_1 = np.column_stack( ( np.concatenate((np.ones(phi_obs.shape[0])*time_obs[0][0],\

⬇️ Suggested change


In test/test_Neddermeyer.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699574531:

         y_obs[i] = (y_obs[i] + .01*np.random.normal(size=y_obs[i].shape)).flatten()
     # indices of observations

     x_obs = ((np.array([params10[4], .17, .36])/.32-.5)/.65).reshape(3,1)

⬇️ Suggested change


In test/test_Neddermeyer.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699575816:

  • y_ind_obs_3 = np.column_stack( ( np.concatenate((np.ones(phi_obs.shape[0])*time_obs[2][0],\

⬇️ Suggested change


In sepia/SepiaPlot.pyhttps://github.com/lanl/SEPIA/pull/38#discussion_r699570704:

         plt.legend()
         plt.title('PCA truncation effect on observation')

         # show data projected and reconstructed through K basis

         # (this is the problem being solved given PCA truncation)

         plt.subplot(2,2,3)

         # add the obs projected and reconstructed through the K basis

Added a few more spaces to align with parenthesis.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/lanl/SEPIA/pull/38#pullrequestreview-743050380, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AQBKU4UVB7R6S5DJLIGED53T7UN35ANCNFSM5C5UV6KQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

luiarthur commented 3 years ago

Great, I think this is ready to be merged.

@jgattiker, if you feel good about the changes, you approve the changes.

This PR has some merge conflicts, but I can resolve those and merge after.

Might need @granthutchings's help if I run into anything tricky.

luiarthur commented 3 years ago

I'll merge this in the morning.

luiarthur commented 3 years ago

Thanks @granthutchings for this PR. And thanks @natalieklein229 and @jgattiker for reviewing.

FYI, I've squash-merged dev into master, and deleted dev.

Let me know if you have any questions.