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

Make decoder.py generic to the astronomical objects being rendered #688

Closed
dereklhansen opened this issue Sep 15, 2022 · 0 comments · Fixed by #807
Closed

Make decoder.py generic to the astronomical objects being rendered #688

dereklhansen opened this issue Sep 15, 2022 · 0 comments · Fixed by #807
Assignees
Labels
refactoring refactoring code or quick fixes.

Comments

@dereklhansen
Copy link
Contributor

dereklhansen commented Sep 15, 2022

With the addition of the galaxy lensing to decoder.py, I think it makes sense to refactor Decoder._render_ptiles() to not hard-code each different object ("star", "galaxy", "lensed_galaxy").

def _render_ptiles(self, tile_catalog: TileCatalog) -> Tensor:

I propose something like this:

    def _render_ptiles(self, tile_catalog: TileCatalog) -> Tensor:
        all_objects_list = []
        for renderer in self.renderers: #stars, galaxys, lensed_galaxies, etc
             centered_object_imgs = renderer(tile_catalog)
             objects_imgs = self.tiler.forward(tile_catalog.locs, centered_objects)
             all_objects_list.append(objects_imgs)
        return sum(all_objects_list)
    ...
    def __init__(...):
          self.renderers = []
@dereklhansen dereklhansen added the refactoring refactoring code or quick fixes. label Sep 15, 2022
@jeff-regier jeff-regier self-assigned this Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring refactoring code or quick fixes.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants