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

Changed to fstring #1706

Merged
merged 5 commits into from
Dec 8, 2021
Merged

Changed to fstring #1706

merged 5 commits into from
Dec 8, 2021

Conversation

svenkat19
Copy link
Contributor

Description
<Changed strings to fstrings in python 3>

Motivation and context

How has this been tested?

  • Testing pipeline.
  • [ x] Other.

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • [x ] None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@andrewfullard andrewfullard linked an issue Jul 12, 2021 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jul 12, 2021

Codecov Report

Merging #1706 (ae4e954) into master (7d3899e) will increase coverage by 0.81%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1706      +/-   ##
==========================================
+ Coverage   61.06%   61.87%   +0.81%     
==========================================
  Files          63       63              
  Lines        5820     5852      +32     
==========================================
+ Hits         3554     3621      +67     
+ Misses       2266     2231      -35     
Impacted Files Coverage Δ
tardis/tardis/io/atom_data/base.py 89.77% <0.00%> (-1.51%) ⬇️
tardis/tardis/util/base.py 74.35% <0.00%> (-1.44%) ⬇️
tardis/tardis/base.py 57.69% <0.00%> (-1.40%) ⬇️
...s/tardis/plasma/properties/radiative_properties.py 77.18% <0.00%> (-0.53%) ⬇️
tardis/tardis/io/util.py 71.67% <0.00%> (-0.52%) ⬇️
tardis/tardis/simulation/base.py 82.88% <0.00%> (-0.45%) ⬇️
tardis/tardis/plasma/properties/nlte.py 38.83% <0.00%> (-0.39%) ⬇️
tardis/tardis/analysis.py 30.16% <0.00%> (ø)
tardis/tardis/montecarlo/base.py 88.77% <0.00%> (ø)
tardis/tardis/util/colored_logger.py
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7d3899e...ae4e954. Read the comment docs.

self.current_no_packets,
self.last_line_list_in.ix[event.ind],
)
f"Line_in ({len(event.ind)}/{self.current_no_packets}):\n{self.last_line_list_in.ix[event.ind]}"
Copy link
Member

Choose a reason for hiding this comment

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

please be PEP8 compliant

Copy link
Contributor

@DhruvSondhi DhruvSondhi left a comment

Choose a reason for hiding this comment

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

Thank you @svenkat19, for the Pull Request. I have requested some changes else everything seems to be on the right track.

"wavelength"
],
)
f"{key[0]}-{key[1]} {self.parent.model.atom_data.lines.ix[value[0]]["wavelength"]}"
Copy link
Contributor

Choose a reason for hiding this comment

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

The appended statement here has been changed. Please check that the statements adhere to their original intended meaning.

Suggested change
f"{key[0]}-{key[1]} {self.parent.model.atom_data.lines.ix[value[0]]["wavelength"]}"
f"{key[0]}-{key[1]} {self.parent.model.atom_data.lines.ix[value[0]]["wavelength"]:.2f} A"

@@ -1225,7 +1214,7 @@ def on_species_clicked(self, index):
last_line_in_model = self.createTable(
[
last_line_in_string,
["Num. pkts %d" % current_last_line_in.wavelength.count()],
[f"Num. pkts {current_last_line_in.wavelength.count()}" ],
Copy link
Contributor

Choose a reason for hiding this comment

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

Extra space after the ending " can be removed.

"The following columns are specified in the csvy"
"model file, but are IGNORED by TARDIS: %s"
% (str(unsupported_columns))
f"The following columns are specified in the csvy model file, but are IGNORED by TARDIS: {str(unsupported_columns)}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please adhere to the Black formatting styling. This seems to be off here in terms of the formatting of the message under the logger.warning

@svenkat19
Copy link
Contributor Author

Thank you @svenkat19, for the Pull Request. I have requested some changes else everything seems to be on the right track.

Could you please go through and let me know if I must change anything else? Cheers :)

Copy link
Contributor

@DhruvSondhi DhruvSondhi left a comment

Choose a reason for hiding this comment

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

Please check these comments. Otherwise, it looks Good to me 🚀.

@@ -262,7 +254,7 @@ def load_t_inner(self, iterations=None):

for iter in iterations:
t_inners.append(
hdf_store["model%03d/configuration" % iter].ix["t_inner"]
hdf_store[f"model{iter:003d}/configuration"].ix["t_inner"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why has there been a change in the string formatting? What I mean is why is it 003d instead of 03d?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why has there been a change in the string formatting? What I mean is why is it 003d instead of 03d?

This has got to be the silliest error done by me😅. Do let me know if there are any mistakes I must fix. Cheers !!

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, Everything else seems to be Awesome. These things can be overlooked easily that's why I raised it here. Thank you for making the required changes 😄

@@ -281,8 +273,8 @@ def load_t_rads(self, iterations=None):
iterations = self.iterations[iterations]

for iter in iterations:
current_iter = "iter%03d" % iter
t_rads_dict[current_iter] = hdf_store["model%03d/t_rads" % iter]
current_iter = f"iter{iter:003d}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Check the previous comment.

@@ -319,7 +311,7 @@ def load_level_populations(self, iterations=None):
iterations = self.iterations[iterations]

for iter in iterations:
current_iter = "iter%03d" % iter
current_iter = f"iter{iter:003d}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here 🤔

@@ -381,7 +373,7 @@ def load_spectrum(self, iteration, spectrum_keyword="luminosity_density"):
hdf_store = pd.HDFStore(self.hdf5_fname, "r")

spectrum = hdf_store[
"model%03d/%s" % (self.iterations[iteration], spectrum_keyword)
f"model{self.iterations[iteration]:003d}/{spectrum_keyword}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@@ -426,7 +418,7 @@ def get_last_line_interaction(self, iteration=-1):
self.load_atom_data()

hdf_store = pd.HDFStore(self.hdf5_fname, "r")
model_string = "model" + ("%03d" % iteration) + "/%s"
model_string = "model" + (f"{iteration:003d}" ) + "/%s"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

@DhruvSondhi
Copy link
Contributor

Please do fix the tests that are failing. If you have any problems regarding the same, please do let us know 😄

Copy link
Member

@wkerzendorf wkerzendorf left a comment

Choose a reason for hiding this comment

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

please fix the PEP8 violations

@wkerzendorf wkerzendorf merged commit 59c7f87 into tardis-sn:master Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert Old Python 2 String formatting into Python 3
5 participants