Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ad
Package Documentation.. image:: https://travis-ci.org/tisimst/ad.png?branch=master
The ad
package allows you to easily and transparently perform
first and second-order automatic differentiation. Advanced math
involving trigonometric, logarithmic, hyperbolic, etc. functions can also
be evaluated directly using the admath
sub-module.
All base numeric types are supported (int
, float
, complex
,
etc.). This package is designed so that the underlying numeric types will
interact with each other as they normally do when performing any
calculations. Thus, this package acts more like a "wrapper" that simply helps
keep track of derivatives while maintaining the original functionality of
the numeric calculations.
From the Wikipedia entry on Automatic differentiation
_ (AD):
"AD exploits the fact that every computer program, no matter how
complicated, executes a sequence of elementary arithmetic operations
(addition, subtraction, multiplication, division, etc.) and elementary
functions (exp, log, sin, cos, etc.). By applying the chain rule
repeatedly to these operations, derivatives of arbitrary order can be
computed automatically, and accurate to working precision."
See the package documentation
_ for details and examples.
Transparent calculations with derivatives: no or little
modification of existing code is needed, including when using
the Numpy
_ module.
Almost all mathematical operations are supported, including functions from the standard math_ module (sin, cos, exp, erf, etc.) and cmath_ module (phase, polar, etc.) with additional convenience trigonometric, hyperbolic, and logarithmic functions (csc, acoth, ln, etc.). Comparison operators follow the same rules as the underlying numeric types.
Real and complex arithmetic handled seamlessly. Treat objects as you
normally would using the math
_ and cmath
_ functions, but with their new
admath
counterparts.
Automatic gradient and hessian function generator for optimization
studies using scipy.optimize
_ routines with gh(your_func_here)
.
Compatible Linear Algebra Routines in the ad.linalg
submodule,
similar to those found in NumPy's linalg
submodule, that are not
dependent on LAPACK. There are currently:
a. Decompositions
chol
: Cholesky Decompositionlu
: LU Decompositionqr
: QR Decompositionb. Solving equations and inverting matrices
solve
: General solver for linear systems of equationslstsq
: Least-squares solver for linear systems of equationsinv
: Solve for the (multiplicative) inverse of a matrixYou have several easy, convenient options to install the ad
package
(administrative privileges may be required):
Download the package files below, unzip to any directory, and run
python setup.py install
from the command-line.
Simply copy the unzipped ad-XYZ
directory to any other location
that python can find it and rename it ad
.
If setuptools
is installed, run easy_install --upgrade ad
from the command-line.
If pip
is installed, run pip install --upgrade ad
from the
command-line.
Download the bleeding-edge version on GitHub_
Please send feature requests, bug reports, or feedback to
Abraham Lee
_.
The author expresses his thanks to :
Eric O. LEBIGOT (EOL)
, author of the uncertainties
package, for providing
code insight and inspirationscipy.optimize
.fhgd
for catching a mis-calculation in admath.atan2
.. _NumPy: http://numpy.scipy.org/ .. _math: http://docs.python.org/library/math.html .. _cmath: http://docs.python.org/library/cmath.html .. _Automatic differentiation: http://en.wikipedia.org/wiki/Automatic_differentiation .. _Eric O. LEBIGOT (EOL): http://www.linkedin.com/pub/eric-lebigot/22/293/277 .. _uncertainties: http://pypi.python.org/pypi/uncertainties .. _scipy.optimize: http://docs.scipy.org/doc/scipy/reference/optimize.html .. _Abraham Lee: mailto:tisimst@gmail.com .. _package documentation: http://pythonhosted.org/ad .. _GitHub: https://github.com/tisimst/ad
FAQs
Fast, transparent first- and second-order automatic differentiation
We found that ad demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.