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

DM-25373 Add Psf trampoline #532

Merged
merged 1 commit into from Jun 23, 2020
Merged

DM-25373 Add Psf trampoline #532

merged 1 commit into from Jun 23, 2020

Conversation

jmeyers314
Copy link
Contributor

No description provided.

@jmeyers314 jmeyers314 changed the title Add Psf trampoline DM-25373 Add Psf trampoline Jun 11, 2020
Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

Looks good in general, though I'd like to discuss the clone vs. cloneStorable and the Psf constructor further before approving.

include/lsst/afw/detection/Psf.h Outdated Show resolved Hide resolved
include/lsst/afw/detection/python.h Outdated Show resolved Hide resolved
include/lsst/afw/detection/python.h Outdated Show resolved Hide resolved
python/lsst/afw/detection/_psf.cc Outdated Show resolved Hide resolved
python/lsst/afw/detection/_psf.cc Outdated Show resolved Hide resolved
tests/test_psf_trampoline.py Outdated Show resolved Hide resolved
tests/test_psf_trampoline.py Outdated Show resolved Hide resolved
tests/test_psf_trampoline.py Outdated Show resolved Hide resolved
@jmeyers314
Copy link
Contributor Author

Looks good in general, though I'd like to discuss the clone vs. cloneStorable and the Psf constructor further before approving.

Thanks, @kfindeisen . I think I've addressed most of your comments now; though still thinking about clone/cloneStorable/__deepcopy__. I added a fixit commit here if you want to take a look (I'll squash it before merging to master).

One additional thing that occurred to me though is that I probably need to follow the instructions for inheriting from Persistable too. I suppose this would mean a few more trampolines for either Persistable or maybe PersistableFacade<>, and probably for PersistableFactory too. Does that sound right?

@kfindeisen
Copy link
Member

kfindeisen commented Jun 15, 2020

I'd recommend against it. PersistableFacade has some problems with pybind11 because it tries to have covariant input types; this is particularly true if you have multiple PersistableFacade instantiations in the inheritance tree. More generally, Persistable is fundamentally incompatible with Python (for reasons I don't quite recall, but @TallJimbo probably does), so there's no point supporting Python implementations of it.

Copy link
Member

@kfindeisen kfindeisen left a comment

Choose a reason for hiding this comment

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

Looks good, though I'd like a bit more documentation.

include/lsst/afw/detection/python.h Outdated Show resolved Hide resolved
python/lsst/afw/detection/_psf.cc Outdated Show resolved Hide resolved
tests/test_psf_trampoline.py Show resolved Hide resolved
@jmeyers314
Copy link
Contributor Author

I'd recommend against it. PersistableFacade has some problems with pybind11 because it tries to have covariant input types; this is particularly true if you have multiple PersistableFacade instantiations in the inheritance tree. More generally, Persistable is fundamentally incompatible with Python (for reasons I don't quite recall, but @TallJimbo probably does), so there's no point supporting Python implementations of it.

Hmm... Is this going to cause a problem? I'm not familiar enough to know, but I would have guessed that say, CoaddPsf persistence is implemented via the persistence of its constituents. If that's true, then does this mean pure-python Psfs cannot be persisted as part of a CoaddPsf?

@TallJimbo
Copy link
Member

does this mean pure-python Psfs cannot be persisted as part of a CoaddPsf?

That's correct, and yes, that's definitely going to be a problem at some point. I don't know what the best approach is going to be, but it shouldn't get in the way of this ticket, at least.

@jmeyers314
Copy link
Contributor Author

That's correct, and yes, that's definitely going to be a problem at some point. I don't know what the best approach is going to be, but it shouldn't get in the way of this ticket, at least.

I wonder if I can define write in the trampoline class and then access it in python via super() maybe? But point taken, won't delay this ticket on this account.

@TallJimbo
Copy link
Member

The main problem is that all of the other classes that any afw::table::io::Persistable implementation would need to use are not wrapped for Python, and I've never looked hard at what it would take to wrap them; I suspect it would require at least some changes to how the C++ works.

The trampoline class enables subclasses of lsst.afw.detection.Psf
to be created in python.
@jmeyers314 jmeyers314 merged commit f994031 into master Jun 23, 2020
@timj timj deleted the tickets/DM-25373 branch February 18, 2021 00:00
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.

None yet

3 participants