Skip to content

Commit

Permalink
Merge pull request #210 from PermutaTriangle/develop
Browse files Browse the repository at this point in the history
Version 2.2.0
  • Loading branch information
jaypantone authored Aug 11, 2020
2 parents baf000b + 049a94e commit 52dda1f
Show file tree
Hide file tree
Showing 16 changed files with 452 additions and 166 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-and-deploy

on:
push:
branches:
- master

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: build
run: python setup.py sdist
- name: deploy
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: twine upload dist/*
62 changes: 62 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: tests

on: [push, pull_request]

jobs:

test:
strategy:
fail-fast: false
matrix:
include:
- python: 3.8
toxenv: flake8
os: ubuntu-latest
- python: 3.8
toxenv: mypy
os: ubuntu-latest
- python: 3.8
toxenv: pylint
os: ubuntu-latest
- python: 3.8
toxenv: black
os: ubuntu-latest
- python: 3.8
toxenv: tilescope
os: ubuntu-latest

- python: 3.6
toxenv: py36
os: ubuntu-latest
- python: 3.7
toxenv: py37
os: ubuntu-latest
- python: 3.8
toxenv: py38
os: ubuntu-latest
- python: 3.9-dev
toxenv: py39
os: ubuntu-latest
- python: pypy3
toxenv: pypy36
os: ubuntu-latest

- python: 3.8
toxenv: py38
os: macos-latest
- python: 3.8
toxenv: py38
os: windows-latest

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: install dependencies
run: python -m pip install --upgrade pip tox
- name: run
env:
TOXENV: ${{ matrix.toxenv }}
run: tox
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ script:
- tox


deploy:
provider: pypi
user: henningu
password:
secure: tX5N54vVZ0Kdy//VUy9dT31KZEplHKyxb7JN45sAHUDDurkUyG2eV1lIIOeoyNNceXQTIN9N6+aY4bVLipLjbmw021VWrkdVGxnaqq0ozIHiayvM1XRKkIQnOD/eRWA7HnN6SoYGDwQwsfTohUtsxlqwsIB2L7Q8hU1VhpjDyh1lNpkN4ufMYC8wG9MG8uohM1D8BuFfAPEZHVuX7QdvdBwb3117H3UiCv7OcXtv6n1xil9BMkm89vLfzCdV3r/TO5YTMhVTbNjnOu0FyB0IoNZB7spTqOE0XYlPMLAel8hs1zvY5sbMzjRqZETMykLJY325gFAk2ZTEJAtfmGlWXGaBoXhy8s0kvdYAZD0sTRmVRcjZd5YFyghxx0dfXE+fq6f/fwlmvr/bAmvtfBTgar8CgGFuE07PolQk7XOn1fiV9TQX+oJjqyySV3OdFIvc52ZyFqXvQRN8OY1AlIXxz0sLsOHGkDUqalqQjW0boSwBCy+DyKXoIaCIXuQVl+teT9bC9DEq5kNT6BiIOn/ABAvmmoMgggqCTDtjlGG6a2oB6Y+7F1yMDhAYddc7ZLOFvYu2A25/ldInLan3SsfPxIWllCg77BFS4LuGH9w/JjFqdu5wJR+F19jhWxicKxWnUaT58wwx51LpPY3okIG4ZEyjPhzED/2lIvn5+Eniq54=
skip_existing: true
on:
branch: master
# deploy:
# provider: pypi
# user: henningu
# password:
# secure: tX5N54vVZ0Kdy//VUy9dT31KZEplHKyxb7JN45sAHUDDurkUyG2eV1lIIOeoyNNceXQTIN9N6+aY4bVLipLjbmw021VWrkdVGxnaqq0ozIHiayvM1XRKkIQnOD/eRWA7HnN6SoYGDwQwsfTohUtsxlqwsIB2L7Q8hU1VhpjDyh1lNpkN4ufMYC8wG9MG8uohM1D8BuFfAPEZHVuX7QdvdBwb3117H3UiCv7OcXtv6n1xil9BMkm89vLfzCdV3r/TO5YTMhVTbNjnOu0FyB0IoNZB7spTqOE0XYlPMLAel8hs1zvY5sbMzjRqZETMykLJY325gFAk2ZTEJAtfmGlWXGaBoXhy8s0kvdYAZD0sTRmVRcjZd5YFyghxx0dfXE+fq6f/fwlmvr/bAmvtfBTgar8CgGFuE07PolQk7XOn1fiV9TQX+oJjqyySV3OdFIvc52ZyFqXvQRN8OY1AlIXxz0sLsOHGkDUqalqQjW0boSwBCy+DyKXoIaCIXuQVl+teT9bC9DEq5kNT6BiIOn/ABAvmmoMgggqCTDtjlGG6a2oB6Y+7F1yMDhAYddc7ZLOFvYu2A25/ldInLan3SsfPxIWllCg77BFS4LuGH9w/JjFqdu5wJR+F19jhWxicKxWnUaT58wwx51LpPY3okIG4ZEyjPhzED/2lIvn5+Eniq54=
# skip_existing: true
# on:
# branch: master
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,31 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

## [2.2.0] - 2020-08-11
### Added
- using Github Actions for testing and deployment
- add specification sharing function to `ForestSpecificationDrawer`

### Changed
- when using a `LimitedStrategyRuleDB`, searching is aborted much faster when the root
is not in the first pruned rules dictionary

### Fixed
- use `AbstractRule` instead of `Rule` in `_rules_from_strategy`
- fix `CombinatorialSpecification.share()` which was missing

## [2.1.1] - 2020-08-06
### Fixed
- Hopefully fixed the type hints
- fixed the type hints

## [2.1.0] - 2020-08-06
### Added
- a `SpecificationDrawer` for visualizing `CombinatorialSpecification`
- `show` method to `CombinatorialSpecification`
- `to_html_representation` method to `CombinatorialClass`
- `AbstractStrategy` raises `StrategyDoesNotApply` in the `__call__` method
- function `CombinatorialSpecification.share_spec()` which uploads the spec to a file
sharing site
- more verbose logging during the specification creation process

### Changed
Expand Down
3 changes: 3 additions & 0 deletions comb_spec_searcher/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .comb_spec_searcher import CombinatorialSpecificationSearcher
from .combinatorial_class import CombinatorialClass, CombinatorialObject
from .specification import CombinatorialSpecification
from .specification_drawer import ForestSpecificationDrawer, SpecificationDrawer
from .strategies import (
AtomStrategy,
CartesianProduct,
Expand All @@ -20,6 +21,8 @@
"CombinatorialClass",
"CombinatorialObject",
"CombinatorialSpecification",
"ForestSpecificationDrawer",
"SpecificationDrawer",
"AtomStrategy",
"CartesianProduct",
"CartesianProductStrategy",
Expand Down
3 changes: 1 addition & 2 deletions comb_spec_searcher/comb_spec_searcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from .specification import CombinatorialSpecification
from .strategies import (
AbstractStrategy,
Rule,
StrategyFactory,
StrategyPack,
VerificationRule,
Expand Down Expand Up @@ -202,7 +201,7 @@ def _rules_from_strategy(
pass
elif isinstance(strategy, StrategyFactory):
for strat in strategy(comb_class, **self.kwargs):
if isinstance(strat, Rule):
if isinstance(strat, AbstractRule):
yield strat
elif isinstance(strat, AbstractStrategy):
try:
Expand Down
7 changes: 7 additions & 0 deletions comb_spec_searcher/resources/static/css/bootstrap.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,50 @@ body {
"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Segoe UI Symbol";
font-size:1rem;font-weight:400;line-height:1.5;
color:#212529;text-align:left;background-color:#fff
}
}

svg {
overflow: visible !important;
}

table {
box-sizing: border-box;
border-collapse: collapse;
}

.label{
width: auto;
border: 1px solid;
border-bottom-style: none;
border-bottom: 1px solid;
}

.verbose{
padding: 4px;
border-top: 1px solid;
}

.node-content{
width: max-content;
text-align: left;
border: 1px solid;
padding: 14px;
font-family: Consolas, monaco, monospace;
font-size: 14px; font-style: normal;
line-height: normal;
display: flex;
justify-content: center;
align-items: center;
margin: auto;
}

.node-container{
width: min-content;
border: 1px solid;
}

.inner-node-content{
margin-right: 14px;
max-width: 400px;
padding: 14px;
}

pre{
font-family: Consolas, monaco, monospace;
font-size: 14px; font-style: normal;
Expand Down Expand Up @@ -104,13 +118,15 @@ pre{

.tooltip {
transform: perspective(1px) scale(1.1);
max-width: 800px;
border-radius: 5px;
border: 1px solid black;
background-color: white;
pointer-events: none;
z-index: 1080;
opacity: 0.97 !important;
padding: 0 30px 0 30px;
pointer-events: all;
}

.tooltip-inner {
Expand All @@ -127,13 +143,6 @@ pre{
max-width: none !important;
}

.tiling {
border: 1px solid;
width: 22px;
height: 22px;
text-align: center;
}

@media print {
body {-webkit-print-color-adjust: exact;}
}
4 changes: 4 additions & 0 deletions comb_spec_searcher/rule_db/limited_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ def find_specification(
else:
prune(rules_dict) # this function removes rules not in a specification.

# if the root is not in the pruned dict, then there's nothing to be done
if self.equivdb[label] not in rules_dict:
raise SpecificationNotFound("No specification for label {}".format(label))

# find the rules that we want to limit, and consider only those in a spec
rules_to_isolate = self.get_rules_up_to_equiv_using_strategies()
rules_to_isolate = set(
Expand Down
34 changes: 32 additions & 2 deletions comb_spec_searcher/specification.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,20 +438,50 @@ def sanity_check(self, length: int = 5) -> bool:
for n in range(length + 1)
)

def show(self, levels_shown: int = 0, levels_expand: int = 0) -> None:
def show(
self, levels_shown: int = 0, levels_expand: int = 0, verbose: bool = False
) -> None:
"""
Displays a tree representing this object in the web browser
OTHER INPUT:
- 'levels_shown': number of levels displayed at the start.
If 0 then the whole tree is displayed
- 'levels_expand': number of levels displayed after expanding a node.
If 0 then the rest of the tree is displayed
- 'verbose': displays formal step below the node
and json representation in tooltips
"""
sd = SpecificationDrawer(
self, levels_shown=levels_shown, levels_expand=levels_expand
self,
levels_shown=levels_shown,
levels_expand=levels_expand,
verbose=verbose,
)
sd.show()

def share(
self, levels_shown: int = 0, levels_expand: int = 0, verbose: bool = False
) -> None:
"""
Uploads the html representation of the specification to a sharing website and
display the link to the file.
INPUT:
- 'levels_shown': number of levels displayed at the start.
If 0 then the whole tree is displayed
- 'levels_expand': number of levels displayed after expanding a node.
If 0 then the rest of the tree is displayed
- 'verbose': displays formal step below the node
and json representation in tooltips
"""
sd = SpecificationDrawer(
self,
levels_shown=levels_shown,
levels_expand=levels_expand,
verbose=verbose,
)
sd.share()

def __eq__(self, other: object) -> bool:
if not isinstance(other, CombinatorialSpecification):
return NotImplemented
Expand Down
Loading

0 comments on commit 52dda1f

Please sign in to comment.