Skip to content

Commit

Permalink
Type fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekcyjna committed Mar 17, 2024
1 parent f560816 commit a33e930
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/transactions/test_transactron_lib_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.common import *
from transactron.testing import *
import random
from transactron.lib.storage import ContentAddressableMemory

Expand Down
2 changes: 1 addition & 1 deletion test/utils/test_amaranth_ext.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from test.common import *
from transactron.testing import *
import random
from transactron.utils.amaranth_ext import MultiPriorityEncoder

Expand Down
2 changes: 1 addition & 1 deletion transactron/lib/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class ContentAddressableMemory(Elaboratable):
Inserts new data.
"""

def __init__(self, address_layout: MethodLayout, data_layout: LayoutList, entries_number: int):
def __init__(self, address_layout: MethodLayout, data_layout: MethodLayout, entries_number: int):
"""
Parameters
----------
Expand Down
7 changes: 5 additions & 2 deletions transactron/testing/input_generation.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from amaranth import *
from amaranth.lib.data import StructLayout
import random
from typing import Optional
from hypothesis.strategies import composite, DrawFn, integers
from transactron.utils import LayoutList
from transactron.utils import MethodLayout

@composite
def generate_based_on_layout(draw : DrawFn, layout: LayoutList):
def generate_based_on_layout(draw : DrawFn, layout: MethodLayout):
if isinstance(layout, StructLayout):
raise NotImplementedError("StructLayout is not supported in automatic value generation.")
d = {}
for name, sublayout in layout:
if isinstance(sublayout, list):
Expand Down
4 changes: 2 additions & 2 deletions transactron/utils/data_repr.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Iterable, Mapping
from ._typing import LayoutList, ShapeLike
from ._typing import ShapeLike, MethodLayout
from typing import Any, Sized
from statistics import fmean
from amaranth.lib.data import StructLayout
Expand Down Expand Up @@ -78,7 +78,7 @@ def bits_from_int(num: int, lower: int, length: int):
return (num >> lower) & ((1 << (length)) - 1)


def data_layout(val: ShapeLike) -> SimpleLayout:
def data_layout(val: ShapeLike) -> MethodLayout:
return [("data", val)]


Expand Down
2 changes: 1 addition & 1 deletion transactron/utils/transactron_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def from_layout_field(shape: ShapeLike | LayoutList) -> ShapeLike:
return shape


def make_layout(*fields: LayoutListField):
def make_layout(*fields: LayoutListField) -> StructLayout:
return from_method_layout(fields)


Expand Down

0 comments on commit a33e930

Please sign in to comment.