Add pre commit game
This commit is contained in:
83
.pre-commit-config.yaml
Normal file
83
.pre-commit-config.yaml
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
default_language_version:
|
||||||
|
python: python3.10
|
||||||
|
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.4.0
|
||||||
|
hooks:
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
exclude: (.txt$|.ipynb$)
|
||||||
|
- id: trailing-whitespace
|
||||||
|
exclude: (.txt$|README.md$)
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-json
|
||||||
|
- id: check-toml
|
||||||
|
- id: check-xml
|
||||||
|
# - id: check-added-large-files
|
||||||
|
# args: [--enforce-all]
|
||||||
|
- id: name-tests-test
|
||||||
|
- id: detect-private-key
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-docstring-first
|
||||||
|
|
||||||
|
- repo: https://github.com/psf/black
|
||||||
|
rev: 22.12.0
|
||||||
|
hooks:
|
||||||
|
- id: black
|
||||||
|
args: [--config=pyproject.toml]
|
||||||
|
- id: black-jupyter
|
||||||
|
args: [--config=pyproject.toml]
|
||||||
|
|
||||||
|
- repo: https://github.com/seandstewart/pre-commit-poetry-export
|
||||||
|
rev: f0501a85959a71c26b964d9542a78d1033af083e
|
||||||
|
hooks: []
|
||||||
|
# - id: export-requirements
|
||||||
|
# - id: export-requirements-dev
|
||||||
|
|
||||||
|
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
|
||||||
|
rev: v2.6.0
|
||||||
|
hooks:
|
||||||
|
- id: pretty-format-ini
|
||||||
|
args: [--autofix]
|
||||||
|
- id: pretty-format-toml
|
||||||
|
args: [--autofix]
|
||||||
|
- id: pretty-format-yaml
|
||||||
|
args: [--autofix]
|
||||||
|
exclude: (docker-compose.yaml$)
|
||||||
|
|
||||||
|
- repo: https://github.com/jendrikseipp/vulture
|
||||||
|
rev: v2.7 # or any later Vulture version
|
||||||
|
hooks:
|
||||||
|
- id: vulture
|
||||||
|
|
||||||
|
- repo: https://github.com/domdfcoding/flake2lint
|
||||||
|
rev: v0.4.2
|
||||||
|
hooks:
|
||||||
|
- id: flake2lint
|
||||||
|
|
||||||
|
- repo: https://github.com/PyCQA/flake8
|
||||||
|
rev: 6.0.0
|
||||||
|
hooks:
|
||||||
|
- id: flake8
|
||||||
|
args: [--config=.flake8]
|
||||||
|
|
||||||
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
|
rev: v0.991
|
||||||
|
hooks:
|
||||||
|
- id: mypy
|
||||||
|
|
||||||
|
- repo: https://github.com/frnmst/md-toc
|
||||||
|
rev: 8.1.8
|
||||||
|
hooks:
|
||||||
|
- id: md-toc
|
||||||
|
|
||||||
|
- repo: https://gitlab.com/smop/pre-commit-hooks
|
||||||
|
rev: v1.0.0
|
||||||
|
hooks:
|
||||||
|
- id: check-poetry
|
||||||
|
|
||||||
|
- repo: https://github.com/Lucas-C/pre-commit-hooks-java
|
||||||
|
rev: 1.3.10
|
||||||
|
hooks:
|
||||||
|
- id: validate-html
|
172
test_main.ipynb
Normal file
172
test_main.ipynb
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": true
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": "array([[0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0.],\n [0., 0., 0., 0., 0.]])"
|
||||||
|
},
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"a = np.zeros((5,5))\n",
|
||||||
|
"a"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": "array([[ 0., 0., 0., 0., 0.],\n [ 0., 0., 0., 0., 0.],\n [ 0., 0., 10., 0., 0.],\n [ 0., 0., 0., 0., 0.],\n [ 0., 0., 0., 0., 0.]])"
|
||||||
|
},
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"a[2,2] = 10\n",
|
||||||
|
"a"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"index_array = np.array([2,2], dtype=int)"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"234 ns ± 7.47 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n",
|
||||||
|
"311 ns ± 2.15 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each)\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"%timeit a[tuple(index_array.tolist())]\n",
|
||||||
|
"%timeit a[index_array[0], index_array[1]]"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def array_change(array):\n",
|
||||||
|
" array[1] = 1"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": "array([[ 0., 0., 0., 0., 0.],\n [ 1., 1., 1., 1., 1.],\n [ 0., 1., 10., 0., 0.],\n [ 1., 1., 1., 1., 1.],\n [ 0., 0., 0., 0., 0.]])"
|
||||||
|
},
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"array_change(a[2:])\n",
|
||||||
|
"a"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 10,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": "array([[ 0., 0., 0., 0., 0.],\n [ 1., 1., 1., 1., 1.],\n [ 0., 1., 10., 0., 0.],\n [ 0., 0., 0., 0., 0.],\n [ 0., 0., 0., 0., 0.]])"
|
||||||
|
},
|
||||||
|
"execution_count": 10,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"a"
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"outputs": [],
|
||||||
|
"source": [],
|
||||||
|
"metadata": {
|
||||||
|
"collapsed": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 2
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython2",
|
||||||
|
"version": "2.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 0
|
||||||
|
}
|
Reference in New Issue
Block a user