Skip to main content

EasyDiff Build Status codecov

EasyDiff is an automatic differentiation python library with forward and reverse mode supported. EasyDiff is developed as a Harvard CS207 (19Fall) course project by Group 18: Yang Zhou, Ruby Zhang, Kangli Wu, and Emily Gould. Check our documentation for more details.

How to use CrackAD

Installation

Option One: Downloading Using Pip

Get The Package

Simply open your terminal and type the following command:

pip install EasyDiff

Update The Package

To get new releases, paste this into your terminal:

pip install EasyDiff --upgrade

We highly recommend installing the package with pip. Yet, if that doesn't work for you, you can still get our package with the second option below.

Option Two: Downloading From GitHub

Clone the Repository

Clone our GitHub repository and navigate into this directory in your terminal:

git clone https://github.com/CrackAD/cs207-FinalProject.git

In order to use the CrackAD package, you'll need to create a virtual environment. We recommend conda because it is both a package and environment manager and is language agnostic. Please run the following commands in a terminal:

Create Conda Environment

Create an environment with the command, where env_name is the name of your choice. Since our package requires the NumPy package, we also install it at this step:

conda create --name env_name python numpy

Activate the Environment

To activate the Conda environment just created, run the following line:

source activate env_name

Or

conda activate env_name

Yet, it is possible that the second one doesn't work because conda will complain that the shell hasn't been configured to use conda activate. So we would recommend using the first line.

Install Packages

If you haven't installed NumPy in the first step, or if you ever need to install another package, simply do the following:

conda install numpy

To check whether the installation succeeded, we could list out all installed packages in this environment:

conda list

If the conda install did not work, try pip install:

pip install Numpy

Note that it is suggested to always try conda install first.

Demonstration

To use CrackAD, create a .py file (eg, driver.py) with the following lines of code:

from EasyDiff.ad import AD
from EasyDiff.var import Var
from EasyDiff.rev_var import Rev_Var
from EasyDiff.ad import AD_Mode
import numpy as np

# test forward mode. 
# give it a function of your choice
func = lambda x,y: Var.log(x) ** Var.sin(y)

# give the initial values to take the derivatives at
ad = AD(vals=np.array([2, 2]), ders=np.array([1, 1]), mode=AD_Mode.FORWARD)

# calculate and print the derivatives
print("Var.log(x) ** Var.sin(y): {}".format(vars(ad.auto_diff(func))))

# test reverse mode. 
func = lambda x,y: Rev_Var.log(x) ** Rev_Var.sin(y)
ad = AD(vals=np.array([2, 2]), ders=np.array([1, 1]), mode=AD_Mode.REVERSE)
print("Rev_Var.log(x) ** Rev_Var.sin(y): {}".format(vars(ad.auto_diff(func))))

Then, you can run the file in a terminal as follows:

python3 driver.py

Metadata

Release files for easydiff 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easydiff 0.0.3
File Size Uploaded
easydiff-0.0.3.tar.gz 13.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for easydiff 0.0.3
File Interpreter ABI Platform
easydiff-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.9 kB

Release files / easydiff-0.0.3.tar.gz

Download URL easydiff-0.0.3.tar.gz
Size 13.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0cf6a4084819f1dc284cb18a96e3083b9895b6aa226dbfa5fe2f32a9b395e470
BLAKE2b-256 checksum
How to use checksums
566d70508990759d03211eaba6a962cbfac01238a9070c95cc9b60712f835a7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / easydiff-0.0.3-py3-none-any.whl

Download URL easydiff-0.0.3-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d30709671b5ae3bd107b71dcca3126f4e8901ad8e646529070c22fe4e1197be
BLAKE2b-256 checksum
How to use checksums
dcd893ba1805a9537dd0100376dcaa0d4ec6df52c5405ede43c921fc74348b66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page