Skip to content

Commit

Permalink
Adding pre-commit (#45)
Browse files Browse the repository at this point in the history
* pre-commit

* black

* black

* black update

* black
  • Loading branch information
zkytony authored Jan 26, 2024
1 parent 0fe9bdb commit 36edc64
Show file tree
Hide file tree
Showing 88 changed files with 2,564 additions and 1,570 deletions.
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
exclude: "docs"
- id: end-of-file-fixer
exclude: "docs"
- id: trailing-whitespace
exclude: "docs"

- repo: https://github.com/psf/black
rev: 23.10.0
hooks:
- id: black
args: [ '--config', 'pyproject.toml' ]
verbose: true
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ RUN cd pomdp-py/ && pip install -e.
WORKDIR /app/pomdp-py

# activate 'pomdp' environment by default
RUN echo "conda activate pomdp" >> ~/.bashrc
RUN echo "conda activate pomdp" >> ~/.bashrc
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ clean:
.PHONY: build
build:
python setup.py build_ext --inplace



18 changes: 15 additions & 3 deletions pomdp_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,28 @@
from pomdp_py.representations.distribution.gaussian import Gaussian
from pomdp_py.representations.belief.histogram import update_histogram_belief
from pomdp_py.representations.belief.particles import update_particles_belief
from pomdp_py.utils.interfaces.conversion import to_pomdp_file, to_pomdpx_file, AlphaVectorPolicy, PolicyGraph
from pomdp_py.utils.interfaces.conversion import (
to_pomdp_file,
to_pomdpx_file,
AlphaVectorPolicy,
PolicyGraph,
)
from pomdp_py.utils.interfaces.solvers import vi_pruning, sarsop

# Algorithms
from pomdp_py.algorithms.value_iteration import ValueIteration # Cython compiled
from pomdp_py.algorithms.value_function import value, qvalue, belief_update
from pomdp_py.algorithms.pomcp import POMCP
from pomdp_py.algorithms.po_rollout import PORollout
from pomdp_py.algorithms.po_uct import POUCT, QNode, VNode, RootVNode,\
RolloutPolicy, RandomRollout, ActionPrior
from pomdp_py.algorithms.po_uct import (
POUCT,
QNode,
VNode,
RootVNode,
RolloutPolicy,
RandomRollout,
ActionPrior,
)
from pomdp_py.algorithms.bsp.blqr import BLQR

# Templates & Utilities
Expand Down
25 changes: 15 additions & 10 deletions pomdp_py/__main__.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,47 @@
import argparse

available_problems = [
'tiger',
'rocksample',
'mos',
'tag',
'load_unload'
]
available_problems = ["tiger", "rocksample", "mos", "tag", "load_unload"]


def parse_args():
parser = argparse.ArgumentParser(description="pomdp_py CLI")
parser.add_argument("-r", "--run", type=str,
help="run a pomdp under pomdp_py.problems."
"Available options: {}".format(available_problems))
parser.add_argument(
"-r",
"--run",
type=str,
help="run a pomdp under pomdp_py.problems."
"Available options: {}".format(available_problems),
)
args = parser.parse_args()
return parser, args


if __name__ == "__main__":
parser, args = parse_args()
if args.run:
if args.run.lower() == "tiger":
from pomdp_py.problems.tiger.tiger_problem import main

main()

elif args.run.lower() == "rocksample":
from pomdp_py.problems.rocksample.rocksample_problem import main

main()

elif args.run.lower() == "mos":
from pomdp_py.problems.multi_object_search.problem import unittest

unittest()

elif args.run.lower() == "tag":
from pomdp_py.problems.tag.problem import main

main()

elif args.run.lower() == "load_unload":
from pomdp_py.problems.load_unload.load_unload import main

main()

else:
Expand Down
Loading

0 comments on commit 36edc64

Please sign in to comment.