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

Sourcery refactored master branch #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Jul 19, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Due to GitHub API limits, only the first 60 comments can be shown.

Comment on lines -328 to +330
print("Warning: build in %s is using versioneer.py from %s"
% (os.path.dirname(me), versioneer_py))
print(
f"Warning: build in {os.path.dirname(me)} is using versioneer.py from {versioneer_py}"
)
Copy link
Author

Choose a reason for hiding this comment

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

Function get_root refactored with the following changes:

Comment on lines -403 to +417
print("unable to run %s" % dispcmd)
print(f"unable to run {dispcmd}")
print(e)
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print(f"unable to find command, tried {commands}")
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print("stdout was %s" % stdout)
print(f"unable to run {dispcmd} (error)")
print(f"stdout was {stdout}")
Copy link
Author

Choose a reason for hiding this comment

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

Function run_command refactored with the following changes:

Comment on lines -953 to +964
f = open(versionfile_abs, "r")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["refnames"] = mo.group(1)
if line.strip().startswith("git_full ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["date"] = mo.group(1)
f.close()
with open(versionfile_abs, "r") as f:
for line in f:
if line.strip().startswith("git_refnames ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["refnames"] = mo[1]
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo[1]
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function git_get_keywords refactored with the following changes:

Comment on lines -992 to +993
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = {r.strip() for r in refnames.strip("()").split(",")}
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = {r[len(TAG):] for r in refs if r.startswith(TAG)}
Copy link
Author

Choose a reason for hiding this comment

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

Function git_versions_from_keywords refactored with the following changes:

Comment on lines -1036 to +1055
GITS = ["git"]
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]

GITS = ["git.cmd", "git.exe"] if sys.platform == "win32" else ["git"]
out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
if rc != 0:
if verbose:
print("Directory %s not under git control" % root)
print(f"Directory {root} not under git control")
raise NotThisMethod("'git rev-parse --git-dir' returned error")

# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match", "%s*" % tag_prefix],
cwd=root)
describe_out, rc = run_command(
GITS,
[
"describe",
"--tags",
"--dirty",
"--always",
"--long",
"--match",
f"{tag_prefix}*",
],
cwd=root,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function git_pieces_from_vcs refactored with the following changes:

This removes the following comments ( why? ):

# maybe improved later

Comment on lines -1500 to +1488
cmds = {}

# we add "version" to both distutils and setuptools
from distutils.core import Command


Copy link
Author

Choose a reason for hiding this comment

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

Function get_cmdclass refactored with the following changes:

This removes the following comments ( why? ):

#   "version": versioneer.get_version().split("+", 1)[0], # FILEVERSION
# nczeczulin reports that py2exe won't like the pep440-style string
# as FILEVERSION, but it can be used for PRODUCTVERSION, e.g.
#   ...
# setup(console=[{
#   "product_version": versioneer.get_version(),

Comment on lines -1712 to +1705
print(" creating %s" % cfg.versionfile_source)
print(f" creating {cfg.versionfile_source}")
Copy link
Author

Choose a reason for hiding this comment

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

Function do_setup refactored with the following changes:

Comment on lines -1785 to +1779
for line in f.readlines():
for line in f:
Copy link
Author

Choose a reason for hiding this comment

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

Function scan_setup_py refactored with the following changes:

keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
return keywords
return {"refnames": git_refnames, "full": git_full, "date": git_date}
Copy link
Author

Choose a reason for hiding this comment

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

Function get_keywords refactored with the following changes:

Comment on lines -89 to +101
print("unable to run %s" % dispcmd)
print(f"unable to run {dispcmd}")
print(e)
return None, None
else:
if verbose:
print("unable to find command, tried %s" % (commands,))
print(f"unable to find command, tried {commands}")
return None, None
stdout = p.communicate()[0].strip()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0:
if verbose:
print("unable to run %s (error)" % dispcmd)
print("stdout was %s" % stdout)
print(f"unable to run {dispcmd} (error)")
print(f"stdout was {stdout}")
Copy link
Author

Choose a reason for hiding this comment

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

Function run_command refactored with the following changes:

Comment on lines -116 to +127
for i in range(3):
for _ in range(3):
dirname = os.path.basename(root)
if dirname.startswith(parentdir_prefix):
return {"version": dirname[len(parentdir_prefix):],
"full-revisionid": None,
"dirty": False, "error": None, "date": None}
else:
rootdirs.append(root)
root = os.path.dirname(root) # up a level
rootdirs.append(root)
root = os.path.dirname(root) # up a level

if verbose:
print("Tried directories %s but none started with prefix %s" %
(str(rootdirs), parentdir_prefix))
print(
f"Tried directories {rootdirs} but none started with prefix {parentdir_prefix}"
)
Copy link
Author

Choose a reason for hiding this comment

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

Function versions_from_parentdir refactored with the following changes:

Comment on lines -141 to +150
f = open(versionfile_abs, "r")
for line in f.readlines():
if line.strip().startswith("git_refnames ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["refnames"] = mo.group(1)
if line.strip().startswith("git_full ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["full"] = mo.group(1)
if line.strip().startswith("git_date ="):
mo = re.search(r'=\s*"(.*)"', line)
if mo:
keywords["date"] = mo.group(1)
f.close()
with open(versionfile_abs, "r") as f:
for line in f:
if line.strip().startswith("git_refnames ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["refnames"] = mo[1]
if line.strip().startswith("git_full ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["full"] = mo[1]
if line.strip().startswith("git_date ="):
if mo := re.search(r'=\s*"(.*)"', line):
keywords["date"] = mo[1]
Copy link
Author

Choose a reason for hiding this comment

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

Function git_get_keywords refactored with the following changes:

Comment on lines -180 to +179
refs = set([r.strip() for r in refnames.strip("()").split(",")])
refs = {r.strip() for r in refnames.strip("()").split(",")}
# starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
# just "foo-1.0". If we see a "tag: " prefix, prefer those.
TAG = "tag: "
tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)])
tags = {r[len(TAG):] for r in refs if r.startswith(TAG)}
Copy link
Author

Choose a reason for hiding this comment

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

Function git_versions_from_keywords refactored with the following changes:

Comment on lines -224 to +241
GITS = ["git"]
if sys.platform == "win32":
GITS = ["git.cmd", "git.exe"]

GITS = ["git.cmd", "git.exe"] if sys.platform == "win32" else ["git"]
out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root,
hide_stderr=True)
if rc != 0:
if verbose:
print("Directory %s not under git control" % root)
print(f"Directory {root} not under git control")
raise NotThisMethod("'git rev-parse --git-dir' returned error")

# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
# if there isn't one, this yields HEX[-dirty] (no NUM)
describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty",
"--always", "--long",
"--match", "%s*" % tag_prefix],
cwd=root)
describe_out, rc = run_command(
GITS,
[
"describe",
"--tags",
"--dirty",
"--always",
"--long",
"--match",
f"{tag_prefix}*",
],
cwd=root,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function git_pieces_from_vcs refactored with the following changes:

This removes the following comments ( why? ):

# maybe improved later

Comment on lines -310 to +304
if "+" in pieces.get("closest-tag", ""):
return "."
return "+"
return "." if "+" in pieces.get("closest-tag", "") else "+"
Copy link
Author

Choose a reason for hiding this comment

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

Function plus_or_dot refactored with the following changes:

Comment on lines -113 to +124
DATA = numpy.fft.ifftshift(
numpy.fft.irfft(
numpy.fft.ifftshift(data, axes=(-1))),
axes=(-1)) * data.shape[-1] * delta_f

return DATA
return (
numpy.fft.ifftshift(
numpy.fft.irfft(numpy.fft.ifftshift(data, axes=(-1))), axes=(-1)
)
* data.shape[-1]
* delta_f
)
Copy link
Author

Choose a reason for hiding this comment

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

Function irft refactored with the following changes:

Comment on lines -131 to +143
DATA = numpy.fft.fftshift(
numpy.fft.rfft2(
numpy.fft.fftshift(data, axes=(-1,-2))
), axes=(-1,-2)
)*delta**2

return DATA
return (
numpy.fft.fftshift(
numpy.fft.rfft2(numpy.fft.fftshift(data, axes=(-1, -2))),
axes=(-1, -2),
)
* delta**2
)
Copy link
Author

Choose a reason for hiding this comment

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

Function rft2 refactored with the following changes:

Comment on lines -151 to +165
DATA = numpy.fft.ifftshift(
return (
numpy.fft.ifftshift(
numpy.fft.irfft2(
numpy.fft.ifftshift(data, axes=(-1,-2)),
axes=(-1,-2)
),
axes=(-1,-2)) * (N * delta_f)**2
return DATA
numpy.fft.ifftshift(data, axes=(-1, -2)), axes=(-1, -2)
),
axes=(-1, -2),
)
* (N * delta_f) ** 2
)
Copy link
Author

