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

gradient(): remove from Base, then deprecate #16113

Closed
stevengj opened this issue Apr 29, 2016 · 13 comments
Closed

gradient(): remove from Base, then deprecate #16113

stevengj opened this issue Apr 29, 2016 · 13 comments
Labels
domain:maths Mathematical functions good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants

Comments

@stevengj
Copy link
Member

gradient(1:10) doesn't work because it dispatches to a method that only takes Array arguments.

Also, gradient doesn't support multi-dimensional arrays, whereas in Matlab and NumPy it returns an N-tuple of the gradients along different directions.

cc: @andreasnoack, who looked at these functions in #5321.

@stevengj stevengj added the good first issue Indicates a good issue for first-time contributors to Julia label Apr 29, 2016
@stevengj
Copy link
Member Author

stevengj commented Apr 29, 2016

Also, the current implementation allocates a lot of temporary arrays. Not sure if we care about the performance of this function, though.

@tkelman
Copy link
Contributor

tkelman commented Apr 29, 2016

The presence of this function in base is pretty annoying from a JuliaOpt / AD perspective. Do we need to keep it here?

@andreasnoack
Copy link
Member

The function has received almost no attention over the years. I only fixed a small obvious error reported in #5320 and have never really used it. The gradients I use are those that @tkelman mentions.

@johnmyleswhite
Copy link
Member

I would love to see this function removed.

@stevengj
Copy link
Member Author

I don't have strong opinions about this function; I know that it has a long lineage (e.g. it is in Matlab and NumPy), but I doubt I've used it more than a couple of times in my life. However, it is useful for plotting purposes, e.g. for quick gradient plots in 2d or plots of the slope of a curve. That's probably why it exists.

@StefanKarpinski
Copy link
Sponsor Member

My vote: deprecate and leave as-is.

@kshyatt kshyatt added needs decision A decision on this change is needed domain:maths Mathematical functions labels May 12, 2016
@kshyatt
Copy link
Contributor

kshyatt commented May 12, 2016

I added the decision label to this because it seems there's some controversy. Whichever way we decide it's still an intro issue but it seems like someone ought to decide.

@pao pao changed the title gradient function is overtyped remove, deprecate, or fix type constraints of gradient()? May 12, 2016
@stevengj
Copy link
Member Author

Seems like the clear consensus is to leave as-is and deprecate.

@tkelman
Copy link
Contributor

tkelman commented May 13, 2016

Yep. Though usually when we deprecate things we suggest a replacement. So we should pick some package to migrate this to, and the package can go ahead and deal with the input types. If it's mostly used for plotting, Graphics.jl maybe?

@stevengj
Copy link
Member Author

stevengj commented May 13, 2016

Graphics.jl is more about drawing than plotting, so I don't think it's appropriate. It's not really clear to me that there is any package in common to all plotting, except maybe ColorTypes.jl, but gradient doesn't belong there.

There is a gradient function in FiniteDiff.jl by @johnmyleswhite, but the semantics are somewhat different. I guess he has gradient(f::Function) there; I suppose he could add gradient(::AbstractArray).

@musm
Copy link
Contributor

musm commented May 13, 2016

curl is also a quick and dirty MATLAB function that has seen my use. Would these all appropriately fit in a special function package (even though they're not what one would typically regard as a special function)

@tkelman
Copy link
Contributor

tkelman commented May 13, 2016

MatlabCompat or an independent VectorCalculus package could work. Most packages that do gradients mean the functional gradient rather than gradient vector fields.

@kmsquire
Copy link
Member

FWIW, there is also a gradient function in Images.jl, which calculates the gradient vector field. But the 1D version doesn't really fit there...

@pao pao changed the title remove, deprecate, or fix type constraints of gradient()? gradient(): remove from Base, then deprecate May 13, 2016
@pao pao removed the needs decision A decision on this change is needed label May 13, 2016
@kshyatt kshyatt added the Hacktoberfest Good for Hacktoberfest participants label Oct 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:maths Mathematical functions good first issue Indicates a good issue for first-time contributors to Julia Hacktoberfest Good for Hacktoberfest participants
Projects
None yet
Development

No branches or pull requests

9 participants