-
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.
ENH enable gsobjects from eval (#20)
- Loading branch information
Showing
6 changed files
with
44 additions
and
1 deletion.
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,10 @@ | ||
import galsim | ||
|
||
|
||
def EvalGSObject(config, base, ignore, gsparams, logger): | ||
req = {'str': str} | ||
params, safe = galsim.config.GetAllParams(config, base, req=req, ignore=ignore) | ||
return galsim.utilities.math_eval(params['str']).withGSParams(**gsparams), safe | ||
|
||
|
||
galsim.config.RegisterObjectType('Eval', EvalGSObject) |
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,16 @@ | ||
import galsim | ||
import numpy as np | ||
|
||
|
||
def test_build_gsobject_evalrepr(): | ||
g = galsim.Gaussian(fwhm=1.0).drawImage(nx=25, ny=25, scale=0.263) | ||
ii = galsim.InterpolatedImage(g, x_interpolant='lanczos15') | ||
with np.printoptions(threshold=np.inf, precision=32): | ||
r = repr(ii) | ||
cfg = { | ||
"type": "Eval", | ||
"str": r.replace("array(", "np.array("), | ||
} | ||
rii, safe = galsim.config.BuildGSObject({'blah': cfg}, 'blah') | ||
assert safe | ||
assert rii == ii |
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,2 @@ | ||
# Allow lines to be as long as 120 characters. | ||
line-length = 120 |