Choose a reason for hiding this comment

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

Function irft2 refactored with the following changes:

if array.dtype==numpy.complex64 or array.dtype==numpy.complex128:
if array.dtype in [numpy.complex64, numpy.complex128]:
Copy link
Author

Choose a reason for hiding this comment

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

Function zoom refactored with the following changes:

Comment on lines -83 to +93
if array.dtype==numpy.complex64 or array.dtype==numpy.complex128:
if array.dtype in [numpy.complex64, numpy.complex128]:
realInterpObj = RectBivariateSpline(
numpy.arange(array.shape[0]), numpy.arange(array.shape[1]),
array.real, kx=order, ky=order)
imagInterpObj = RectBivariateSpline(
numpy.arange(array.shape[0]), numpy.arange(array.shape[1]),
array.imag, kx=order, ky=order)

return (realInterpObj(coordsY,coordsX)
+ 1j*imagInterpObj(coordsY,coordsX))

Copy link
Author

Choose a reason for hiding this comment

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

Function zoom_rbs refactored with the following changes:


Copy link
Author

Choose a reason for hiding this comment

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

Function binImgs refactored with the following changes:

Comment on lines -58 to +61
#Compute propagated field
outputComplexAmp = Q3 * fouriertransform.ift2(
Q2 * fouriertransform.ft2(Q1 * inputComplexAmp/mag,inputSpacing), df1)
return outputComplexAmp
return Q3 * fouriertransform.ift2(
Q2 * fouriertransform.ft2(Q1 * inputComplexAmp / mag, inputSpacing),
df1,
)
Copy link
Author

