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

Quickfix to solve Issue #455 and #464 #471

Merged
merged 11 commits into from
Feb 3, 2016

Conversation

yeganer
Copy link
Contributor

@yeganer yeganer commented Feb 1, 2016

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.

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.
@unoebauer
Copy link
Contributor

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.

@wkerzendorf
Copy link
Member

@yeganer looks very good, we need to think about updating the tests. maybe grab a coffee now at ESO?

yeganer added 3 commits February 1, 2016 15:43
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 ).
@yeganer
Copy link
Contributor Author

yeganer commented Feb 2, 2016

@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.

  • test_atomic.py:test_atomic_reprepare() should be rewritten and the logic should be changed( see comment in code) to check for len(lines) == N and not if len(lines) > 0.
  • test_simulation.py seems like a "small" version of a full tardis test to me. Either move the logic ( comparing nubar, t_rad, w, j_est) to test_tardis_full.py or load a fixed model with a known plasma state and run the simulation on that. The current implementation will fail on any change in the codebase, whether it is in plasma, atomic, montecarlo or somewhere else. In that case the bug would be catched by test_tardis_full.py anyway.

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.
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

yeganer added 2 commits February 2, 2016 15:32
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.
@unoebauer
Copy link
Contributor

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'])
Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Fine with me.

Copy link
Member

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.

@yeganer
Copy link
Contributor Author

yeganer commented Feb 2, 2016

@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):
Copy link
Member

Choose a reason for hiding this comment

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

what's happening here?

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Member

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.

@wkerzendorf
Copy link
Member

@yeganer - I've added a few comments, but it is almost done.

yeganer added 3 commits February 3, 2016 13:45
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
@yeganer
Copy link
Contributor Author

yeganer commented Feb 3, 2016

@wkerzendorf I addressed most of your concerns. The only remaining issues are:

  • verysimpleconfig.yaml restore original behavior?
  • PY2/PY3 restore original behavior?

If that's settled, we can merge.

@@ -5,7 +5,6 @@ supernova:
time_explosion: 13 day

atom_data: kurucz_atom_pure_simple.h5
Copy link
Member

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.

@wkerzendorf
Copy link
Member

I think checkout conftest.py and then merge from my side.
@orbitfold - do you agree to merge?
@unoebauer - do you agree to merge?

@orbitfold
Copy link
Contributor

Fine by me.

@unoebauer
Copy link
Contributor

@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.

@unoebauer
Copy link
Contributor

@wkerzendorf The test looks excellent:
virt_spec_cmp

Let's merge

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.

4 participants