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

Format update #35

Merged
merged 12 commits into from
Nov 2, 2020
Merged

Format update #35

merged 12 commits into from
Nov 2, 2020

Conversation

marcomangano
Copy link
Contributor

Purpose

I re-formatted the code, as per this issue.
The first two commits are the black and manual flake8 fixes respectively.
I committed separately a few fixes that I would like the reviewers to double check carefully, to be sure that the code behaviour is not changing

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Checklist

  • I have run flake8 and black to make sure the code adheres to PEP-8 and is consistently formatted
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@marcomangano marcomangano requested a review from a team as a code owner October 31, 2020 10:03
import os
import glob
import re
from stat import * # noqa: F403
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you not tell what the star imports were?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Never mind I see you fixed this later on.

@@ -148,9 +148,9 @@ def reg_file_comp(ref_file, comp_file):
str1 = "@value 3.141592653589793 1e-12 1e-12"
str2 = "@value 3.141592653589999 1e-12 1e-12"

print("This comp should be True: ", reg_comp(str1, str2))
print("This comp should be True: ", _reg_str_comp(str1, str2))
Copy link
Collaborator

Choose a reason for hiding this comment

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

I forget, why is this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

reg_comp does not exist anymore - I believed you renamed it to _reg_str_comp, but this was not caught as an error because we never run python mdo_regression_helper.py

import numpy as np
from pprint import pprint
from mpi4py import MPI
from .MExt import MExt
from petsc4py import PETSc

try:
from cgnsutilities import cgns_utils as cs
Copy link
Collaborator

Choose a reason for hiding this comment

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

This actually reminds me, we changed the file names, so this should probably be updated to
from cgnsutilities import cgnsutilities as cs

@@ -277,7 +277,6 @@ def write_output(filename, lines):
try:
g = open(newname, "w")
except IOError as err:
f.close()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suspect this was supposed to be g.close() I think? Not really sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that was my guess too... but then I realized that it did not make sense to close something that was never opened, so I removed it altogether. I can put g.close() back in, but one way or the other that except is going to exit the run - more or less gracefully

@ewu63
Copy link
Collaborator

ewu63 commented Oct 31, 2020

So I am a tiny bit uneasy about fixing complexify.py just because it's so old it needs a total overhaul. What I would recommend is reverting those files to how they were, and if you add a .flake8 file just to ignore those files, then Travis will work its magic. We can fix these at a later date.

See for example this file.

@marcomangano
Copy link
Contributor Author

So I am a tiny bit uneasy about fixing complexify.py just because it's so old it needs a total overhaul. What I would recommend is reverting those files to how they were, and if you add a .flake8 file just to ignore those files, then Travis will work its magic. We can fix these at a later date.

See for example this file.

Yeah, I was a bit uneasy too but I gave it a shot. I will revert it back as you suggest

@marcomangano
Copy link
Contributor Author

I will fix complexify by the end of the day

@ewu63
Copy link
Collaborator

ewu63 commented Oct 31, 2020

Sure, instead of reverting commits you can just copy/paste what we had before and do a single commit that way.

@marcomangano
Copy link
Contributor Author

Sure, instead of reverting commits you can just copy/paste what we had before and do a single commit that way.

That's the only way I am able to do it ahaha

@marcomangano
Copy link
Contributor Author

@nwu63 this should fix it?

@ewu63
Copy link
Collaborator

ewu63 commented Oct 31, 2020

Good except you still need to run black on it

ewu63
ewu63 previously approved these changes Oct 31, 2020
Copy link
Collaborator

@ewu63 ewu63 left a comment

Choose a reason for hiding this comment

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

Good with me but I'd prefer someone else to also take a look.

@ewu63 ewu63 requested a review from eirikurj October 31, 2020 16:18
Copy link
Contributor

@eirikurj eirikurj left a comment

Choose a reason for hiding this comment

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

Few minor things, otherwise looks good.

@@ -121,7 +124,7 @@ def __init__(self, CGNSFile, optionsDict, comm=None, dtype='d'):
self.warp
except AttributeError:
curDir = os.path.dirname(os.path.realpath(__file__))
self.warp = MExt('idwarp', [curDir], debug=debug)._module
self.warp = MExt("idwarp", [curDir])._module
Copy link
Contributor

Choose a reason for hiding this comment

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

To maintain consistency please keep this argument and add a default value debug=False in the __init__ function.

@@ -763,12 +762,12 @@ def warpMesh(self):
"""

# Get proc ID
myID = self.comm.Get_rank()
self.myID = self.comm.Get_rank()
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of overwriting the value (which is set once in the __init__ function) please just remove this line (and the ones below).

print('| All IDWarp Options: |')
print('+---------------------------------------+')
print("")
print(" Options of mesh", mesh, "of", len(self.meshes))
Copy link
Contributor

Choose a reason for hiding this comment

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

This will print out the handle to the mesh object. Not sure this is the desired behavior.

Copy link
Contributor

@eirikurj eirikurj left a comment

Choose a reason for hiding this comment

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

Few minor things, otherwise looks good. Do we want to add the black/flake8 commit to a git blame ignore file?

@marcomangano
Copy link
Contributor Author

Few minor things, otherwise looks good. Do we want to add the black/flake8 commit to a git blame ignore file?

@nwu63 what is our final position on this? I have one I can add now, but we realized that such file is only useful locally.. other ppl must initialize it in their git option for it to work, and still it is not effective on the browser interface. Your call guys!

@ewu63
Copy link
Collaborator

ewu63 commented Nov 2, 2020

Yeah personally I don't see much value in it since git cannot pick it out automatically, and it just sort of clutters the repo. Most tools can git blame multiple times and as long as your commit message is clear I think it's fine.

@ewu63 ewu63 merged commit 3363284 into mdolab:master Nov 2, 2020
@marcomangano marcomangano deleted the format-update branch November 3, 2020 08:51
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.

3 participants