Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- if (julia -e 'VERSION < v"0.5" && exit(1)'); then
julia -e 'include(joinpath(JULIA_HOME, Base.DATAROOTDIR, "julia", "build_sysimg.jl")); build_sysimg(force=true)';
julia -e 'Pkg.clone(pwd()); Pkg.build("ForwardDiff"); Pkg.test("ForwardDiff"; coverage=true)';
julia -e 'Pkg.clone(pwd()); Pkg.build("ForwardDiff"); Pkg.checkout("DiffBase"); Pkg.test("ForwardDiff"; coverage=true)';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need to do this? These kind of things should be very temporary, otherwise you're not testing against the same versions of things your users will have installed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DiffBase serves as a repository of test functions. If I didn't do this, I'd have to re-tag DiffBase every time I wanted to add a new shared test function, which would get really annoying.

I share your concern though. I've been meaning to factor the shared test suite out of DiffBase and into an unregistered package (DiffTestSuite or something). Then DiffTestSuite could be a test-only dependency that I Pkg.checkout every time, and I could go back to CI-testing DiffBase's functionality with the proper versions. That's what I probably should've done this in the first place...I'll set it up tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pkg.add("ForwardDiff"); Pkg.test("ForwardDiff") should pass. If that requires tagging more often, tag more often. Pkg.test shouldn't depend on unregistered packages.

Copy link
Contributor

@tkelman tkelman Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same dependency versioning issue applies as everywhere else - if it's needed to pass tests and doesn't exist in every version of DiffBase, then at least test/REQUIRE needs to have a corresponding minimum version requirement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough - I'll fix this to use tagged DiffBase versions and start tagging DiffBase more often, then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind if you want to run additional tests on CI-only, or have things temporarily checked out to branches on CI if that's necessary while things are being developed -- as long as you keep in mind how that configuration will differ from what users will have installed, and that Pkg.test should work for them on releases too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, no worries! My future workflow will be to keep master branch's CI running against tagged dependency versions for the reasons you mentioned. I can always toggle a PR's CI config to use whatever DiffBase branch I want during development, and then before merging, I can tag the new DiffBase version (if necessary) and switch the config back to using only tagged versions.

julia -O3 -e 'include(joinpath(Pkg.dir("ForwardDiff"), "test/SIMDTest.jl"))';
else
julia -e 'Pkg.clone(pwd()); Pkg.build("ForwardDiff"); Pkg.test("ForwardDiff"; coverage=true)';
julia -e 'Pkg.clone(pwd()); Pkg.build("ForwardDiff"); Pkg.checkout("DiffBase"); Pkg.test("ForwardDiff"; coverage=true)';
fi
after_success:
- julia -e 'cd(Pkg.dir("ForwardDiff")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
37 changes: 37 additions & 0 deletions docs/_rst/source/advanced_usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,43 @@ Note that it is usually best to pick a chunk size which divides evenly into the
dimension. Otherwise, ForwardDiff has to construct and utilize an extra "remainder" chunk to
complete the calculation.

Fixing issues with NaN/Inf return values
----------------------------------------

ForwardDiff's default behavior is to return ``NaN`` for undefined derivatives (or otherwise
mirror the behavior of the function in ``Base``, if it would return an error). This is
usually the correct thing to do, but in some cases can erroneously "poison" values which
aren't sensitive to the input and thus cause ForwardDiff to incorrectly return ``NaN`` or
``Inf`` derivatives. For example:

.. code-block:: julia

# the dual number's perturbation component is zero, so this
# variable should not propagate derivative information
julia> log(ForwardDiff.Dual(0.0, 0.0))
Dual(-Inf,NaN) # oops, this NaN should be 0.0

Here, ForwardDiff computes the derivative of ``log(0.0)`` as ``NaN`` and then propagates
this derivative by multiplying it by the perturbation component. Usually, ForwardDiff can
rely on the identity ``x * 0.0 == 0.0`` to prevent the derivatives from propagating when
the perturbation component is ``0.0``. However, this identity doesn't hold if ``isnan(y)``
or ``isinf(y)``, in which case a ``NaN`` derivative will be propagated instead.

It is possible to fix this behavior by checking that the perturbation component is zero
before attempting to propagate derivative information, but this check can noticeably
decrease performance (~5%-10% on our benchmarks).

In order to preserve performance in the majority of use cases, ForwardDiff disables this
check by default. If your code is affected by this ``NaN`` behvaior, you can enable
ForwardDiff's ``NaN``-safe mode by setting ``NANSAFE_MODE_ENABLED`` to ``true`` in
ForwardDiff's source (this constant is located in ``src/ForwardDiff.jl`` in the
package's directory).

In the future, we plan on allowing users and downstream library authors to dynamically
enable ``NaN``-safe mode via the ``AbstractConfig`` API (see `the relevant issue
<https://github.com/JuliaDiff/ForwardDiff.jl/issues/181>`_).


Hessian of a vector-valued function
-----------------------------------

