Skip to content

Commit

Permalink
Add yaml for pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
squillero committed Aug 23, 2023
1 parent 8347a96 commit 3a3b19e
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 138 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Python tests

on: [push]

jobs:
build:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: szenius/set-timezone@v1.2
with:
timezoneLinux: "Europe/Berlin"
- 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: pip install pytest pytest-md
- uses: pavelzw/pytest-action@v2.1.0
with:
emoji: false
verbose: true
job-summary: true
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![License: Apache 2.0](https://img.shields.io/badge/license-apache--2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![Status: Actrive](https://img.shields.io/badge/status-active-brightgreen.svg)](https://github.com/cad-polito-it/byron)
![Language: Python](https://img.shields.io/badge/language-python-blue.svg)
![Version: 0.1.dev2](https://img.shields.io/badge/version-0.8a1.dev12-orange.svg)
![Version: 0.1.dev2](https://img.shields.io/badge/version-0.8a1.dev13-orange.svg)
![Codename: Don Juan](https://img.shields.io/badge/codename-Don_Juan-pink.svg)
[![Documentation Status](https://readthedocs.org/projects/byron/badge/?version=pre-alpha)](https://byron.readthedocs.io/en/pre-alpha/?badge=pre-alpha)

Expand Down
8 changes: 7 additions & 1 deletion byron/classes/individual.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def run_paranoia_checks(self) -> bool:

# ==[check nodes (semantic)]=========================================
assert all(
n < self._genome.graph["node_count"] for n in self._genome
n < self._genome.graph['node_count'] for n in self._genome
), f"{PARANOIA_VALUE_ERROR}: Invalid 'node_count' attribute ({self._genome.graph['node_count']})"

assert all(
Expand Down Expand Up @@ -402,6 +402,12 @@ def run_paranoia_checks(self) -> bool:

return True

def consolidate_genome(self) -> None:
self._genome = nx.convert_node_labels_to_integers(self._genome)
fasten_subtree_parameters(NodeReference(self._genome, NODE_ZERO))
self._genome.graph['node_count'] = len(self._genome)
self.run_paranoia_checks()

def describe(
self,
*,
Expand Down
2 changes: 1 addition & 1 deletion byron/global_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
from collections import defaultdict
import multiprocessing

__version__ = "0.8a1.dev12"
__version__ = "0.8a1.dev13"
__date__ = "23-08-2023"
__codename__ = "Don Juan"
__author__ = "Giovanni Squillero and Alberto Tonda"
Expand Down
2 changes: 1 addition & 1 deletion byron/operators/_graph_crossover.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ def bunch_random_crossover(p1: Individual, p2: Individual, strength=1.0) -> list
offspring.genome.add_edge(ed[0], first_locus, **ed[1])
# offspring._Individual__COUNTER == max(offspring.genome.nodes)

offspring.genome.graph["node_count"] = max(offspring.genome.nodes) + 1
offspring.genome.graph['node_count'] = max(offspring.genome.nodes) + 1

return [offspring]
4 changes: 2 additions & 2 deletions byron/tools/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@


def add_node(G: nx.MultiDiGraph) -> int:
node_id = G.graph["node_count"]
G.graph["node_count"] += 1
node_id = G.graph['node_count']
G.graph['node_count'] += 1
G.add_node(node_id)
return node_id

Expand Down
Binary file added docs/byron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/tutorials/constraints/01. macro+parameters.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_14867/1429530752.py:1: ByronPerformanceWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/constraints/02. frames.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_14886/1429530752.py:1: ByronPerformanceWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/constraints/03. local references.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_13920/1429530752.py:1: ByronPerformanceWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/constraints/04. global references.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_13937/1429530752.py:1: ByronPerformanceWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/constraints/05. checks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_14015/1429530752.py:1: ByronPerformanceWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/onemax-go.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"text": [
"/var/folders/31/dkl97hks2c14b663vl55pt440000gn/T/ipykernel_11165/826285489.py:1: RuntimeWarning: \n",
" Paranoia checks are enabled in this notebook: performances can be significantly impaired\n",
" [see https://github.com/cad-polito-it/byron/blob/pre-alpha/docs/paranoia.md for details]\n",
" [see https://github.com/cad-polito-it/byron/blob/alpha/docs/paranoia.md for details]\n",
" import byron\n"
]
}
Expand Down
Loading

0 comments on commit 3a3b19e

Please sign in to comment.