Repository navigation
Subhalo-based phase space model for satellites - #637
Conversation
|
@aphearin - I've tried to investigate but the building process dies earlier, and the tests don't even start up. I'll try to look at it again tomorrow. |
|
Thanks @bsipocz. Very briefly, for context, this is an integration test in which I create a Monte Carlo realization of a galaxy population, where the population is stored in an Astropy Table called |
|
Something must have changed in the last two months since the last tests run on halotools ;) Joke aside, I'll have a look at it tomorrow. Also for the long term, I think it will be useful to have a cron job travis (which is a new thing) run ~weekly for halotools, so these failures are spotted sooner. I'm testing some enhancements with ci-helpers, so it will also be possible just to run a few builds that are using dependencies that can change rapidly, e.g. the ones with astropy or numpy dev. I'll keep you posted. |
|
I think that's a good idea. My own development cycle will always be intermittent, since I switch back and forth between implementing new features and then using them for science. Let me know if I can help with implementing the travis cron job. |
|
@aphearin - Could you restart the failing travis builds? Locally, using astropy dev, everything works for me, all the tests pass, so probably there was some last minute merge for 1.3 that did the trick. |
|
Also, $EVENT_TYPE was introduced as an env variable for ci-helpers, so you can define builds to run only in for certain job types, e.g. only from cron, or for merge/pushes or for PRs, etc. I'm not sure how useful it is for halotools, but maybe it is. |
|
@aphearin - My apologies, I though I was testing with latest master, but I was rather on one of my feature branches (branched from a6dcf8b87c89b6e7c8d54001181dba7c32056a52). Now with latest master I see the same error. Meaning that the regression is coming from one of these pull requests: |
|
I'm almost 100% sure that the regression is coming from here astropy/astropy#5556 |
|
That does indeed look like a very likely candidate, @bsipocz. The potentially "problematic" example given by @taldcroft at the end of astropy/astropy#5556 looks extremely similar to the form of the statement that fails in this PR. |
|
@aphearin - from the test failure report I can't quite see the part of your code that was affected by #5556. I am worried about these kind of regressions so any explanation would be appreciated. |
|
@taldcroft - I'm not positive that #5556 is responsible, but it looks quite similar. The assertion in my test suite that fails is the following: Does that help? Let me know if I can provide more context or answer other specifics. |
|
@aphearin - Yesterday I went through those PR merges on astropy dev. The first point when the fail appeared was for 5556, so I'm quite positive it's the source of it. |
|
Ok @bsipocz - can you maybe briefly describe what specific change to the Table behavior I should be aware of so that I can make the modifications? When you were going through the code, what sorts of changes were you trying out? From the description on 5556 it was not clear to me, especially since this change only impacted a single line of code in the entire repo. |
|
@aphearin - what you should be looking for are places where you update table column data in place. That is the only change, where something like So we were concerned about merging #5556, and if it turns out that subtle problems are common then I might consider backing it out before the release. So your investigation now is especially timely and helpful. I think that on the whole #5556 is a good thing (e.g. pandas behaves this way), but we don't want to cause tricky breakage problems. |
|
@aphearin - I were exactly looking for cases @taldcroft mentions, where you update columns of e.g. |
|
I'll look into this asap, @bsipocz and @taldcroft. I'm quite concerned, actually. It sounds like a pretty serious undertaking that will affect hundreds of lines distributed throughout the code base in a way that cannot be fixed in an automated fashion. |
|
So I was able to resolve the bug using the syntax change suggested by @taldcroft - but I'm concerned I just got lucky as there are many, many places throughout the repo where things could have gone wrong. What concerns me even more is how "silent" this Table-related bug is - users building their own Halotools models will have to be aware of this specific in-place syntax or they will get crazy results that do not raise exceptions. So FYI, I'm going to leave this open for the time being while I revisit the many places this sort of problem may occur. |
|
@aphearin - in this case is the problem related to lost meta data or a lost reference? Those are the only two reasons I'm aware of that a problem could arise. |
|
In looking at the code I can't immediately see why there was a failure in the test. In any case I appreciate that this could be confusing... grr. One thing that might be useful is to insert statements to print the column before and after the update using the original syntax (without |
|
@taldcroft - I still don't understand why the tests fail either, partly because I myself have not yet installed the dev-branch of astropy and done inspections like the one you suggest. Here's a high-level explanation of what is going on in the code. There is a container class (the HodModelFactory) that is responsible for collecting a set of functions defined in independently-written component classes. The container class is responsible for passing the appropriate Table slice to each component class. So, in the example here, the |
|
I installed halotools and did some playing around with the code itself. I can't follow the logic between the code where you added The problems would make sense if there was a table slice happening at some point to create in-memory references of columns that subsequently get broken. For example, before #5556: After #5556 the value of t['a'] is unaffected when |
|
Yes @taldcroft, that is precisely what is going on. A slice of the galaxy_table is created and passed to the function, then the values in the slice are (should be) over-written. This is exactly what is going on, nice detective work. |
…e is explicitly modified in-place in accord with astropy/astropy#5556. This change has previously been brought as part of astropy#637 by b28fe15. However, as that PR is entirely unrelated to this bugfix, astropy#637 will instead be rebased against this commit for clarity. Merging this PR will also resolve the test failures that occur in astropy#638. @bsipocz and/or @eteq - let me know if you know how to handle the git rewrite in a more elegant way (e.g., rolling back b28fe15), otherwise I'm fine with simply locally rebasing astropy#637, locally resolving the conflict, and then force-pushing astropy#637.
b28fe15 to
72a5eae
Compare
This commit also resolves the following bug: the preprocess_subhalo_table method of SubhaloPhaseSpace was actually over-writing the subhalo_table_sorting_keys list before conducting the sort, and so the intra_halo_sorting_key was being entirely ignored. @johannesulf - I'd like to merge this PR into master and include this in the v0.5 release, especially since you are using this class in your next publication. Please try swapping out this new version with your own private one and verify that you get the same science results.
This PR introduces the SubhaloPhaseSpace class to HOD profile modeling. Briefly, using this class subhalo positions and velocities can be chosen for HOD/CLF satellites, as opposed to analytical relations.
This initial PR is currently just for testing and is unfinished as the
reverse_orderoption still needs to be implemented, as discussed with @johannesulf.