-
Notifications
You must be signed in to change notification settings - Fork 103
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
Moves msgs into pypit/__init__.py #310
Conversation
Moves msgs object to __init__.py, and propagates the fall-out from this change.
It looks like there are some bugs here I need to fix in the tests. Let me try to figure this out before you review it. |
The travis errors are when the setup.py file is trying to import something from within pypit and it ends up creating a circular import (I think). I know virtually nothing about setup.py files, but is this a good idea? I.e., do we want the setup.py file to import anything from pypit? I'm not sure what the best practice is here. |
Good idea to move the version check into The current error seems to be that you're not importing scipy at the top of the file. Perhaps, in |
Do'h! Yeah, stupid bug on my part. I just added scipy for now to see if travis still fails (and it does...). Right, one of things that I thought of suggesting was to clean up setup.py. I was putting this off because, like I said, I'm not really comfortable editing setup.py files yet, and I wanted to hold off, again, until all the cython is removed. My point of reference, again, is MaNGA's Marvin package: https://github.com/sdss/marvin/blob/master/setup.py There, they use a text file to set the requirements (requirements.txt). They don't check these versions themselves within the code; they become part of the installation process using the So maybe given that travis is failing, this change to the setup.py files is more pressing. Let me know what you think and I can try to fix this today/tomorrow. |
This sounds good to me. PYPIT's setup.py file is currently based on the DESI pipeline (@profxj wrote this, maybe he can correct me if I'm mistaken?). In any case, if using a different style of setup.py file does the trick, I'm happy with that! I guess now's the time to do it, since we're also ditching cython. |
I am fully supportive of over-hauling setup.py The current Travis failure is odd. I've added an explicit install As for the requirements, I might prefer that they simply be checked |
Scanning the great internet, I don't see a way to check for As such, we might want to fall back to using something like |
Regarding 'close_qa', @kbwestfall is correct |
ok, I've made chk_requirements a method in setup.py Now back to the arclines failures in Travis.. |
Okay, there are a number of balls in the air so let me try to summarize:
|
|
|
Here is a compromise on the QA/HTML: The only bits I want done when the code crashes I somewhat prefer all the QA methods being in one module |
Ok, after spending my own time in circular import hell |
ok, passing tests now. Am going to |
Awesome! Sorry for all the hassle. Hopefully it's a step in the right direction. A few thoughts:
|
This is looking much better - a huge step in the right direction! I think it's worthwhile at this point either closing or discussing arclines Issue 26 Given that we're hoping to modularise PYPIT, perhaps it makes sense to merge arclines into PYPIT? |
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.
Ok, I've made my more formal pass.
We can discuss my comments tomorrow.
CHANGES.rst
Outdated
* Removed majority of cython functionality | ||
* Moved logging to be a package object using the main __init__.py file | ||
* Begin to adhere to PEP8 (mostly) | ||
* setup.py rewritten. Modeled after https://github.com/sdss/marvin/blob/master/setup.py . Added requirements.txt with the package versions required. | ||
|
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.
Add:
-- Updates archeck
-- Loads NIST arclines from arclines instead of PYPIT
@@ -304,7 +305,7 @@ def median_ratio_flux(spec, smask, ispec, iref, nsig=3., niter=5, **kwargs): | |||
# Ratio | |||
med_flux = fluxes[iref,allok] / fluxes[ispec,allok] | |||
# Clip | |||
mn_scale, med_scale, std_scale = sigma_clipped_stats(med_flux, sigma=nsig, iters=niter, **kwargs) | |||
mn_scale, med_scale, std_scale = astropy.stats.sigma_clipped_stats(med_flux, sigma=nsig, iters=niter, **kwargs) |
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.
Was this another circular import?
Just checking..
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, not a circular import. Just a syntax preference. The module loads both scipy.stats and astropy.stats, so I just wanted to be clear where this comes from.
pypit/ardebug.py
Outdated
# These need to be outside of the def's | ||
from pypit.ginga import show_image | ||
from pypit.ginga import chk_arc_tilts | ||
#from pypit.ginga import show_image |
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.
Is this a circular imports issue?
These changes would reduce the ease-of-use
of this debugger..
Let's discuss.
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 I commented these out because they're not actually used in the module itself. Are you importing them here because they get used when debugger is imported?
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.
yes, that is the intent.
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.
Ah, got it. I just saw how this is used in artrace.py . We can leave it that way if you want, but I'm not crazy about the construction. E.g., why are ginga.py and ardebug.py separate modules? In the one place chk_arc_tilts() is used (artrace.py) the module actually imports ginga as well (although that's probably because I moved all the imports to the top), so why not use it directly from ginga?
skyframe=skyframe, objframe=obj_model) | ||
# Return | ||
return newvar | ||
|
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.
Ok, I think that makes good sense.
merging! |
This PR moves the msgs object in the
pypit/__init__.py
file. For most files, the only change was to usefrom pypit import msgs
instead ofBut I also had to make a number of changes to the main
PYPIT
function and thearmsgs.Messages
class to get this to work. A bit of a headache was to allow for thearmsgs.Messages
object to close the QA files. Forcing all the imports to the top of the file led to a circular import. What I have in place works, but I had to change the importfrom pypit.arqa import get_dimen, set_qa_filename
in pypit/arpca.py tofrom pypit import arqa
; otherwise, I was getting an error. This probably means that you always have to use this format; i.e., you can't callfrom pypit.arqa import ...
without getting an error, which is not ideal.So I think the larger question is do we really need
armsgs.Messages.close
to access and run the consolidated functionarqa.close_qa
? As far as I can tell, the function isn't closing already open QA files. Is it critical that these QA functions be run when an error is called and/or someone pressed 'ctrl+c'?I also made some style changes to enforce PEP 8 in the files that I touched.