-
Notifications
You must be signed in to change notification settings - Fork 107
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
Big Image class overhaul -- #82, #114, #117, #123, #124, #125 #128
Conversation
Minor correction about the new draw syntax. If you omit the image argument, then
This is because the arguments are actually:
as suggested by Jim. If So you can omit the |
Just a quick note: everything compiles fine and all tests pass on my machine. Will go through code etc. tonight / tomorrow... |
…ses to make im3 = im1 + im2 and similar more efficient. (#117)
I forgot that I'd meant to implement the C++ arithmetic using composite classes to delay the calculation and thus save an inefficient copy. So I just added this functionality. This method also makes it easy to implement the mixed-type arithmetic, so I did that too. I haven't written any C++ unit tests for this yet, but I really should, since the python unit tests don't test these functions considering that the python layer implements the arithmetic using numpy, rather than calling the C++ functions. |
Hi Mike - Barney and I just went through part of this. First, a few comments:
A question which we're happy to discuss more on the phone - I'm putting this here mainly so others have a chance to chime in, but if we talk about it on the phone then one of us can summarize the answer here laterL We had thought that the choice of which is an More later - |
@joergdietrich , would you be willing to try compiling and running the tests on "the little Linux box that could (find subtle system-dependent issues)"? :) @gbernstein and @TallJimbo , given the size of this overhaul, we'd like your feedback before merging. |
Barney, Mike, and I just got off the phone, and I'm going to try to summarize the answers to the questions / comments above (but please correct me if I get something wrong...):
|
I have one error:
BTW, this little Linux box will stay behind in Michigan when I will move to Munich in June. |
Joerg, I think I might have fixed the error you found. Please git pull and try again. |
The error persists. |
Shame that little Linux box won't still be around come June; it's useful...! I did my own test, on the constness of the
So I think that what is implemented is working correctly, independently of whether we want to keep the ConstImageView available at the Python layer. I can't think of a very strong reason to be rid of it... We might want to label some of our internals as inviolable and produce a runtime error Exception if anyone attempts to change them (the OpticalPSF lookup tables for instance, or the RealGalaxy images from COSMOS). What I will do, however, is add a quick unit test just to check that we are getting a RuntimeError if attempting the above on all systems - would be nice to know that this behaviour is consistent! |
… since scons has no way of realizing it.
…t data type' error
I'm not sure why that error is persisting. Is it on the same line still? Anyway, I added some diagnostic information to be printed along with the error to help figure out what the conflict is exactly. So please do another git pull and tell me what the error is now. |
I think Jim's comment was probably right. And after committing a change that might have worked, I actually decided to go with a whole different tack, which is to switch the instantiation types of Image from short and int to int16_t and int32_t. I was thinking about why we might want to have integer Images, and it's probably mostly to be compatible with reading such from fits files. In that case, we will want the image to match up with the type in the fits file, which are almost certainly going to be 16 and 32 bit integers. So the right solution is to force C++ to use those sizes too, rather than whatever it might call an int. I'm hoping that the python's int16 and int32 will always match C++'s int16_t and int32_t, but I can't say that I have a huge amount of confidence in this fact, so I guess we'll see. :) Anyway, give it a try Jörg, and see if this works for you. |
And if this doesn't work, I'm fine with merging and making a new issue about it. No sense it holding up other work until this gets straightened out. |
We keep progressing from bad to worse. Now it doesn't even build:
|
Well, in general I call that progress. I'd much rather find problems at compile time than have the compile work, but let problems lurk until some random time at run time. But anyway, this means that npy_int32 is not the same type as int32_t. One's probably a typedef of long and the other of int. That's unfortunate. I was hoping the numpy people would have make those sync up, but I guess not. Anyway, I've now instantiated the NumPyTraits struct for int32_t rather than npy_int32, so it should compile now. I guess we'll see if it runs. |
And we probably need to fill the Image dictionary with the npy_ types, so I just did that too. Which makes me think that I probably need to put the Normalize stuff back in. So hold off a couple minutes before trying this. |
That is weird, I don't get the compilation error... |
It would only be on systems where int == long. Unfortunately, I don't have one of those to test on... |
OK, give it a try now. |
another build error:
|
OK. Here's another attempt. I got rid of the |
Builds and passes all tests. Thanks a lot Mike. |
Phew. Finally. :) Good. |
Fantastic. Let's leave it overnight for any further comments, and then we can merge in the morning. |
Barney just resolved some comments, and I've confirmed that everything still builds and all tests pass, so I'm going to merge now. Thanks, Mike, for the tremendous job on this significant reworking of the Image class! (and I think you win the award for "most issues resolved with a single pull request") I'll go through and close / comment on the various issues as appropriate. |
I think my big Image overhaul is ready for code review.
redefine
method which Gary pointed out problematic, and Jim himself described as dangerous.setValue
method as a way to set pixel values in python.move
method tosetOrigin
.setCenter
method for convenience.copyFrom
and all arithmetic ops to expect images to be the same shape, but not necessarily the same origin. The old behavior was to act on the overlap of the two bounds. The old behavior can be recovered byim[im.bounds & im2.bounds] = im2[im.bounds & im2.bounds]
which is probably clearer as to the intent.draw(im,dx,wmult)
in addition toim = draw(dx,wmult)
in python.im[bounds] = im2
syntax for sub-images plus a bunch of unit tests to check this syntax does the right thing.