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

Change affect_neg! keyword arg to instead be a different constructor #18

Closed
ChrisRackauckas opened this issue Jan 20, 2017 · 5 comments
Closed

Comments

@ChrisRackauckas
Copy link
Member

While it seems odd to get rid of ! on a mutating function, @ccontrer 's example brings up a big issue:

callback = ContinuousCallback(condtion,affect_bounce!,rootfind,save_positions,affect_neg! = affect_negative!)

That works.

callback = ContinuousCallback(condtion,affect_bounce!,rootfind,save_positions,affect_neg!=affect_negative!)

That errors. See the difference? Julia parses affect_neg!=affect_negative! as affect_neg != affect_negative!, and errors. That's not nice behavior, and so I think it might be best to just take off the !.

@ccontrer
Copy link

Right! I thought about that. Well, it's only a keyword, isn't it? The function itself will still be mutating function.

@ChrisRackauckas
Copy link
Member Author

Yeah, but the name should probably be consistent. If the keyword arg is affect_neg, then I think the field should be too, and then I think affect should be the other. They would still be mutating. Is that sensible?

@ccontrer
Copy link

ccontrer commented Jan 21, 2017

If the keyword arg is affect_neg, then I think the field should be too, and then I think affect should be the other.

I agree. Or not letting affect_neg! be an keyword. As in

ContinuousCallback(condition,affect!,affect_neg!,
                   rootfind,
                   save_positions;
                   interp_points=10,
                   abstol=1e-14,reltol=0)
ContinuousCallback(condition,affect!,
                   rootfind,
                   save_positions;
                   interp_points=10,
                   abstol=1e-14,reltol=0) = ContinuousCallback(condition,affect!,affect!,
                                                               rootfind,save_positions;
                                                               interp_points=10,
                                                               abstol=1e-14,reltol=0)

or something like that.

@ChrisRackauckas
Copy link
Member Author

I like that suggestion a lot. I think that's the correct way forward.

@ChrisRackauckas ChrisRackauckas changed the title Deprecate affect! for affect Change affect_neg! keyword arg to instead be a different constructor Jan 21, 2017
@ChrisRackauckas
Copy link
Member Author

I implemented this suggestion. There is a depwarn telling people to look at the docs if they use the kwarg, and the docs are being updated right now. I'll tag a new version with this soon.

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

No branches or pull requests

2 participants