From 4d98e74255e875bef9a63cd8795f4f9768bcb981 Mon Sep 17 00:00:00 2001 From: apassenger Date: Mon, 6 May 2019 11:04:54 +0200 Subject: [PATCH 1/7] nPartyCoinFlip Users can add parties that they want to add(not only 4 party) --- .../pythonLib/coinflipLeader/nPartyCoinFlip | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/pythonLib/coinflipLeader/nPartyCoinFlip diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip b/examples/pythonLib/coinflipLeader/nPartyCoinFlip new file mode 100644 index 0000000..bb0b69a --- /dev/null +++ b/examples/pythonLib/coinflipLeader/nPartyCoinFlip @@ -0,0 +1,30 @@ +from cqc.pythonLib_protocols.coinflip_leader import CoinflipConsensus + + +def main(): + + leaderChooser = CoinflipConsensus(arr) + return leaderChooser.leader() + + + +arr = [] +veri = input("Add person") +while veri: + arr.append(veri) + veri = input("Add person") + + + +d = dict() +for veri in arr: + d[veri] = 0 + + +for i in range(0, 20): + if i % 10 == 0: + print(i) + d[main()] += 1 + + +print(d) From 006a7b1183dc16665aa6d2c4cb84913a162518bc Mon Sep 17 00:00:00 2001 From: apassenger Date: Mon, 6 May 2019 11:05:27 +0200 Subject: [PATCH 2/7] Rename nPartyCoinFlip to nPartyCoinFlip.py --- .../coinflipLeader/{nPartyCoinFlip => nPartyCoinFlip.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename examples/pythonLib/coinflipLeader/{nPartyCoinFlip => nPartyCoinFlip.py} (100%) diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py similarity index 100% rename from examples/pythonLib/coinflipLeader/nPartyCoinFlip rename to examples/pythonLib/coinflipLeader/nPartyCoinFlip.py From 3b82c9c235a51630eab65dd90f494936e1756331 Mon Sep 17 00:00:00 2001 From: apassenger Date: Tue, 21 May 2019 17:43:28 +0300 Subject: [PATCH 3/7] Update nPartyCoinFlip.py --- .../coinflipLeader/nPartyCoinFlip.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py index bb0b69a..b01041f 100644 --- a/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py +++ b/examples/pythonLib/coinflipLeader/nPartyCoinFlip.py @@ -3,24 +3,27 @@ def main(): - leaderChooser = CoinflipConsensus(arr) + leaderChooser = CoinflipConsensus(arr) # Elects a leader from array that you declared return leaderChooser.leader() - - -arr = [] -veri = input("Add person") -while veri: +# For 12-13-14-15 lines: After seeing "Add person" sentence, you can add person that how many person you want to add. +# After adding one person you should press "enter" and then you can continue to add person with press enter +# If you want to cancel from adding person you should press enter again +# After enter the all name that you wanted to add you should press "enter" +# Note that: you should use name from cqc's names space such as Alice, Bob, David, Eve Charlie.., you cant't use name randomly such as Gozde, Axel ... +arr = [] # Here an empty array was defined +veri = input("Add person") +while veri: arr.append(veri) veri = input("Add person") - +# giving a value for each leader d = dict() for veri in arr: d[veri] = 0 - +# Runs 20 rounds of leader election and prints the results. for i in range(0, 20): if i % 10 == 0: print(i) From 5fcdac981dedfc2f7d166e342e1436e2e977913d Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Wed, 22 May 2019 09:38:01 +0200 Subject: [PATCH 4/7] Updated README for coinflip example --- examples/pythonLib/coinflipLeader/README.txt | 23 ++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/examples/pythonLib/coinflipLeader/README.txt b/examples/pythonLib/coinflipLeader/README.txt index 77795dd..6b17bec 100644 --- a/examples/pythonLib/coinflipLeader/README.txt +++ b/examples/pythonLib/coinflipLeader/README.txt @@ -2,13 +2,28 @@ ## How to run +First make sure that simulaqron is started with the nodes you'd want to include. +This can be done with for example `simulaqron start` which by default starts a network +with the nodes Alice, Bob, Charlie, David and Eve. +Note that you need to be using either the qutip or projectq backend, since single-qubit +rotations are used which are not supported in stabilizer formalism. +To change the backend do `simulaqron set backend projectq`, which of course requires projectq +to be installed (`pip install projectq`). + +In this folder there is both an example with the four nodes Alice, Bob, Charlie and David +and one where you can dynamically choose the nodes that the example uses. + +To start either of the examples do +``` +python3 fourPartyCoinFlip.py +``` +or ``` -sh $NETSIM/run/startAll.sh -./run.sh +python3 nPartyCoinFlip.py ``` -Note that you need to give the nodes a few seconds to start up after running -the first command. +When running `nPartyCoinFlip.py` fill in the names you want to use (note that these needs to +be in the current running network) and press enter when you're finished. ## Explanation From fc3cfe21fd2c62bbcfd114321c1b085a48038874 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Tue, 28 May 2019 18:10:35 +0200 Subject: [PATCH 5/7] Added travis.yml for CI --- .travis.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..e6b5f8b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +dist: xenial +language: python +python: + - "3.6" + - "3.7" +before_install: + - make build +install: + - pip3 install dist/*.whl +script: + - make lint From 8ca12f2b3bcd18ca9d41bee1fcb4b26c141cf441 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Wed, 29 May 2019 17:33:35 +0200 Subject: [PATCH 6/7] Updated CI and version --- .travis.yml | 36 +++++++++++++++++++++++++++++------- CHANGELOG.md | 11 +++++++++++ cqc/__init__.py | 2 +- 3 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.travis.yml b/.travis.yml index e6b5f8b..1f314f3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,33 @@ -dist: xenial language: python -python: - - "3.6" - - "3.7" +only: +- master +- Develop +matrix: + include: + - name: Python 3.5 on Linux + python: 3.5 + - name: Python 3.6 on Linux + python: 3.6 + env: + - BUILD=True + - name: Python 3.7 on Xenial Linux + python: 3.7 + dist: xenial + - name: Python 3.7 on macOS + os: osx + osx_image: xcode10.2 + language: shell before_install: - - make build +- make build install: - - pip3 install dist/*.whl +- pip3 install dist/*.whl script: - - make lint +- make lint +deploy: + provider: pypi + user: adahlberg + password: + secure: cQUlOGHX5ksULLBM2kOE9s2hdaJn4WK8rhD4LUuWndUG7rLeqtVfEMVrqWuMmzWcHXKOti143vgthSgp+akixfnQD7jWupVVSRiz5SFgq+1DRezGlkvYcZz2833on28lNFRiTjuPHkY3WoK0sS1iESxwTBvvi4y+q+AGtFzKE8hr+Pej+HnqFMMeXfqE7d/ZhoOrcBiRRcOrV/2JjpET5CMqimCYR4rz25yzpvVWlakC24vCqGs0Py+JL+VlZszjQz25NAQuuVwOAKnH/bapCV/JFmpvrFF5gKqAly9d1/+ZVgQVT9swMPjwmQs3zQ9E7IlL+4BPhdDly1H/GchyTRvf3uFt6Lok8ySvDyIkZUM2HlIoJIJCAESRCoEK7K7t1ySovBKjXI1Jc8O3QhAvdVMFWPpVxq5ZKwvUAEKtt7vRzN2KVmSi1nJxEzL89iuZkUtihws6DD8Y/6VgcemCFEZlP8ubxxRqR6gSaAhxSHppTdlNK2xUKq5AOwuS8A/3ur7SsMGasmMXTgQ/ElkrlHSZDvub4A89EMxfCMKrutIDPXSdpgYkmAvMFBsop+il/HJwWLc14xiNRsod4XVV5143M3pGg1wNKCifl2tTjbgoho9kFyso6RFkK28Qy3oSqZ+Sdw346M6jD6r2JVm7xsQZI7a5iR2Uq3PESkjkTP0= + on: + tags: true + condition: $BUILD = True diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..00d68a7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +CHANGELOG +========= + +For more details refer to the [documentation](https://softwarequtech.github.io/SimulaQron/html/index.html). + +Upcoming +-------- + +2019-05-29 (v3.0.2) +------------------- +- Updated coinflip example and added CI. diff --git a/cqc/__init__.py b/cqc/__init__.py index b7a5531..da4039b 100644 --- a/cqc/__init__.py +++ b/cqc/__init__.py @@ -1 +1 @@ -__version__ = '3.0.1' +__version__ = '3.0.2' From 25fc3bcb9fb320d8dfe20587074f9b996e293f32 Mon Sep 17 00:00:00 2001 From: Axel Dahlberg Date: Wed, 29 May 2019 17:48:35 +0200 Subject: [PATCH 7/7] Changed ModuleNotFoundError to ImportError to support python3.5 --- cqc/pythonLib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cqc/pythonLib.py b/cqc/pythonLib.py index f7a1351..8c4aa6a 100644 --- a/cqc/pythonLib.py +++ b/cqc/pythonLib.py @@ -97,7 +97,7 @@ from simulaqron.settings import simulaqron_settings _simulaqron_version = simulaqron.__version__ _simulaqron_major = int(_simulaqron_version.split('.')[0]) -except ModuleNotFoundError: +except ImportError: _simulaqron_major = -1