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

IO related code reorganization #103

Merged
merged 11 commits into from
Mar 24, 2023
Merged

IO related code reorganization #103

merged 11 commits into from
Mar 24, 2023

Conversation

NikoOinonen
Copy link
Collaborator

Fixes #46

Reorganizing code related to file IO so that all IO functions are in one module called io:

  • Rename basUtils to io
  • Move some functions from io to atomicUtils
  • Move several functions from GridUtils to io. Basically GridUtils now only functions as an interface to the C++ functions.
  • Deleted a couple of functions that were not used anywhere and did not seem important.
  • Fix all affected imports.

@yakutovicha
Copy link
Collaborator

@NikoOinonen, please resolve the conflicts. I will then review the PR.

Copy link
Collaborator

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

thanks a lot @NikoOinonen. The two main suggestions I have are:

  1. Please always use the same coding pattern:
from ppafm import io

io.loadXYZ(..)
  1. Please remove unnecessary comments.

@@ -10,7 +10,6 @@
#from ppafm import fieldOCL as FFcl
#from ppafm import RelaxOpenCL as oclr
#from ppafm import common as PPU
#from ppafm import basUtils
#from ppafm.AFMulatorOCL_Simple import AFMulator
#from ppafm.GeneratorOCL_Simple2 import InverseAFMtrainer
#from ppafm.AuxMap import AuxMaps
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the unnecessary comments and sys.path.append. Same for all the occurrences below.

Comment on lines 393 to 394
#io.saveVecFieldXsf( "DEBUG_FFcl", self.FF[:,:,:,:3].astype(np.float32), self.lvec )
#io.saveXSF( "DEBUG_FFcl_z.xsf", self.FF[:,:,:,2].astype(np.float32), self.lvec )
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
#io.saveVecFieldXsf( "DEBUG_FFcl", self.FF[:,:,:,:3].astype(np.float32), self.lvec )
#io.saveXSF( "DEBUG_FFcl_z.xsf", self.FF[:,:,:,2].astype(np.float32), self.lvec )

#import GridUtils as GU
#sys.path.append("/u/25/prokoph1/unix/git/ProbeParticleModel")

from ppafm.io import loadXSF, saveXSF
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest the following pattern everywhere:

from ppafm import io

io.saveXSF(..)  # everywhere

Comment on lines 59 to 61
#saveXSF( "FF"+namestr+"_x.xsf", Fx*PQ, lvec1, head=head1 )
#saveXSF( "FF"+namestr+"_y.xsf", Fy*PQ, lvec1, head=head1 )
#saveXSF( "FF"+namestr+"_z.xsf", Fz*PQ, lvec1, head=head1 )
Copy link
Collaborator

Choose a reason for hiding this comment

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

eliminate.

Suggested change
#saveXSF( "FF"+namestr+"_x.xsf", Fx*PQ, lvec1, head=head1 )
#saveXSF( "FF"+namestr+"_y.xsf", Fy*PQ, lvec1, head=head1 )
#saveXSF( "FF"+namestr+"_z.xsf", Fz*PQ, lvec1, head=head1 )

@@ -159,7 +156,7 @@ def evalFF_LJC( iZPP, xyzs, Zs, qs, poss, typeParams, func_runFF=FFcl.runLJC ):
FF = evalFFatoms_LJC( atoms, cLJs, poss, func_runFF=FFcl.runLJC )
FEin = FF[:,:,:,:4] + Q*FF[:,:,:,4:]
Tff = time.clock()-t1ff;
#GU.saveXSF( geomFileName+'_Fin_z.xsf', FEin[:,:,:,2], lvec );
# io.saveXSF( geomFileName+'_Fin_z.xsf', FEin[:,:,:,2], lvec );
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are many commented lines everywhere in the files you updated. Just remove them, please.

@NikoOinonen
Copy link
Collaborator Author

@yakutovicha Most of the problems are in the scripts inside dev, and it looks like most of those scripts are unmaintained and broken. In hindsight, I probably should not have touched them at all, but it was just easier to grep and fix every occurrence of basUtils and GridUtils than to be selective.

@ProkopHapala Could you check if these scripts are actually needed, and maybe delete or move them to some other branch if they are not important? So that we don't have to spent time modifying them when we do fixes like this.

@ondrejkrejci
Copy link
Collaborator

I am having a problem as this reorganization is heavily messing with my pull request, which is to be finished this week (if my son is not ill). Maybe I should wait to this one to be pushed and then I will change the NPY part of it?

@NikoOinonen
Copy link
Collaborator Author

@ondrejkrejci We can also merge yours first and then pull those fixes here. Whichever way you think is easiest.

@ondrejkrejci
Copy link
Collaborator

@ondrejkrejci We can also merge yours first and then pull those fixes here. Whichever way you think is easiest.

If this is quicker than me, go ahead.

@yakutovicha
Copy link
Collaborator

I am having a problem as this reorganization is heavily messing with my pull request, which is to be finished this week (if my son is not ill). Maybe I should wait to this one to be pushed and then I will change the NPY part of it?

My 2 cents on this topic.

An open pull request will have more conflicts with time. That is normal because other people are also working on the code. Therefore, resolving merge conflicts is a natural part of collaborative development. An open pull request should never be a reason for others to wait or to stop working.

@yakutovicha
Copy link
Collaborator

Blocked till #119 is resolved.

@NikoOinonen NikoOinonen marked this pull request as draft March 23, 2023 11:50
@NikoOinonen NikoOinonen marked this pull request as ready for review March 23, 2023 13:14
@NikoOinonen NikoOinonen requested a review from yakutovicha March 23, 2023 13:14
@yakutovicha
Copy link
Collaborator

@NikoOinonen, please merge the main branch into it so the tests are passing.

@NikoOinonen
Copy link
Collaborator Author

Merged main and all checks are passing.

Copy link
Collaborator

@yakutovicha yakutovicha left a comment

Choose a reason for hiding this comment

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

Thanks @NikoOinonen. LGTM.

I think it is a good step forward towards high-quality code 👍

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

Successfully merging this pull request may close these issues.

Organize file IO related functions to their own module
3 participants