Skip to main content

A package for Automatic Differentiation

Project description

How to Use Package

Installation

To begin, the user has to work in a python environment (preferably version >= 3.7). As an option, the user can choose to create a new virtual environment for automatic differentiation using the following command in the terminal:

conda create -n env_autodiff python=3.7

We have used PyPI to host our package. Users can download our Automatic Differentiation package with the following command in the terminal:

pip install autodiffing

To install the required dependencies, users need to run the following command in the terminal:

pip install -r requirements.txt

Within our requirements.txt, we have the a number of packages that come with the installation of python version 3.7 and our main packages, but the main packages that we require for our Automatic Differentiation package are:

numpy==1.17.4
doctest-cli==0.0.3
pytest==5.2.4 pytest-cov==2.8.1
matplotlib==3.1.1
scipy==1.3.2

numpy is essential for our Automatic Differentiation package as we require it for the calculation of our elementary functions, and for dealing with arrays and matrices when there are vector functions and vector inputs.

doctest-cli is needed for user to run demo case usage of the functions within our package. To do so, the user can run the following commands in the terminal:

python DualNumber.py
python ElementaryFunctions.py

pytest and pytest-cov are packages for the user to test that our code is functional and check for code coverage of our tests.

matplotlib is needed for any potential visualization of our outputs.

scipy is a good package to have for its optimization and linear algebra abilities.

Using the Package

Once users have installed all the dependencies and the package itself, they may begin to use our package to quickly find derivatives of functions. For this section, we walk through three different examples of how users can interact with the package for their purposes. Users should start by importing the DualNumber and ElementaryFunctions modules. As specified in Milestone 1 and in this document, users should start by initializing a DualNumber object:

# DualNumber is a class in module AD, user must initialize the value of the variable in the initialization.
x = DualNumber(5)

Note that when the user initializes a variable, he or she must provide the initial value. For this milestone, the user may only pass in scalar-valued functions of scalars, but in the future we will implement methods and classes for the user to input vector-valued functions of vectors. The initial value of the derivative is set as a default of 1, but the user may overwrite this. To find the derivative of a specific elementary function, users should pass this initialized object into our custom-designed elementary functions as follows:

# ElemFunctions is a class where we define some elementary function derivatives and calculate the derivative function.
func = EF.Sin(x)

# we can get the value and derivative from the attributes "val" and "der". If we did not assign value and derivative direction in the fist
# step, we can do it here. 
print(func.val)
print(func.der)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autodiffing-0.0.1.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autodiffing-0.0.1-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

File details

Details for the file autodiffing-0.0.1.tar.gz.

File metadata

  • Download URL: autodiffing-0.0.1.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for autodiffing-0.0.1.tar.gz
Algorithm Hash digest
SHA256 99f216be45c07733cb6e8698f274d91f44aa63f1fb8bd181f7ffbde83ad7c6e6
MD5 0745c95f62f589856671ae39ef931e11
BLAKE2b-256 3e29c5660232a85ceb4db41ff4cffa5f72ad4e95ad4fe297ea4fc10ad55eb4f1

See more details on using hashes here.

File details

Details for the file autodiffing-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: autodiffing-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.5

File hashes

Hashes for autodiffing-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9eff14cf87679e74f916815e4f1ebde537778f3b4f6026b444cd429c66d76a5d
MD5 140a90764744a5bc08d84a17b6023ec3
BLAKE2b-256 5dade325cf0fdba931e86b17379dc27c517c28b84172be163dbe69b74e5022f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page