forked from jeff-regier/Celeste.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Config object to faciliate passing params deep into the call chain
As discucsed in PR jeff-regier#538, we have this problem of passing arguments deep down the call stack of Celeste inference. This manifests itself as lots of chains of keyword arguments and various not-so-pretty hacks (like custom `infer_source_callback` wrappers) to set options. The discussion in jeff-regier#538 outlines a broad direction for not only solving this problem, but also the related problem of different branches of code for different options at each stage of inference. The two current examples are single vs. joint inference and MOG vs. FFT PSF inference, but there will likely always be such branches. I still think that's a good direction to go, but even a minimal implementation is too invasive to be safe/worthwhile right now. Instead, this commit takes what I view as the simplest possible step in the right direction. We add a single `Config` object which is instantiated at top-level and passed as the first argument through all major function calls. Over time this object ought to absorb more parameters. Once there are distinct groups of parameters, the object can be split into multiple objects, and functions can receive only the sub-Config-object they require. Dynamic dispatch of different types of sub-Config-objects can follow from that. (If this doesn't make sense, read the example in jeff-regier#538.) The change looks a little silly right now, since it's this config object with one parameter, but it's an incremental path. There are a lot of legacy wrappers included which instantiate the default Config object, so I don't have to go change every top-level caller (in which case I'd likely break something because I'm not familiar with much of the code), but over time callers ought to be changed to explicitly pass a Config object, and the legacy wrappers can go away.
- Loading branch information
1 parent
15a3605
commit 31b704a
Showing
15 changed files
with
179 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Configs | ||
|
||
type Config | ||
# A minimum pixel radius to be included around each source. | ||
min_radius_pix::Float64 | ||
|
||
function Config() | ||
config = new() | ||
config.min_radius_pix = 8.0 | ||
config | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.