Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Import cross sections from csv #41
base: master
Are you sure you want to change the base?
Import cross sections from csv #41
Changes from 23 commits
0a0270c
d5c8552
553738f
5300d62
dab091b
d69d61b
7984c15
66b1c6f
4fdafa7
dca2d49
eb079f6
8190183
946efaa
cd0f3c0
8f48e5e
a959150
067c289
a621ab0
13911d0
4fb993d
cd4dc0e
5c9c31c
b138c4b
bb8a526
5cdb67b
39651d5
a2441b5
f59b50a
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to do this is
if reference in ('Scofield', 'Yeh')
. What you have is fine here, but the other way is worth knowing if there are more options to compare 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another nice trick which is used elsewhere in the code is
if reference.lower() in ('scofield', 'yeh')
; this makes it case-insensitive so our user doesn't have to mess around with shift keys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow PEP8 guidelines for spacing around
,
and=
, it makes the code easier to read.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wording can be a bit firmer here, and it's also useful to give feedback. e.g.
f"Reference '{reference}' was not recognised. Accepted values are 'Scofield' and 'Yeh'."
This can make it clearer if the user made a typo or a script inserted the wrong value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new argument needs to be included in the docstring below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is recommended in PEP8 that we always compare to
None
usingis
, i.e.(This is because in principle some maniac could be using a custom class/object which
== None
!)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
float(weighting)
? It makes sense to turn energy into a number while it's being renamed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of
_
for unused return values 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for
== True
;isfile()
already returns a True/False that will make sense toif
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the significance of the
1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be a good idea to clarify that this is because the file was not found. It might be that the user did install data but there is some other issue with paths.
Also,
print
is likely not the best option here; in Galore we generally uselogging
instead. Or would it make more sense in this case to raise an error? What happens when other invalid values are used?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the requested energy is nowhere near a value in the table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessarily the correct data to use. We want the "highest" orbital from 1s, 2s, 3s... which is not necessarily the one with the largest scattering cross section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider making these comparisons case-insensitive with e.g.
if dataset.lower() == 'scofield'
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if somebody wants to update to a corrected newer version?
If we don't provide some kind of
force=True
option, it would be helpful to print where the file exists so it can be examined/deleted.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this
except
catching? "Bare" exceptions like this can catch any error, including ones we don't expect. It's best to be very specific about which exceptions are ok to ignore.