Expand Down
37 changes: 37 additions & 0 deletions docs/_sources/advanced_usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,43 @@ Note that it is usually best to pick a chunk size which divides evenly into the
dimension. Otherwise, ForwardDiff has to construct and utilize an extra "remainder" chunk to
complete the calculation.

Fixing issues with NaN/Inf return values
----------------------------------------

ForwardDiff's default behavior is to return ``NaN`` for undefined derivatives (or otherwise
mirror the behavior of the function in ``Base``, if it would return an error). This is
usually the correct thing to do, but in some cases can erroneously "poison" values which
aren't sensitive to the input and thus cause ForwardDiff to incorrectly return ``NaN`` or
``Inf`` derivatives. For example:

.. code-block:: julia

# the dual number's perturbation component is zero, so this
# variable should not propagate derivative information
julia> log(ForwardDiff.Dual(0.0, 0.0))
Dual(-Inf,NaN) # oops, this NaN should be 0.0

Here, ForwardDiff computes the derivative of ``log(0.0)`` as ``NaN`` and then propagates
this derivative by multiplying it by the perturbation component. Usually, ForwardDiff can
rely on the identity ``x * 0.0 == 0.0`` to prevent the derivatives from propagating when
the perturbation component is ``0.0``. However, this identity doesn't hold if ``isnan(y)``
or ``isinf(y)``, in which case a ``NaN`` derivative will be propagated instead.

It is possible to fix this behavior by checking that the perturbation component is zero
before attempting to propagate derivative information, but this check can noticeably
decrease performance (~5%-10% on our benchmarks).

In order to preserve performance in the majority of use cases, ForwardDiff disables this
check by default. If your code is affected by this ``NaN`` behvaior, you can enable
ForwardDiff's ``NaN``-safe mode by setting ``NANSAFE_MODE_ENABLED`` to ``true`` in
ForwardDiff's source (this constant is located in ``src/ForwardDiff.jl`` in the
package's directory).

In the future, we plan on allowing users and downstream library authors to dynamically
enable ``NaN``-safe mode via the ``AbstractConfig`` API (see `the relevant issue
<https://github.com/JuliaDiff/ForwardDiff.jl/issues/181>`_).


Hessian of a vector-valued function
-----------------------------------

Expand Down
15 changes: 10 additions & 5 deletions docs/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
Expand Down Expand Up @@ -52,6 +52,8 @@ div.sphinxsidebar {
width: 230px;
margin-left: -100%;
font-size: 90%;
word-wrap: break-word;
overflow-wrap : break-word;
}

div.sphinxsidebar ul {
Expand Down Expand Up @@ -83,10 +85,6 @@ div.sphinxsidebar #searchbox input[type="text"] {
width: 170px;
}

div.sphinxsidebar #searchbox input[type="submit"] {
width: 30px;
}

img {
border: 0;
max-width: 100%;
Expand Down Expand Up @@ -187,6 +185,13 @@ div.genindex-jumpbox {

/* -- general body styles --------------------------------------------------- */

div.body p, div.body dd, div.body li, div.body blockquote {
-moz-hyphens: auto;
-ms-hyphens: auto;
-webkit-hyphens: auto;
hyphens: auto;
}

a.headerlink {
visibility: hidden;
}
Expand Down
4 changes: 2 additions & 2 deletions docs/_static/css/theme.css

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions docs/_static/doctools.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
Expand Down Expand Up @@ -124,6 +124,7 @@ var Documentation = {
this.fixFirefoxAnchorBug();
this.highlightSearchWords();
this.initIndexTable();

},

/**
Expand Down Expand Up @@ -252,6 +253,29 @@ var Documentation = {
});
var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
},

initOnKeyListeners: function() {
$(document).keyup(function(event) {
var activeElementType = document.activeElement.tagName;
// don't navigate when in search box or textarea
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT') {
switch (event.keyCode) {
case 37: // left
var prevHref = $('link[rel="prev"]').prop('href');
if (prevHref) {
window.location.href = prevHref;
return false;
}
case 39: // right
var nextHref = $('link[rel="next"]').prop('href');
if (nextHref) {
window.location.href = nextHref;
return false;
}
}
}
});
}
};

Expand All @@ -260,4 +284,4 @@ _ = Documentation.gettext;

$(document).ready(function() {
Documentation.init();
});
});
Binary file modified docs/_static/fonts/Inconsolata-Bold.ttf
Binary file not shown.
Binary file added docs/_static/fonts/Inconsolata-Regular.ttf
Binary file not shown.
Binary file removed docs/_static/fonts/Inconsolata.ttf
Binary file not shown.
Binary file modified docs/_static/fonts/Lato-Bold.ttf
Binary file not shown.
Binary file modified docs/_static/fonts/Lato-Regular.ttf
Binary file not shown.
Binary file modified docs/_static/fonts/RobotoSlab-Bold.ttf
Binary file not shown.
Binary file modified docs/_static/fonts/RobotoSlab-Regular.ttf
Binary file not shown.
Binary file modified docs/_static/fonts/fontawesome-webfont.eot
Binary file not shown.
Loading