-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from PAICookers/dev
v0.0.11
- Loading branch information
Showing
14 changed files
with
903 additions
and
636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will upload a Python Package using Twine when a release is created | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ env.TAG_NAME }} | ||
|
||
- name: Publish python poetry package | ||
uses: JRubics/[email protected] | ||
with: | ||
python_version: "3.10" | ||
pypi_token: ${{ secrets.PYPI_API_TOKEN }} | ||
build_format: "wheel" | ||
ignore_dev_requirements: "yes" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from paitest import paitest | ||
from paitest.frames import FrameDecoder | ||
|
||
|
||
if __name__ == "__main__": | ||
"""Here are simple exmaples""" | ||
|
||
# Path to store the config, test input and output frames | ||
save_path = "./test" | ||
|
||
# N groups | ||
groups = 1 | ||
|
||
# PAITest instance | ||
PAITestManager = paitest("EAST") | ||
|
||
# 1. Generate 1 group for N cores with N parameters reg. | ||
a_cf, a_ti, a_to = PAITestManager.Get1GroupForNCoresWithNParams( | ||
3, save_dir="./test" | ||
) | ||
print(a_cf, a_ti, a_to) | ||
|
||
# 2. Generate 1 group for N cores with the same 1 parameter reg. | ||
a_cf, a_ti, a_to = PAITestManager.Get1GroupForNCoresWith1Param(1, save_dir="./test") | ||
print(a_cf, a_ti, a_to) | ||
|
||
# 3. Generate N groups for 1 core with N parameters reg. | ||
a_cf, a_fi, a_fo = PAITestManager.GetNGroupsFor1CoreWithNParams( | ||
3, save_dir="./test1" | ||
) | ||
|
||
# 3. Replace the core coordinate with (9, 9) then save in test/config_r.bin | ||
a_cf_replaced = PAITestManager.ReplaceCoreCoord(a_cf[:3], (9, 9)) | ||
PAITestManager.SaveFrames("./test/config_r.bin", a_cf_replaced) | ||
print(f"a_cf_replaced: {a_cf_replaced}") | ||
|
||
# Then, decode the replaced frames to check whether the replacement is OK | ||
decoder = FrameDecoder() | ||
attr = decoder.decode(a_cf_replaced) | ||
|
||
replaced_coord = attr.get("core_coord") | ||
if replaced_coord == (9, 9): | ||
print("Replacement OK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from .frame import \ | ||
Addr2Coord as Addr2Coord, \ | ||
Coord2Addr as Coord2Addr, \ | ||
FrameGen as FrameGen, \ | ||
Coord as Coord, \ | ||
Direction as Direction, \ | ||
FrameMask as FrameMask, \ | ||
FrameSubType as FrameSubType | ||
from .frame import ( | ||
Addr2Coord as Addr2Coord, | ||
Coord2Addr as Coord2Addr, | ||
FrameGen as FrameGen, | ||
Direction as Direction, | ||
FrameMask as FrameMask, | ||
FrameSubType as FrameSubType, | ||
FrameDecoder as FrameDecoder, | ||
) | ||
from .coord import Coord as Coord |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
from typing import Tuple, Union, Optional | ||
|
||
|
||
class Coord: | ||
"""Coordinate class""" | ||
|
||
def __init__( | ||
self, _x: Union[Tuple[int, int], int], _y: Optional[int] = None | ||
) -> None: | ||
if isinstance(_x, Tuple): | ||
x, y = _x[0], _x[1] | ||
if isinstance(_y, int): | ||
raise ValueError(f"Wrong Argument: {_y}") | ||
elif isinstance(_x, int): | ||
if isinstance(_y, int): | ||
x, y = _x, _y | ||
else: | ||
raise ValueError("Missing Argument: y") | ||
else: | ||
raise ValueError("Wrong Argument") | ||
|
||
if not (0 <= x < 32 and 0 <= y < 32): | ||
raise ValueError(f"0 <= x < 32, 0 <= y < 32: ({x}, {y})") | ||
|
||
self.x, self.y = x, y | ||
|
||
def __add__(self, other) -> "Coord": | ||
return Coord(self.x + other.x, self.y + other.y) | ||
|
||
def __sub__(self, other) -> "CoordOffset": | ||
return CoordOffset(self.x - other.x, self.y - other.y) | ||
|
||
def __eq__(self, other) -> bool: | ||
if isinstance(other, Tuple): | ||
return (self.x, self.y) == other | ||
|
||
return self.x == other.x and self.y == other.y | ||
|
||
def __ne__(self, other) -> bool: | ||
return self.x != other.x or self.y != other.y | ||
|
||
def __lt__(self, other) -> bool: | ||
"""Whether on the left or below""" | ||
return self.x < other.x or self.y < other.y | ||
|
||
def __gt__(self, other) -> bool: | ||
"""Whether on the right and above""" | ||
return ( | ||
(self.x > other.x and self.y > other.y) | ||
or (self.x == other.x and self.y > other.y) | ||
or (self.x > other.x and self.y == other.y) | ||
) | ||
|
||
def __le__(self, other) -> bool: | ||
return self.__lt__(other) or self.__eq__(other) | ||
|
||
def __ge__(self, other) -> bool: | ||
return self.__gt__(other) or self.__eq__(other) | ||
|
||
def __str__(self) -> str: | ||
return f"({self.x}, {self.y})" | ||
|
||
|
||
class CoordOffset(Coord): | ||
"""Coordinate offset class""" | ||
|
||
def __init__(self, _x: int, _y: int) -> None: | ||
if not (-32 < _x < 32 and -32 < _y < 32): | ||
raise ValueError(f"-32 < x < 32, -32 < y < 32: ({_x}, {_y})") | ||
|
||
self.x, self.y = _x, _y | ||
|
||
def __add__(self, other): | ||
if isinstance(other, CoordOffset): | ||
return CoordOffset(self.x + other.x, self.y + other.y) | ||
else: | ||
return Coord(self.x + other.x, self.y + other.y) | ||
|
||
def __sub__(self, other) -> "CoordOffset": | ||
if isinstance(other, Coord): | ||
raise TypeError("A CoordOffset cannot substract a Coord") | ||
|
||
return CoordOffset(self.x - other.x, self.y - other.y) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import overload, Tuple | ||
|
||
class Coord: | ||
x: int = ... | ||
y: int = ... | ||
@overload | ||
def __init__(self, _x: Tuple[int, int]) -> None: ... | ||
@overload | ||
def __init__(self, _x: int, _y: int) -> None: ... | ||
def __add__(self, other) -> Coord: ... | ||
def __sub__(self, other) -> CoordOffset: ... | ||
def __eq__(self, other) -> bool: ... | ||
def __ne__(self, other) -> bool: ... | ||
def __lt__(self, other) -> bool: ... | ||
def __gt__(self, other) -> bool: ... | ||
def __le__(self, other) -> bool: ... | ||
def __ge__(self, other) -> bool: ... | ||
def __str__(self) -> str: ... | ||
|
||
__repr__ = __str__ | ||
|
||
class CoordOffset(Coord): | ||
def __init__(self, _x: int, _y: int) -> None: ... | ||
def __add__(self, other) -> CoordOffset | Coord: ... | ||
def __sub__(self, other) -> CoordOffset: ... |
Oops, something went wrong.