Comments (2)
I tend to avoid using bp::optional<>
(and the BOOST_PYTHON_FUNCTION_OVERLOADS macros) for exactly this reason, even though it's what you'll find in the Boost.Python tutorial.
Instead you can duplicate the default values when telling Boost.Python about the keyword arguments; in this case, that's
(bp::arg("u_"), bp::arg("mean")=0., bp::arg("sigma")=1.)
The downside is that you have to put the defaults in two places and keep them in sync. The upside is that keyword arguments now work just like they do in Python.
By the way, I tend to also rename C++ arguments sometimes when specifying the Python keyword arguments. In C++, the argument names aren't used by the caller, and they can have funny names for technical reasons (like u_ instead of u). We don't have to make them the same in both places, and I'd recommend changing the Python keyword argument in this case to something more descriptive (e.g. "uniform"), or at least dropping the _.
from galsim.
Hi Jim,
Great, thanks!
On 28 Mar 2012, at 09:30, Jim Bosch wrote:
I tend to avoid using
bp::optional<>
(and the BOOST_PYTHON_FUNCTION_OVERLOADS macros) for exactly this reason, even though it's what you'll find in the Boost.Python tutorial.Instead you can duplicate the default values when telling Boost.Python about the keyword arguments; in this case, that's
(bp::arg("u_"), bp::arg("mean")=0., bp::arg("sigma")=1.)
The downside is that you have to put the defaults in two places and keep them in sync. The upside is that keyword arguments now work just like they do in Python.
By the way, I tend to also rename C++ arguments sometimes when specifying the Python keyword arguments. In C++, the argument names aren't used by the caller, and they can have funny names for technical reasons (like "u_" instead of "u"). We don't have to make them the same in both places, and I'd recommend changing the Python keyword argument in this case to something more descriptive (e.g. "uniform"), or at least dropping the "_".
Reply to this email directly or view it on GitHub:
#58 (comment)
Barnaby Rowe
Jet Propulsion Laboratory
California Institute of Technology
MS 169-237
4800 Oak Grove Drive
Pasadena CA 91109
United States of America
Department of Physics & Astronomy
University College London
Gower Street
London WC1E 6BT
United Kingdom
from galsim.
Related Issues (20)
- pip install on Colab fails HOT 7
- Galsim Convolution vs scipy fftconvolve HOT 11
- Compile failure with conda compiler on macos HOT 5
- Build wheel error HOT 3
- Constant galsim.SED fails to broadcast over wave
- Can't photon shoot simple chromatic transformation HOT 1
- Small Discrepancy between Real and Fourier Space Shift HOT 4
- Colab install failed error: metadata-generation-failed HOT 1
- Monochromatic SED HOT 2
- BUG in FFTs? HOT 5
- Remove hidden scipy dependency
- SED flux type units lost in translation HOT 2
- Installation issue (FFTW problem with Apple ARM) HOT 2
- define `origin` and `world_origin` for CelestialWCS classes? HOT 8
- CelestialWCS method docstring erratum?
- Quintic interpolant (ALT_QUINTIC) uval: sign pb HOT 2
- Construct images without sanity checks in `_convertMask` function in the HSM module HOT 5
- New quintic kernel for interpolation in Fourier Space
- Sum over ghosts or use a diffrent formula for periodic cardinal sinus.
- maxk approximation used in Exponential profile HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from galsim.