-
-
Notifications
You must be signed in to change notification settings - Fork 421
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
Quickfix to solve Issue #455 and #464 #471
Conversation
Deleted atom_data._lines and atom_data._levels This change ensures that the BasePlasma always gets prepared data. A proper fix will take more time and will be done later.
I strongly suspect that the Travis testing process will fail, at lest for the full_spectrum test. The spectra won't be bit-equal to the recorded values. You should re-calculate these tests offline, ensure that the new results are sensible and update the data files. |
@yeganer looks very good, we need to think about updating the tests. maybe grab a coffee now at ESO? |
Because they didn't call it and it's mandatory All default tests are working now. Spectral test might need updating.
There are still 3 tests failing: test_packet_output test_plasma_estimates TestPlasma.test_lte_plasma test_atomic_reprepare needs a small rewrite/fix (see comments in code)
The old files contained wrong values (see issue tardis-sn#455) With this change the following tests will run again: * test_packet_output * test_plasma_estimates * TestPlasma.test_lte_plasma One should consider updating tardis/simulation/tests/test_simulation.py since it creates a new model which essentially tests the whole codebase. These tests will always fail if something in the codebase changes ( see comment in the file ).
@wkerzendorf @unoebauer: I fixed all tests. They are running fine locally. If you could please look over the changes and run the test locally so we can be sure everything is working fine and we can merge this and finally fix the bug for master. There are still 2 Issues with the code.
Since these have nothing to do with the bug, I'll open new Issues for them. I just wanted to document them. |
@@ -58,18 +59,19 @@ class Lines(BaseAtomicDataProperty): | |||
outputs = ('lines', 'nu', 'f_lu', 'wavelength_cm') | |||
|
|||
def _filter_atomic_property(self, lines, selected_atoms): | |||
return lines[lines.atomic_number.isin(selected_atoms)] | |||
# return lines[lines.atomic_number.isin(selected_atoms)] | |||
return lines | |||
|
|||
def _set_index(self, lines): | |||
# Filtering process re-arranges the index. This re-orders it. | |||
# It seems to be important that the lines stay indexed in the correct order | |||
# so that the tau_sobolevs values are in the right order for the montecarlo | |||
# code, or it returns the wrong answer. |
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.
I would really remove the comments - this may lead to confusions in the future if somebody looks at it and doesn't remember the entire #455 discussion
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.
My reasoning behind not removing it was that someday in the future when all the filtering and atom data preparation gets implemented in the plasma part having the old functionality at hand might be useful.
But your comment reminded me that BasicAtomDataProperty definitely needs a change.
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.
Hmm - but I think that the entire idea behind the enforced re-indexing (which should only achieve compatibility between unsorted _lines and sorted lines) is no longer applicable. Moreover, the re-indexing procedure left in the comments is wrong. Given all that, I'd strongly suggest removing the comments.
Remove numpy and pytest as imports from test_plasma_simple.py as they were not needed.
Fix BaseAtomicDataProperty:calculate(): It won't try to load atom_data._<property> anymore since. This is a cleanup since atom_data._<property> doesn't exist anymore.
Apart from my concern about the comments in the Plasma part, I am happy with this PR and am in favour of merging ASAP. Opinions, @aoifeboyle, @wkerzendorf, @orbitfold? |
# reindexed = lines.reindex(lines.index) | ||
# except: | ||
# reindexed = lines.reindex(lines.index) | ||
# lines = reindexed.dropna(subset=['atomic_number']) |
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.
@unoebauer I'm fine with removing that part since you are right, it is wrong and obsolete. However i'd leave the line filtering in place and maybe add a commented part to _set_index()
which mirrors the current set_index that is done in atomic.py
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.
Fine with me.
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.
I think that is a good idea - leave the _set_index
method in there even if it doesn't do anything.
@unoebauer Could you please run the original setup where this bug first appeared and compare the output with 45eca24, just to be 100% sure. |
@@ -133,10 +133,10 @@ def pytest_report_header(config): | |||
if opts: | |||
s += "Using Astropy options: {0}.\n".format(" ".join(opts)) | |||
|
|||
if six.PY3 and (config.getini('doctest_rst') or config.option.doctest_rst): | |||
if not six.PY2 and (config.getini('doctest_rst') or config.option.doctest_rst): |
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 happening here?
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's changing the logic to treat python2 as the exception. That way this part doesn't need to be rewritten in the future once there is python 3 and python 4 around.
The old code would treat python4 the same way as python2 which would result in an undesired behavior.
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.
I wouldn't worry about Python 4. Even if it does eventually happen, I doubt compatibility issues will be handled by the six module, which is purely for compatibility issues between 2 and 3.
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.
I just ran across that and thought, why not fix it. If I run across a potential bug, is there any reason to not fix it?
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.
I'd argue the original behavior is not a bug. Either way it's a minor issue. Either way is probably fine. Just I don't think the change was really needed.
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.
okay - I think we should leave it as the old one. The only reason is that when our astropy friends will help us, they are not confused. please change it back.
@yeganer - I've added a few comments, but it is almost done. |
Changed behavior to raise a custom exception instead of a generic one. This is done to better reflect the error. Related Issues: tardis-sn#455 tardis-sn#464 Pull Request tardis-sn#471
The comments were describing the problem with the tests in this file. An issue has been created regarding this problem rendering the comments obsolete. Related Issue: tardis-sn#474
The old, commented code was wrong and got replaced with the code for a future implementation. Pull Request tardis-sn#471
@wkerzendorf I addressed most of your concerns. The only remaining issues are:
If that's settled, we can merge. |
@@ -5,7 +5,6 @@ supernova: | |||
time_explosion: 13 day | |||
|
|||
atom_data: kurucz_atom_pure_simple.h5 |
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 is fine - if as you say this is never really used we could put a dummy string in. but leave it for now.
I think checkout |
Fine by me. |
@wkerzendorf Just a second - let me do the last final check. I'd like to rerun the original #455 problem. If this passes let's merge. |
@wkerzendorf The test looks excellent: Let's merge |
Deleted atom_data._lines and atom_data._levels
This change ensures that the BasePlasma always gets prepared data.
A proper fix will take more time and will be done later.