Skip to content

Commit

Permalink
Add tox, pyproject, setup, and GitHub workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
parsiad committed Jan 29, 2024
1 parent c2a32d1 commit 2cd954f
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 9 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: tox

on:
- push
- pull_request

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Run tox
run: tox
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__
*.egg-info
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tool.black]
line-length = 120

[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extraPaths": ["python"]
"extraPaths": ["src"]
}
29 changes: 29 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[metadata]
name = micrograd-pp
version = 0.1
author = Parsiad Azimzadeh
author_email = [email protected]
description = A minimalistic wrapper around NumPy which adds support for automatic differentiation.
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/parsiad/micrograd-pp
project_urls =
Bug Tracker = https://github.com/parsiad/micrograd-pp/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent

[options]
install_requires =
tabulate
package_dir =
= src
packages = find:
python_requires = >= 3.6

[options.packages.find]
where = src

[pylint.FORMAT]
max-line-length=120
File renamed without changes.
10 changes: 2 additions & 8 deletions python/micrograd_pp/_expr.py → src/micrograd_pp/_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,7 @@ def func() -> npt.NDArray:
dim = tuple(
[
self.ndim - 1 - i
for i, (m, n) in enumerate(
itertools.zip_longest(
reversed(self._a.shape), reversed(self.shape)
)
)
for i, (m, n) in enumerate(itertools.zip_longest(reversed(self._a.shape), reversed(self.shape)))
if m is None or m != n
]
)
Expand Down Expand Up @@ -470,9 +466,7 @@ def __init__(self, a: Expr, pow: int | float) -> None:
self._pow = pow

def _backward(self, grad: npt.NDArray) -> None:
self._a.update_grad(
lambda: grad * self._pow * self._a._value ** (self._pow - 1)
)
self._a.update_grad(lambda: grad * self._pow * self._a._value ** (self._pow - 1))


class _ReLU(Expr):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[tox]
envlist = py311

[testenv]
deps =
numpy
pytest
commands =
pytest tests/

0 comments on commit 2cd954f

Please sign in to comment.