Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
df2bd3b
Add barabasi instructions
rachwalk Dec 30, 2022
2d9ac4c
Rename barabasi to barabasi-albert
rachwalk Mar 21, 2023
8a105bd
Add changelog
rachwalk Apr 25, 2023
76390e0
Update changelog
rachwalk May 10, 2023
7ec4801
Init version of barabasi
rachwalk May 22, 2023
9486e18
Merge with barabasi
rachwalk May 22, 2023
d606fce
Fix barabasi
rachwalk May 22, 2023
6043b1b
Update changelog
madpeh May 23, 2023
442defc
0.0.58/add reference to self jid (#90)
madpeh May 23, 2023
ead167f
Update changelog
madpeh May 23, 2023
79c2c86
0.0.58/add logging instruction (#91)
madpeh May 23, 2023
4189202
0.0.58/import only required python modules (#92)
madpeh May 23, 2023
a9e060a
0.0.58/add todos (#93)
madpeh May 23, 2023
84d3652
Update changelog
madpeh May 23, 2023
299587b
Update changelog
madpeh May 23, 2023
239bd81
Update changelog
madpeh May 23, 2023
1a0e9e0
Update changelog
madpeh May 23, 2023
a0a4257
Add order operation
rachwalk May 26, 2023
1c1e00d
Progress
rachwalk Jun 2, 2023
bfa25df
Finalise intermediate representation
rachwalk Jun 7, 2023
8c31bad
Add inhomogenous random graphs
rachwalk Jun 8, 2023
490a65c
Merge with add-random-graphs
rachwalk Jun 8, 2023
cb5ad92
Fix most todos
rachwalk Jun 8, 2023
6a642a5
Fix fa3d7007
rachwalk Jun 8, 2023
553f993
Add parse module
rachwalk Jun 8, 2023
0d3fa58
Add basic module parsing, prepare usage example
rachwalk Jun 9, 2023
e5df55c
Add modvar as message prm
rachwalk Jun 9, 2023
60a5f29
Update intermediate represantation to include ModuleVars
rachwalk Jun 9, 2023
c96b2dc
Update CHANGELOG.md
madpeh Jun 9, 2023
408ea0e
Modify module format
rachwalk Jun 22, 2023
b39d6f4
Add comment to changelog
rachwalk Jun 22, 2023
dcaba18
Merge branch 'release-0.0.58' of github.com:agent-based-information-f…
rachwalk Jun 22, 2023
4be98b1
Add panic exceptions
rachwalk Jun 30, 2023
43e7953
Refortmat
rachwalk Jul 2, 2023
7da4441
Working intermediate representation (maybe)
rachwalk Jul 6, 2023
6586133
Working modules
rachwalk Jul 6, 2023
ecfe9cd
Add modules (#94)
rachwalk Jul 6, 2023
1ca968a
Correct block generation
rachwalk Jul 17, 2023
9ad8e97
Merge branch 'release-0.0.58' of github.com:agent-based-information-f…
rachwalk Jul 17, 2023
219d602
Move changelog to another repo
rachwalk Jul 17, 2023
6b78fff
Update set types
rachwalk Jul 18, 2023
bf4234b
Merge with uuid
rachwalk Jul 18, 2023
fefeb9e
Merge branch 'release-0.0.58' into add-assignment-operators
rachwalk Jul 18, 2023
eb66af0
Fix uuid description
rachwalk Jul 18, 2023
adbdbed
Remove print statements
rachwalk Jul 18, 2023
ebb5148
Fix issue with modvar being accepted as type
rachwalk Jul 18, 2023
f15be1c
Add sim_id to the agents
rachwalk Jul 19, 2023
f7fe5fa
Update examples
rachwalk Jul 19, 2023
b5fe109
Remove trash file
rachwalk Jul 19, 2023
da0b2fb
Add str and float to reserved keywords
rachwalk Jul 19, 2023
e5cf9c6
Release 0.0.58
rachwalk Jul 19, 2023
343c45e
Add modules to the API
rachwalk Jul 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ Types:

`.` (`msg.prm`) - Allows to access the value of `prm` from `msg`.

`LOGS level: {debug, info, warning, error, critical}, name0: Any, name1: Any, ...` - Logs a message with specified `level` and `name0`, `name1`, ... as arguments.

## Message Scope <a name = "message-scope"></a>

### Parameters <a name = "message-scope-parameters"></a>
Expand Down
4 changes: 3 additions & 1 deletion aasm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Agents Assembly translator"""

__version__ = "0.0.57"
__version__ = "0.0.58"

from aasm.generating.code import Code
from aasm.modules.module import Module
from aasm.generating.python_spade import get_spade_code
from aasm.generating.python_module import get_modules_for_target
from aasm.utils.exception import PanicException
16 changes: 14 additions & 2 deletions aasm/generating/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,27 @@


class Code:
def __init__(self, agent_code_lines: List[str], graph_code_lines: List[str]):
def __init__(
self,
agent_code_lines: List[str],
graph_code_lines: List[str],
module_code_lines: List[str],
):
self.agent_code_lines: List[str] = agent_code_lines
self.graph_code_lines: List[str] = graph_code_lines
self.module_code_lines: List[str] = module_code_lines
self._iter_code_lines: List[str] | None = None
self._iter_idx: int | None = None
self._iter_num_code_lines: int | None = None

def __iter__(self) -> Code:
self._iter_code_lines = self.agent_code_lines + ["\n"] + self.graph_code_lines
self._iter_code_lines = (
self.agent_code_lines
+ ["\n"]
+ self.graph_code_lines
+ ["\n"]
+ self.module_code_lines
)
self._iter_num_code_lines = len(self._iter_code_lines)
self._iter_idx = -1
return self
Expand Down
35 changes: 17 additions & 18 deletions aasm/generating/python_code.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,30 @@
from __future__ import annotations

from typing import List
from typing import List, Set


class PythonCode:
def __init__(self, indent_size: int):
self.indent_size = indent_size
self.indent: int = 0
self.code_lines: List[str] = []
self.required_imports: Set[str] = set()

def indent_left(self) -> None:
self.indent -= self.indent_size

def indent_right(self) -> None:
self.indent += self.indent_size

def add_line(self, line: str) -> None:
self.code_lines.append(self.indent * " " + line + "\n")
def add_line(
self, line: str, required_imports: Set[str] | None = None, add_newline=True
) -> None:
if required_imports is not None:
self.required_imports.update(required_imports)
if add_newline:
self.code_lines.append(self.indent * " " + line + "\n")
else:
self.code_lines.append(self.indent * " " + line)

def add_newline(self) -> None:
self.add_line("")
Expand All @@ -25,18 +33,9 @@ def add_newlines(self, count: int) -> None:
for _ in range(count):
self.add_newline()

def add_template(self, template: str, **kwargs: Any) -> None:
lines = template.render(kwargs).splitlines()
current_indent = 0
for line in lines:
space_count = len(line) - len(
line.lstrip(" ")
) # templates should have 4 space indents per pep8
indent_count = space_count // 4
if indent_count < current_indent:
for _ in range(current_indent - indent_count):
self.indent_left()
elif indent_count > current_indent:
for _ in range(indent_count - current_indent):
self.indent_right()
self.add_line(line.strip())
def add_required_imports(self) -> None:
lines: List[str] = []
for required_import in self.required_imports:
lines.append(f"import {required_import}\n")
lines.sort()
self.code_lines = lines + self.code_lines
Loading