Hebg

Latest version: v0.2.4

Safety actively analyzes 625010 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

0.2.4

Add boolean option to cut looping behaviors and redirect them to alternatives.

Examples:
Uncutted
python
unrolled_graph = unroll_graph(gather_wood.graph)

![GatherWood](https://user-images.githubusercontent.com/60117466/216784503-0073ebcc-af25-45e2-a850-b291a44ddbc2.png)
Cutted
python
unrolled_graph = unroll_graph(gather_wood.graph, cut_looping_alternatives=True)

![GatherWoodCut](https://user-images.githubusercontent.com/60117466/216784550-656b8971-946e-41e8-b348-78d6207c7cec.png)
Uncutted
python
unrolled_graph = unroll_graph(get_new_axe.graph)

![GetNewAxe](https://user-images.githubusercontent.com/60117466/216784559-abf731d8-1c19-4b7e-92df-016ebdaa6db9.png)
Cutted
python
unrolled_graph = unroll_graph(get_new_axe.graph, cut_looping_alternatives=True)

![GetNewAxeCut](https://user-images.githubusercontent.com/60117466/216784560-07bd65b6-317e-488c-b7ff-44d90d4e1257.png)

0.2.3

We can now unroll looping behaviors like in this example:


class GatherWood(Behavior):
"""Gather wood"""

def __init__(self) -> None:
"""Gather wood"""
super().__init__("Gather wood")

def build_graph(self) -> HEBGraph:
graph = HEBGraph(self)
feature = FeatureCondition("Has an axe")
graph.add_edge(feature, Action("Punch tree"), index=False)
graph.add_edge(feature, Behavior("Get new axe"), index=False)
graph.add_edge(feature, Action("Use axe on tree"), index=True)
return graph


class GetNewAxe(Behavior):
"""Get new axe with wood"""

def __init__(self) -> None:
"""Get new axe with wood"""
super().__init__("Get new axe")

def build_graph(self) -> HEBGraph:
graph = HEBGraph(self)

feature = FeatureCondition("Has wood")
graph.add_edge(feature, Behavior("Gather wood"), index=False)
graph.add_edge(feature, Action("Craft axe"), index=True)
return graph

def build_looping_behaviors() -> List[Behavior]:
behaviors: List[Behavior] = [GatherWood(), GetNewAxe()]
all_behaviors = {behavior.name: behavior for behavior in behaviors}
for behavior in behaviors:
behavior.graph.all_behaviors = all_behaviors
return behaviors


![GatherWood](https://user-images.githubusercontent.com/60117466/216681787-085e64c9-db88-42ad-ad86-4611950ecfad.png)
![GetNewAxe](https://user-images.githubusercontent.com/60117466/216681800-74d3aea9-3685-4f47-9260-fe5feb1e3eba.png)

0.2.2

🚑 Hotfix allow draw_networkx_nodes_images to draw even if some nodes miss an image.

**Full Changelog**: https://github.com/IRLL/HEB_graphs/compare/0.2.1...0.2.2

0.2.1

Changes:
- 🎨 Add colored textboxes when drawing HEBGraph without images
- 🐛 Fix infinite looping due to missing check when computing histograms
- 📝 Add unrolling example and explanation in README

0.2.0

This is the first release of the HEBG package.

This package is meant to build programmatic Hierarchical Explanable Behaviors as Graphs to compare them to human explanations of behavior. Taking the definition of "behavior" as a function from observation to action.

Features
- Creation of HEBGraph object using the three available types of nodes: Action, FeatureCondition and Behavior.
- Using HEBGraph objects as functional behaviors, calling them with an observation will return the action based on the graph.
- Creation of Hierarchical Behaviors: a Behavior with it's own HEBGraph can be used in an other Behavior HEBGraph.
- Unrolling of a hierarchical HEBGraph, to recursively transform each behavior Node in a graph to it's own subgraph if available.
- Code generation from HEBGraph.

Links

Releases

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.