From 8f8d923c5c56014c191a3972168f42cabf963eec Mon Sep 17 00:00:00 2001 From: lschoe Date: Mon, 29 Apr 2024 17:14:57 +0200 Subject: [PATCH] Add .codecov.yml, and minor edits. --- .codecov.yml | 9 ++ README.md | 2 +- demos/SecretSantaExplained.ipynb | 153 ++++++++++++++++--------------- demos/SecretSantaExplained.py | 2 +- 4 files changed, 88 insertions(+), 78 deletions(-) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..5033d136 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,9 @@ +coverage: + status: + patch: + default: + threshold: 10% + only_pulls: true + project: + default: + threshold: 1% diff --git a/README.md b/README.md index a81e759a..de6a9b4d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ The [MPyC homepage](https://www.win.tue.nl/~berry/mpyc/) has some more info and ## Installation -Pure Python, no dependencies. Python 3.9+ (following [SPEC 0 — Minimum Supported Dependencies](https://scientific-python.org/specs/spec-0000/)). +Pure Python, no dependencies. Python 3.9+ (following [SPEC 0 -- Minimum Supported Dependencies](https://scientific-python.org/specs/spec-0000/)). Run `pip install .` in the root directory (containing file `setup.py`).\ Or, run `pip install -e .`, if you want to edit the MPyC source files. diff --git a/demos/SecretSantaExplained.ipynb b/demos/SecretSantaExplained.ipynb index d71fbf27..52860c07 100644 --- a/demos/SecretSantaExplained.ipynb +++ b/demos/SecretSantaExplained.ipynb @@ -75,7 +75,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-04-15 13:03:02,082 Start MPyC runtime v0.9.2\n" + "2024-04-29 16:51:29,897 Start MPyC runtime v0.10.1\n" ] } ], @@ -187,7 +187,7 @@ "\n", "4. `mpc.returnType(rettype)` to define the return type of an MPyC coroutine.\n", "\n", - "We have defined function `random_derangement` as a coroutine because from its body we call function `mpc.is_zero_public`, which is also a coroutine, and we need its the result to follow the correct branch of the `if` statement. The execution of `random_derangement` is suspended at the `await` keyword, and will be resumed once the result `mpc.is_zero_public(t)` is available.\n", + "We have defined function `random_derangement` as a coroutine because from its body we call function `mpc.is_zero_public`, which is also a coroutine, and we need the result to follow the correct branch of the `if` statement. The execution of `random_derangement` is suspended at the `await` keyword, and will be resumed once the result `mpc.is_zero_public(t)` is available.\n", "\n", "## Random permutations from random unit vectors\n", "\n", @@ -318,12 +318,12 @@ "text": [ "Random unit vectors:\n", " 1 [1]\n", - " 2 [1, 0]\n", - " 3 [0, 1, 0]\n", - " 4 [0, 0, 1, 0]\n", - " 5 [0, 1, 0, 0, 0]\n", - " 6 [1, 0, 0, 0, 0, 0]\n", - " 7 [0, 0, 0, 0, 1, 0, 0]\n" + " 2 [0, 1]\n", + " 3 [1, 0, 0]\n", + " 4 [0, 1, 0, 0]\n", + " 5 [0, 0, 1, 0, 0]\n", + " 6 [0, 0, 1, 0, 0, 0]\n", + " 7 [0, 0, 0, 0, 0, 1, 0]\n" ] } ], @@ -348,11 +348,11 @@ "Random permutations:\n", " 1 [0]\n", " 2 [1, 0]\n", - " 3 [1, 2, 0]\n", - " 4 [3, 0, 2, 1]\n", - " 5 [2, 0, 1, 4, 3]\n", - " 6 [1, 0, 4, 3, 5, 2]\n", - " 7 [6, 0, 4, 3, 5, 1, 2]\n" + " 3 [1, 0, 2]\n", + " 4 [0, 2, 3, 1]\n", + " 5 [0, 1, 3, 2, 4]\n", + " 6 [2, 3, 1, 5, 0, 4]\n", + " 7 [0, 1, 3, 2, 4, 6, 5]\n" ] } ], @@ -377,10 +377,10 @@ "Random derangements:\n", " 2 [1, 0]\n", " 3 [2, 0, 1]\n", - " 4 [1, 0, 3, 2]\n", - " 5 [3, 4, 1, 2, 0]\n", - " 6 [3, 4, 1, 5, 2, 0]\n", - " 7 [1, 5, 3, 6, 0, 2, 4]\n" + " 4 [2, 0, 3, 1]\n", + " 5 [1, 4, 3, 2, 0]\n", + " 6 [3, 0, 5, 2, 1, 4]\n", + " 7 [1, 4, 0, 5, 6, 3, 2]\n" ] } ], @@ -402,7 +402,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-04-15 13:03:02,230 Stop MPyC -- elapsed time: 0:00:00.148|bytes sent: 0\n" + "2024-04-29 16:51:30,068 Stop MPyC -- elapsed time: 0:00:00.168|bytes sent: 0\n" ] } ], @@ -428,7 +428,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "C:\\Users\\Berry\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3513: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n", + "C:\\Users\\Berry\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3377: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.\n", " warn(\"To exit: use 'exit', 'quit', or Ctrl-D.\", stacklevel=1)\n" ] } @@ -462,32 +462,32 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-04-15 13:03:23,698 Start MPyC runtime v0.9.2\n", + "2024-04-29 16:51:36,774 Start MPyC runtime v0.10.1\n", "Example: (5+13)*(5-13) = -144\n", "Random unit vectors:\n", " 1 [1]\n", " 2 [0, 1]\n", - " 3 [0, 0, 1]\n", + " 3 [0, 1, 0]\n", " 4 [0, 0, 1, 0]\n", - " 5 [0, 1, 0, 0, 0]\n", - " 6 [1, 0, 0, 0, 0, 0]\n", - " 7 [0, 0, 0, 0, 1, 0, 0]\n", + " 5 [0, 0, 0, 1, 0]\n", + " 6 [0, 0, 1, 0, 0, 0]\n", + " 7 [0, 0, 0, 1, 0, 0, 0]\n", "Random permutations:\n", " 1 [0]\n", " 2 [1, 0]\n", - " 3 [0, 2, 1]\n", - " 4 [1, 3, 2, 0]\n", - " 5 [4, 1, 3, 2, 0]\n", - " 6 [5, 0, 3, 4, 2, 1]\n", - " 7 [3, 0, 5, 1, 4, 2, 6]\n", + " 3 [2, 1, 0]\n", + " 4 [3, 2, 1, 0]\n", + " 5 [0, 2, 3, 4, 1]\n", + " 6 [2, 4, 3, 0, 1, 5]\n", + " 7 [1, 4, 3, 5, 6, 2, 0]\n", "Random derangements:\n", " 2 [1, 0]\n", - " 3 [2, 0, 1]\n", - " 4 [3, 2, 1, 0]\n", - " 5 [3, 4, 0, 1, 2]\n", - " 6 [3, 0, 4, 5, 2, 1]\n", - " 7 [4, 5, 6, 2, 1, 0, 3]\n", - "2023-04-15 13:03:23,737 Stop MPyC -- elapsed time: 0:00:00.039|bytes sent: 0\n" + " 3 [1, 2, 0]\n", + " 4 [2, 3, 1, 0]\n", + " 5 [4, 0, 3, 1, 2]\n", + " 6 [1, 3, 0, 2, 5, 4]\n", + " 7 [3, 4, 6, 2, 1, 0, 5]\n", + "2024-04-29 16:51:36,821 Stop MPyC -- elapsed time: 0:00:00.046|bytes sent: 0\n" ] } ], @@ -515,8 +515,8 @@ " [-T t] [-B b] [--ssl] [-W w] [-L l] [-K k]\n", " [--log-level ll] [--no-log] [--no-async]\n", " [--no-barrier] [--no-gmpy2] [--no-numpy]\n", - " [--no-prss] [--mix32-64bit] [--output-windows]\n", - " [--output-file] [-f F]\n", + " [--no-uvloop] [--no-prss] [--mix32-64bit]\n", + " [--output-windows] [--output-file] [-f F]\n", "\n", "MPyC help:\n", " -V, --VERSION print MPyC version number and exit\n", @@ -542,6 +542,7 @@ " --no-barrier disable barriers\n", " --no-gmpy2 disable use of gmpy2 package\n", " --no-numpy disable use of numpy package\n", + " --no-uvloop disable use of uvloop (winloop) package\n", " --no-prss disable use of PRSS (pseudorandom secret sharing)\n", " --mix32-64bit enable mix of 32-bit and 64-bit platforms\n", "\n", @@ -574,33 +575,33 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-04-15 13:03:24,451 Start MPyC runtime v0.9.2\n", - "2023-04-15 13:03:25,077 All 3 parties connected via SSL.\n", + "2024-04-29 16:51:43,244 Start MPyC runtime v0.10.1\n", + "2024-04-29 16:51:43,913 All 3 parties connected via SSL.\n", "Example: (5+13)*(5-13) = -144\n", "Random unit vectors:\n", " 1 [1]\n", - " 2 [1, 0]\n", - " 3 [0, 1, 0]\n", - " 4 [1, 0, 0, 0]\n", - " 5 [0, 1, 0, 0, 0]\n", - " 6 [0, 0, 1, 0, 0, 0]\n", - " 7 [0, 0, 0, 0, 0, 0, 1]\n", + " 2 [0, 1]\n", + " 3 [1, 0, 0]\n", + " 4 [0, 1, 0, 0]\n", + " 5 [0, 0, 1, 0, 0]\n", + " 6 [0, 0, 0, 0, 0, 1]\n", + " 7 [0, 0, 0, 0, 1, 0, 0]\n", "Random permutations:\n", " 1 [0]\n", " 2 [1, 0]\n", - " 3 [0, 2, 1]\n", - " 4 [1, 2, 0, 3]\n", - " 5 [1, 4, 2, 0, 3]\n", - " 6 [3, 0, 4, 5, 2, 1]\n", - " 7 [1, 5, 6, 0, 4, 2, 3]\n", + " 3 [0, 1, 2]\n", + " 4 [3, 1, 0, 2]\n", + " 5 [4, 0, 1, 2, 3]\n", + " 6 [3, 1, 5, 4, 0, 2]\n", + " 7 [2, 5, 3, 4, 1, 0, 6]\n", "Random derangements:\n", " 2 [1, 0]\n", - " 3 [1, 2, 0]\n", - " 4 [3, 2, 1, 0]\n", - " 5 [4, 3, 1, 2, 0]\n", - " 6 [2, 0, 1, 4, 5, 3]\n", - " 7 [1, 4, 3, 0, 5, 6, 2]\n", - "2023-04-15 13:03:25,304 Stop MPyC -- elapsed time: 0:00:00.227|bytes sent: 24834\n" + " 3 [2, 0, 1]\n", + " 4 [1, 0, 3, 2]\n", + " 5 [4, 2, 3, 0, 1]\n", + " 6 [4, 5, 0, 1, 2, 3]\n", + " 7 [4, 3, 1, 5, 2, 6, 0]\n", + "2024-04-29 16:51:44,290 Stop MPyC -- elapsed time: 0:00:00.377|bytes sent: 35544\n" ] } ], @@ -626,33 +627,33 @@ "name": "stdout", "output_type": "stream", "text": [ - "2023-04-15 13:03:25,714 Start MPyC runtime v0.9.2\n", - "2023-04-15 13:03:26,243 All 8 parties connected.\n", + "2024-04-29 16:51:49,998 Start MPyC runtime v0.10.1\n", + "2024-04-29 16:51:50,569 All 8 parties connected.\n", "Example: (5+13)*(5-13) = -144\n", "Random unit vectors:\n", " 1 [1]\n", " 2 [0, 1]\n", - " 3 [0, 1, 0]\n", - " 4 [1, 0, 0, 0]\n", - " 5 [0, 0, 1, 0, 0]\n", - " 6 [0, 0, 0, 0, 0, 1]\n", - " 7 [1, 0, 0, 0, 0, 0, 0]\n", + " 3 [1, 0, 0]\n", + " 4 [0, 1, 0, 0]\n", + " 5 [1, 0, 0, 0, 0]\n", + " 6 [0, 0, 0, 0, 1, 0]\n", + " 7 [0, 0, 1, 0, 0, 0, 0]\n", "Random permutations:\n", " 1 [0]\n", - " 2 [1, 0]\n", - " 3 [1, 0, 2]\n", - " 4 [2, 1, 0, 3]\n", - " 5 [3, 4, 1, 0, 2]\n", - " 6 [5, 4, 3, 2, 1, 0]\n", - " 7 [4, 5, 1, 3, 6, 2, 0]\n", + " 2 [0, 1]\n", + " 3 [0, 2, 1]\n", + " 4 [1, 2, 0, 3]\n", + " 5 [4, 2, 0, 3, 1]\n", + " 6 [1, 0, 2, 5, 3, 4]\n", + " 7 [3, 1, 2, 0, 6, 5, 4]\n", "Random derangements:\n", " 2 [1, 0]\n", - " 3 [2, 0, 1]\n", - " 4 [2, 3, 1, 0]\n", - " 5 [2, 4, 3, 1, 0]\n", - " 6 [5, 4, 3, 2, 1, 0]\n", - " 7 [5, 2, 4, 0, 6, 3, 1]\n", - "2023-04-15 13:03:26,829 Stop MPyC -- elapsed time: 0:00:00.586|bytes sent: 73192\n" + " 3 [1, 2, 0]\n", + " 4 [1, 0, 3, 2]\n", + " 5 [1, 3, 4, 0, 2]\n", + " 6 [3, 2, 0, 1, 5, 4]\n", + " 7 [5, 2, 3, 6, 1, 0, 4]\n", + "2024-04-29 16:51:51,080 Stop MPyC -- elapsed time: 0:00:00.511|bytes sent: 99488\n" ] } ], @@ -684,7 +685,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.11" } }, "nbformat": 4, diff --git a/demos/SecretSantaExplained.py b/demos/SecretSantaExplained.py index 89afc5c5..0dca1491 100644 --- a/demos/SecretSantaExplained.py +++ b/demos/SecretSantaExplained.py @@ -108,7 +108,7 @@ async def random_derangement(n): # returns list of n secint ele # # 4. `mpc.returnType(rettype)` to define the return type of an MPyC coroutine. # -# We have defined function `random_derangement` as a coroutine because from its body we call function `mpc.is_zero_public`, which is also a coroutine, and we need its the result to follow the correct branch of the `if` statement. The execution of `random_derangement` is suspended at the `await` keyword, and will be resumed once the result `mpc.is_zero_public(t)` is available. +# We have defined function `random_derangement` as a coroutine because from its body we call function `mpc.is_zero_public`, which is also a coroutine, and we need the result to follow the correct branch of the `if` statement. The execution of `random_derangement` is suspended at the `await` keyword, and will be resumed once the result `mpc.is_zero_public(t)` is available. # # ## Random permutations from random unit vectors #