Skip to content
Snippets Groups Projects
Commit d274e43b authored by angloth's avatar angloth
Browse files

Solve merge conflict in basic operation where old identifier was still used on develop

parents c063e9cb 541b1394
No related branches found
No related tags found
1 merge request!2Integrated ID system, traversing and som signal tests
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignEscapedNewlines: DontAlign
AlignOperands: false
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: true
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 140
CommentPragmas: ''
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros:
- Q_FOREACH
- BOOST_FOREACH
- FOREACH
- FOR_EACH
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<'
Priority: 2
- Regex: '.*'
Priority: 1
IncludeIsMainRegex: '(_test)?$'
IndentCaseLabels: true
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
NamespaceMacros:
- NAMESPACE
PenaltyBreakAssignment: 100
PenaltyBreakBeforeFirstCallParameter: 10
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 100
PenaltyBreakString: 10
PenaltyBreakTemplateDeclaration: 10000
PenaltyExcessCharacter: 999999
PenaltyReturnTypeOnItsOwnLine: 10000
PointerAlignment: Left
ReflowComments: false
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
- Q_UNUSED
TabWidth: 4
TypenameMacros:
- STACK_OF
- LIST
- LIST_ENTRY
UseTab: ForContinuationAndIndentation
\ No newline at end of file
...@@ -28,4 +28,6 @@ $RECYCLE.BIN/ ...@@ -28,4 +28,6 @@ $RECYCLE.BIN/
*.stackdump *.stackdump
[Dd]esktop.ini [Dd]esktop.ini
*.egg-info *.egg-info
__pycache__/ __pycache__/
\ No newline at end of file env/
venv/
\ No newline at end of file
...@@ -75,10 +75,5 @@ add_custom_target( ...@@ -75,10 +75,5 @@ add_custom_target(
copy_python_dir ALL copy_python_dir ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_NAME}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}" COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_NAME}" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}"
COMMENT "Copying python files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}" COMMENT "Copying python files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${LIBRARY_NAME}"
DEPENDS remove_old_python_dir DEPENDS "${TARGET_NAME}" remove_old_python_dir
)
add_custom_target(
copy_misc_files ALL
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_LIST_DIR}/README.md" "${CMAKE_CURRENT_LIST_DIR}/LICENSE" "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
COMMENT "Copying misc. files to ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
) )
\ No newline at end of file
...@@ -3,7 +3,10 @@ ...@@ -3,7 +3,10 @@
# B-ASIC - Better ASIC Toolbox # B-ASIC - Better ASIC Toolbox
B-ASIC is an ASIC toolbox for Python 3 that simplifies circuit design and optimization. B-ASIC is an ASIC toolbox for Python 3 that simplifies circuit design and optimization.
## Prerequisites ## Development
How to build and debug the library during development.
### Prerequisites
The following packages are required in order to build the library: The following packages are required in order to build the library:
* cmake 3.8+ * cmake 3.8+
* gcc 7+/clang 7+/msvc 16+ * gcc 7+/clang 7+/msvc 16+
...@@ -16,9 +19,6 @@ The following packages are required in order to build the library: ...@@ -16,9 +19,6 @@ The following packages are required in order to build the library:
* numpy * numpy
* pyside2/pyqt5 * pyside2/pyqt5
## Development
How to build and debug the library during development.
### Using CMake directly ### Using CMake directly
How to build using CMake. How to build using CMake.
...@@ -62,15 +62,41 @@ python3 setup.py sdist ...@@ -62,15 +62,41 @@ python3 setup.py sdist
The output gets written to `B-ASIC/dist/b-asic-<version>.tar.gz`. The output gets written to `B-ASIC/dist/b-asic-<version>.tar.gz`.
#### Installation (Binary distribution) #### Installation (Binary distribution)
In `B-ASIC`: In `B-ASIC/dist`:
``` ```
python3 -m pip install b_asic-<version>-<python_tag>-<abi_tag>-<platform_tag>.whl pip install b_asic-<version>-<python_tag>-<abi_tag>-<platform_tag>.whl
``` ```
#### Installation (Source distribution) #### Installation (Source distribution)
In `B-ASIC/dist`:
```
pip install b-asic-<version>.tar.gz
```
### Running tests
How to run the tests using pytest in a virtual environment.
#### Linux/OS X
In `B-ASIC`: In `B-ASIC`:
``` ```
python3 -m pip install b-asic-<version>.tar.gz python3 -m venv env
source env/bin/activate
pip install .
pytest
```
#### Windows
In `B-ASIC` (as admin):
```
python3 -m venv env
.\env\Scripts\activate.bat
pip install .
pytest
```
#### Test with coverage
```
pytest --cov=b_asic --cov-report html test
``` ```
## Usage ## Usage
...@@ -78,7 +104,7 @@ How to build and use the library as a user. ...@@ -78,7 +104,7 @@ How to build and use the library as a user.
### Installation ### Installation
``` ```
python3 -m pip install b_asic pip install b_asic
``` ```
### Importing ### Importing
...@@ -88,17 +114,6 @@ python3 ...@@ -88,17 +114,6 @@ python3
>>> help(asic) >>> help(asic)
``` ```
## Running tests
### pytest
Run all tests against installed version off b_asic using a virtual enviroment
In `B-ASIC`:
```
python3 -m venv .venv
source .venv/bin/activate
pip install .
pytest
```
## License ## License
B-ASIC is distributed under the MIT license. B-ASIC is distributed under the MIT license.
See the included LICENSE file for more information. See the included LICENSE file for more information.
...@@ -36,7 +36,7 @@ class BasicOperation(Operation): ...@@ -36,7 +36,7 @@ class BasicOperation(Operation):
Evaluate the operation and generate a list of output values given a list of input values. Evaluate the operation and generate a list of output values given a list of input values.
""" """
pass pass
def inputs(self) -> List[InputPort]: def inputs(self) -> List[InputPort]:
return self._input_ports.copy() return self._input_ports.copy()
......
...@@ -71,7 +71,8 @@ setuptools.setup( ...@@ -71,7 +71,8 @@ setuptools.setup(
"pybind11>=2.3.0", "pybind11>=2.3.0",
"numpy", "numpy",
"install_qt_binding", "install_qt_binding",
"pytest==5.3.4" "pytest==5.3.4",
"pytest-cov==2.8.1"
], ],
packages = ["b_asic"], packages = ["b_asic"],
ext_modules = [CMakeExtension("b_asic")], ext_modules = [CMakeExtension("b_asic")],
......
import pytest
from test.fixtures.signal import *
\ No newline at end of file
import pytest
from b_asic import Signal, SignalSource, SignalDestination, Addition
"""
Use a fixture for initializing objects and pass them as argument to a test function
"""
@pytest.fixture
def signal():
source = SignalSource(Addition(0), 1)
dest = SignalDestination(Addition(1), 2)
return Signal(0, source, dest)
@pytest.fixture
def signals():
ret = []
for i in range(0,3):
source = SignalSource(Addition(0), 1)
dest = SignalDestination(Addition(1), 2)
ret.append(Signal(i, source, dest))
return ret
\ No newline at end of file
"""
B-ASIC test suite for Inputport
"""
# import module we are testing
from b_asic import InputPort
# import dependencies
from b_asic import Signal, SignalSource, SignalDestination, Addition
import pytest
def test_connect_multiple_signals(signals):
"""
test if only one signal can connect to an input port
"""
inp_port = InputPort(0)
for s in signals:
inp_port.connect(s)
assert inp_port.signal_count() == 1
assert inp_port.signals()[0] == signals[-1]
\ No newline at end of file
"""
B-ASIC test suite for InputPort
TODO: More info
"""
from b_asic import OutputPort, Signal, SignalSource, SignalDestination, Addition
import pytest
def test_connect_multiple_signals(signals):
"""
test if multiple signals can connect to an output port
"""
outp_port = OutputPort(0)
for s in signals:
outp_port.connect(s)
assert outp_port.signal_count() == 3
assert outp_port.signals() == signals
\ No newline at end of file
"""
B-ASIC test suite for Port interface, place all general test cases for abstract class Port here
"""
from b_asic import InputPort, OutputPort, Signal, SignalSource, SignalDestination, Addition
import pytest
def test_connect_one_signal_to_port(signal):
port = InputPort(0)
port.connect(signal)
assert len(port.signals()) == 1
assert port.signal() == signal
def test_change_port_signal():
source = SignalSource(Addition(0), 1)
dest = SignalDestination(Addition(1),2)
signal1 = Signal(1, source, dest)
signal2 = Signal(2, source, dest)
port = InputPort(0)
port.connect(signal1)
assert port.signal() == signal1
port.connect(signal2)
assert port.signal() == signal2
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment