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 #24

Merged
merged 2 commits into from
Feb 15, 2024
Merged

Sourcery refactored master branch #24

merged 2 commits into from
Feb 15, 2024

Conversation

sourcery-ai[bot]
Copy link
Contributor

@sourcery-ai sourcery-ai bot commented Jun 11, 2020

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^

if Pos == "All":
NodNum = len(Spectra)
else:
NodNum = len(Spectra) / 2.0
NodNum = len(Spectra) if Pos == "All" else len(Spectra) / 2.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function SumNods refactored with the following changes:

  • Replace if statement with if expression

if not len(w) or not len(tw):
if not (len(w) and len(tw)):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function ccf_astro refactored with the following changes:

  • Simplify logical expression

elif sun and model:
elif sun:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

  • Remove redundant conditional

y = wave * doppler_factor
return y
return wave * doppler_factor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function doppler_factor_shift refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -31 to +30
y = wave * (1 + beta)
return y
return wave * (1 + beta)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function doppler_shift refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -40 to +45
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, *model_params))
for a in iter_1 for b in iter_2)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, *model_params))
for a in iter_1
for b in iter_2
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function parallel_chisqr_2D refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -47 to +55
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, c, *model_params))
for a in iter_1 for b in iter_2 for c in iter_3)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, c, *model_params))
for a in iter_1
for b in iter_2
for c in iter_3
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function parallel_chisqr_3D refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -53 to +65
grid = Parallel(n_jobs=n_jobs)(delayed(chi_squared)(obs, model(a, b, c, d, *model_params))
for a in iter_1 for b in iter_2 for c in iter_3 for d in iter_4)
return grid
return Parallel(n_jobs=n_jobs)(
delayed(chi_squared)(obs, model(a, b, c, d, *model_params))
for a in iter_1
for b in iter_2
for c in iter_3
for d in iter_4
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function parallel_chisqr_4D refactored with the following changes:

  • Inline variable that is only used once

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -45 to +46
if alpha is not None:
if abs(alpha) > 0.2:
print("Warning! Alpha is outside acceptable range -0.2->0.2")
closest_alpha = alphas[np.abs(alphas - alpha).argmin()]
phoenix_glob = ("/Z{2:+4.1f}.Alpha={3:+5.2f}/*{0:05d}{1:4.2f}"
"{2:+4.1f}.Alpha={3:+5.2f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh,
closest_alpha)
else:
phoenix_glob = ("/Z{2:+4.1f}/*{0:05d}{1:4.2f}{2:+4.1f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh)
phoenix_glob = ("/Z{2:+4.1f}/*{0:05d}{1:4.2f}{2:+4.1f}.PHOENIX*.fits"
"").format(closest_teff, closest_logg, closest_feh)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function find_closest_phoenix refactored with the following changes:

  • Remove redundant conditional

s_lambda = s_amp * np.sinh(s_inner)
return s_lambda
return s_amp * np.sinh(s_inner)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function s_profile refactored with the following changes:

  • Inline variable that is only used once

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

snr = np.mean(spectra) / np.std(spectra, ddof=0)
return snr
return np.mean(spectra) / np.std(spectra, ddof=0)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function snr refactored with the following changes:

  • Inline variable that is only used once

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -44 to +43
snr = np.mean(spectra) / np.std(spectra, ddof=ddof)
return snr
return np.mean(spectra) / np.std(spectra, ddof=ddof)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function snr refactored with the following changes:

  • Inline variable that is only used once

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -38 to +37
if chip is None:
chips = range(1, 5)
else:
chips = [int(chip)]

chips = range(1, 5) if chip is None else [int(chip)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

  • Replace if statement with if expression

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

Comment on lines -72 to +71
if len(data) == 2:
fits.writeto(fitssave, norm_flux, header=hdr)
else:
fits.writeto(fitssave, norm_flux, header=hdr)
fits.writeto(fitssave, norm_flux, header=hdr)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

  • Hoist repeated code outside conditional statement

args = parser.parse_args()
return args
return parser.parse_args()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function _parser refactored with the following changes:

  • Inline variable that is only used once

@jason-neal jason-neal merged commit 8df2d6d into master Feb 15, 2024
6 of 8 checks passed
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.

2 participants