Skip to content

Commit

Permalink
Merge pull request #39 from brandonwillard/fix-subtensor-shape-inference
Browse files Browse the repository at this point in the history
- Fix `*Subtensor*` `Op` shape inference
- Make `theano.tensor.basic.as_tensor_variable` consistent in how it handles constant conversions
- Remove `TensorConstant` caching
  • Loading branch information
brandonwillard committed Oct 12, 2020
2 parents c46143b + eaf1470 commit e96b285
Show file tree
Hide file tree
Showing 35 changed files with 2,205 additions and 1,881 deletions.
70 changes: 70 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
.PHONY: help venv conda docker docstyle format style black test lint check coverage pypi
.DEFAULT_GOAL = help

PROJECT_NAME = theano
PROJECT_DIR = theano/
PYTHON = python
PIP = pip
CONDA = conda
SHELL = bash

help:
@printf "Usage:\n"
@grep -E '^[a-zA-Z_-]+:.*?# .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?# "}; {printf "\033[1;34mmake %-10s\033[0m%s\n", $$1, $$2}'

conda: # Set up a conda environment for development.
@printf "Creating conda environment...\n"
${CONDA} create --yes --name ${PROJECT_NAME}-env python=3.6
( \
${CONDA} activate ${PROJECT_NAME}-env; \
${PIP} install -U pip; \
${PIP} install -r requirements.txt; \
${CONDA} deactivate; \
)
@printf "\n\nConda environment created! \033[1;34mRun \`conda activate ${PROJECT_NAME}-env\` to activate it.\033[0m\n\n\n"

venv: # Set up a Python virtual environment for development.
@printf "Creating Python virtual environment...\n"
rm -rf ${PROJECT_NAME}-venv
${PYTHON} -m venv ${PROJECT_NAME}-venv
( \
source ${PROJECT_NAME}-venv/bin/activate; \
${PIP} install -U pip; \
${PIP} install -r requirements.txt; \
deactivate; \
)
@printf "\n\nVirtual environment created! \033[1;34mRun \`source ${PROJECT_NAME}-venv/bin/activate\` to activate it.\033[0m\n\n\n"

docstyle:
@printf "Checking documentation with pydocstyle...\n"
pydocstyle ${PROJECT_DIR}
@printf "\033[1;34mPydocstyle passes!\033[0m\n\n"

format:
@printf "Checking code format with black...\n"
black -t py36 --check ${PROJECT_DIR} tests/ setup.py conftest.py
@printf "\033[1;34mBlack passes!\033[0m\n\n"

style:
@printf "Checking code style with pylint...\n"
flake8
@printf "\033[1;34mPylint passes!\033[0m\n\n"

black: # Format code in-place using black.
black ${PROJECT_DIR} tests/ setup.py conftest.py

test: # Test code using pytest.
pytest -v tests/ ${PROJECT_DIR} --cov=${PROJECT_DIR} --cov-report=xml --html=testing-report.html --self-contained-html

coverage: test
diff-cover coverage.xml --compare-branch=master --fail-under=100

pypi:
${PYTHON} setup.py clean --all; \
${PYTHON} setup.py rotate --match=.tar.gz,.whl,.egg,.zip --keep=0; \
${PYTHON} setup.py sdist bdist_wheel; \
twine upload --skip-existing dist/*;

lint: docstyle format style # Lint code using pydocstyle, black and pylint.

check: lint test coverage # Both lint and test code. Runs `make lint` followed by `make test`.
11 changes: 11 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import os

import pytest


def pytest_sessionstart(session):
os.environ["THEANO_FLAGS"] = ",".join(
[
os.environ.setdefault("THEANO_FLAGS", ""),
"warn.ignore_bug_before=all,on_opt_error=raise,on_shape_error=raise",
]
)


def pytest_addoption(parser):
parser.addoption(
"--runslow", action="store_true", default=False, help="run slow tests"
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ sympy
versioneer
jax; python_version > '3.6'
jaxlib; python_version > '3.6'
diff-cover
Loading

0 comments on commit e96b285

Please sign in to comment.