diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index fd8347c..e1b6530 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -17,9 +17,9 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x' @@ -44,11 +44,11 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install iverilog run: sudo apt install iverilog - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x' @@ -90,9 +90,9 @@ jobs: python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] name: Python ${{ matrix.python-version }} test steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 @@ -107,9 +107,9 @@ jobs: needs: test if: github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x' @@ -123,7 +123,7 @@ jobs: - name: Generate documentation run: pdoc --html ariths_gen - name: Upload results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: documentation path: html diff --git a/ariths_gen/multi_bit_circuits/others/popcount.py b/ariths_gen/multi_bit_circuits/others/popcount.py index 04fcda3..4721bce 100644 --- a/ariths_gen/multi_bit_circuits/others/popcount.py +++ b/ariths_gen/multi_bit_circuits/others/popcount.py @@ -1,7 +1,7 @@ """ """ -from typing import Union +from typing import Union, Optional from ariths_gen.wire_components import ( Wire, @@ -45,7 +45,7 @@ class UnsignedPopCount(GeneralCircuit): """ - def __init__(self, a: Bus, adder : Union[ArithmeticCircuit, None] = None, prefix : str = "", name : str = "popcnt", **kwargs): + def __init__(self, a: Bus, adder : Optional[ArithmeticCircuit] = None, prefix : str = "", name : str = "popcnt", **kwargs): self.N = a.N self.a = a diff --git a/tests/test_all.py b/tests/test_all.py index bcd9342..5a22005 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -381,6 +381,25 @@ def test_wire_as_bus(): assert r.sum() == 1 assert r[-1, -1, -1] == 1 +def test_unique(): + from ariths_gen.wire_components import Wire, Bus + import pytest + import sys + from ariths_gen.one_bit_circuits.logic_gates import AndGate + from ariths_gen.one_bit_circuits.one_bit_components import TwoOneMultiplexer + from ariths_gen.core.arithmetic_circuits import GeneralCircuit + + class test_circuit(GeneralCircuit): + def __init__(self, a: Bus, prefix="test_circuit", **kwargs): + super().__init__(prefix=prefix, name="test_circuit", inputs=[a], out_N=1, **kwargs) + g = self.add_component(AndGate(a[0], a[1], prefix="g2")) + g2 = self.add_component(AndGate(g.out, a[2], prefix="g2")) + g3 = self.add_component(AndGate(g2.out, g.out, prefix="g2")) + self.out[0] = g3.out + + with pytest.raises(AssertionError): + circ = test_circuit(Bus("a", 3), "c1") + circ.get_v_code_flat(file_object=sys.stdout) if __name__ == "__main__": test_unsigned_approxmul() diff --git a/tests/test_popcnt.py b/tests/test_popcnt.py index 52de63f..a877254 100644 --- a/tests/test_popcnt.py +++ b/tests/test_popcnt.py @@ -1,3 +1,4 @@ +from io import StringIO from ariths_gen.core.cgp_circuit import UnsignedCGPCircuit from ariths_gen.wire_components import ( Wire, @@ -11,6 +12,7 @@ from ariths_gen.core.arithmetic_circuits import GeneralCircuit from ariths_gen.multi_bit_circuits.others import ( UnsignedPopCount ) +import numpy as np def test_popcount():