Choose a reason for hiding this comment

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

Function angularSpectrum refactored with the following changes:

This removes the following comments ( why? ):

#Compute propagated field

Uout = A*B*C

return Uout
return A*B*C
Copy link
Author

Choose a reason for hiding this comment

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

Function oneStepFresnel refactored with the following changes:

Comment on lines -147 to +145
Uout = A*B*C

return Uout
return A*B*C
Copy link
Author

Choose a reason for hiding this comment

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

Function twoStepFresnel refactored with the following changes:

#Evaluate the Fresnel-Kirchoff integral but with the quadratic
#phase factor inside cancelled by the phase of the lens
Uout = numpy.exp( 1j*k/(2*f) * (x2**2 + y2**2) )/ (1j*wvl*f) * fouriertransform.ft2( Uin, d1)

return Uout
return (
numpy.exp(1j * k / (2 * f) * (x2**2 + y2**2))
/ (1j * wvl * f)
* fouriertransform.ft2(Uin, d1)
)
Copy link
Author

Choose a reason for hiding this comment

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

Function lensAgainst refactored with the following changes:

This removes the following comments ( why? ):

#phase factor inside cancelled by the phase of the lens
#Evaluate the Fresnel-Kirchoff integral but with the quadratic

Comment on lines -436 to +447
phi = np.transpose(rebin(np.reshape(phi1, (npp, 1)), (npp, nr)))
return phi
return np.transpose(rebin(np.reshape(phi1, (npp, 1)), (npp, nr)))
Copy link
Author

Choose a reason for hiding this comment

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

Function polang refactored with the following changes:

Comment on lines -545 to +566
geom = {'px': px, 'py': py, 'cr': cr, 'cp': cp,
'pincx': pincx, 'pincy': pincy, 'pincw': pincw,
'ap': ap, 'ncp': ncp, 'ncmar': ncmar}

return geom
return {
'px': px,
'py': py,
'cr': cr,
'cp': cp,
'pincx': pincx,
'pincy': pincy,
'pincw': pincw,
'ap': ap,
'ncp': ncp,
'ncmar': ncmar,
}
Copy link
Author

Choose a reason for hiding this comment

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

Function pcgeom refactored with the following changes:

Comment on lines -624 to +641
assert (stf == 'kolmogorov') or (stf == 'kolstf') or (stf == 'vonKarman') \
or (stf == 'karman') or (stf == 'vk')
assert stf in ['kolmogorov', 'kolstf', 'vonKarman', 'karman', 'vk']
Copy link
Author

Choose a reason for hiding this comment

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

Function make_kl refactored with the following changes:

Comment on lines -60 to +64
else:
if m > 0: # j is even
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.cos((m*theta)+rot)
else: #i is odd
m = abs(m)
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.sin((m*theta)+rot)
elif m > 0: # j is even
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.cos((m*theta)+rot)
else: #i is odd
m = abs(m)
Z = numpy.sqrt(2*(n+1)) * zernikeRadialFunc(n, m, R) * numpy.sin((m*theta)+rot)
Copy link
Author

Choose a reason for hiding this comment

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

Function zernike_nm refactored with the following changes:

Comment on lines -116 to +115
if j%2==0:
s=1
else:
s=-1
s = 1 if j%2==0 else -1
Copy link
Author

Choose a reason for hiding this comment

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

Function zernIndex refactored with the following changes:

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.

0 participants