mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 20:25:34 -05:00
chore: update black to 22.3.0
This commit is contained in:
@@ -129,7 +129,7 @@ class Integer(BaseDataType):
|
||||
maximum value that can be represented by the `Integer`
|
||||
"""
|
||||
|
||||
return (2 ** self.bit_width) - 1 if not self.is_signed else (2 ** (self.bit_width - 1)) - 1
|
||||
return (2**self.bit_width) - 1 if not self.is_signed else (2 ** (self.bit_width - 1)) - 1
|
||||
|
||||
def can_represent(self, value: int) -> bool:
|
||||
"""
|
||||
|
||||
@@ -178,7 +178,7 @@ class Node:
|
||||
|
||||
result = self.evaluator(*args)
|
||||
|
||||
if isinstance(result, int) and -(2 ** 63) < result < (2 ** 63) - 1:
|
||||
if isinstance(result, int) and -(2**63) < result < (2**63) - 1:
|
||||
result = np.int64(result)
|
||||
if isinstance(result, float):
|
||||
result = np.float64(result)
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
python-dateutil 2.8.2 Apache Software License; BSD License
|
||||
setuptools-scm 6.4.2 MIT License
|
||||
six 1.16.0 MIT License
|
||||
tomli 1.2.3 MIT License
|
||||
tomli 2.0.1 MIT License
|
||||
torch 1.11.0 BSD License
|
||||
typing-extensions 4.2.0 Python Software Foundation License
|
||||
|
||||
72
poetry.lock
generated
72
poetry.lock
generated
@@ -130,25 +130,24 @@ lxml = ["lxml"]
|
||||
|
||||
[[package]]
|
||||
name = "black"
|
||||
version = "21.12b0"
|
||||
version = "22.3.0"
|
||||
description = "The uncompromising code formatter."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6.2"
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=7.1.2"
|
||||
click = ">=8.0.0"
|
||||
mypy-extensions = ">=0.4.3"
|
||||
pathspec = ">=0.9.0,<1"
|
||||
pathspec = ">=0.9.0"
|
||||
platformdirs = ">=2"
|
||||
tomli = ">=0.2.6,<2.0.0"
|
||||
typing-extensions = ">=3.10.0.0"
|
||||
tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""}
|
||||
typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""}
|
||||
|
||||
[package.extras]
|
||||
colorama = ["colorama (>=0.4.3)"]
|
||||
d = ["aiohttp (>=3.7.4)"]
|
||||
jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"]
|
||||
python2 = ["typed-ast (>=1.4.3)"]
|
||||
uvloop = ["uvloop (>=0.15.2)"]
|
||||
|
||||
[[package]]
|
||||
@@ -216,11 +215,11 @@ unicode_backport = ["unicodedata2"]
|
||||
|
||||
[[package]]
|
||||
name = "click"
|
||||
version = "8.0.4"
|
||||
version = "8.1.3"
|
||||
description = "Composable command line interface toolkit"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[package.dependencies]
|
||||
colorama = {version = "*", markers = "platform_system == \"Windows\""}
|
||||
@@ -688,7 +687,7 @@ i18n = ["Babel (>=2.7)"]
|
||||
|
||||
[[package]]
|
||||
name = "jsonschema"
|
||||
version = "4.4.0"
|
||||
version = "4.5.1"
|
||||
description = "An implementation of JSON Schema validation for Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -721,7 +720,7 @@ qtconsole = "*"
|
||||
|
||||
[[package]]
|
||||
name = "jupyter-client"
|
||||
version = "7.3.0"
|
||||
version = "7.3.1"
|
||||
description = "Jupyter protocol implementation and client libraries"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -2075,11 +2074,11 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*"
|
||||
|
||||
[[package]]
|
||||
name = "tomli"
|
||||
version = "1.2.3"
|
||||
version = "2.0.1"
|
||||
description = "A lil' TOML parser"
|
||||
category = "main"
|
||||
optional = false
|
||||
python-versions = ">=3.6"
|
||||
python-versions = ">=3.7"
|
||||
|
||||
[[package]]
|
||||
name = "tomlkit"
|
||||
@@ -2166,7 +2165,7 @@ python-versions = "*"
|
||||
|
||||
[[package]]
|
||||
name = "types-toml"
|
||||
version = "0.10.6"
|
||||
version = "0.10.7"
|
||||
description = "Typing stubs for toml"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@@ -2247,7 +2246,7 @@ full = ["pygraphviz"]
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.8,<3.10"
|
||||
content-hash = "37916208873844ab6d6cf1c4a6e34fff3f4d3500a5dae9bdbc5f6fdbfd548877"
|
||||
content-hash = "9cc6d8d2d79bcdcf129e3986cd5b4864f979f5cd5bfba14ebea0de39ad5ce6ef"
|
||||
|
||||
[metadata.files]
|
||||
alabaster = [
|
||||
@@ -2314,8 +2313,29 @@ beautifulsoup4 = [
|
||||
{file = "beautifulsoup4-4.10.0.tar.gz", hash = "sha256:c23ad23c521d818955a4151a67d81580319d4bf548d3d49f4223ae041ff98891"},
|
||||
]
|
||||
black = [
|
||||
{file = "black-21.12b0-py3-none-any.whl", hash = "sha256:a615e69ae185e08fdd73e4715e260e2479c861b5740057fde6e8b4e3b7dd589f"},
|
||||
{file = "black-21.12b0.tar.gz", hash = "sha256:77b80f693a569e2e527958459634f18df9b0ba2625ba4e0c2d5da5be42e6f2b3"},
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:2497f9c2386572e28921fa8bec7be3e51de6801f7459dffd6e62492531c47e09"},
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:5795a0375eb87bfe902e80e0c8cfaedf8af4d49694d69161e5bd3206c18618bb"},
|
||||
{file = "black-22.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3556168e2e5c49629f7b0f377070240bd5511e45e25a4497bb0073d9dda776a"},
|
||||
{file = "black-22.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:67c8301ec94e3bcc8906740fe071391bce40a862b7be0b86fb5382beefecd968"},
|
||||
{file = "black-22.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:fd57160949179ec517d32ac2ac898b5f20d68ed1a9c977346efbac9c2f1e779d"},
|
||||
{file = "black-22.3.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:cc1e1de68c8e5444e8f94c3670bb48a2beef0e91dddfd4fcc29595ebd90bb9ce"},
|
||||
{file = "black-22.3.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d2fc92002d44746d3e7db7cf9313cf4452f43e9ea77a2c939defce3b10b5c82"},
|
||||
{file = "black-22.3.0-cp36-cp36m-win_amd64.whl", hash = "sha256:a6342964b43a99dbc72f72812bf88cad8f0217ae9acb47c0d4f141a6416d2d7b"},
|
||||
{file = "black-22.3.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:328efc0cc70ccb23429d6be184a15ce613f676bdfc85e5fe8ea2a9354b4e9015"},
|
||||
{file = "black-22.3.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:06f9d8846f2340dfac80ceb20200ea5d1b3f181dd0556b47af4e8e0b24fa0a6b"},
|
||||
{file = "black-22.3.0-cp37-cp37m-win_amd64.whl", hash = "sha256:ad4efa5fad66b903b4a5f96d91461d90b9507a812b3c5de657d544215bb7877a"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e8477ec6bbfe0312c128e74644ac8a02ca06bcdb8982d4ee06f209be28cdf163"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:637a4014c63fbf42a692d22b55d8ad6968a946b4a6ebc385c5505d9625b6a464"},
|
||||
{file = "black-22.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:863714200ada56cbc366dc9ae5291ceb936573155f8bf8e9de92aef51f3ad0f0"},
|
||||
{file = "black-22.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:10dbe6e6d2988049b4655b2b739f98785a884d4d6b85bc35133a8fb9a2233176"},
|
||||
{file = "black-22.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:cee3e11161dde1b2a33a904b850b0899e0424cc331b7295f2a9698e79f9a69a0"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:5891ef8abc06576985de8fa88e95ab70641de6c1fca97e2a15820a9b69e51b20"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:30d78ba6bf080eeaf0b7b875d924b15cd46fec5fd044ddfbad38c8ea9171043a"},
|
||||
{file = "black-22.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:ee8f1f7228cce7dffc2b464f07ce769f478968bfb3dd1254a4c2eeed84928aad"},
|
||||
{file = "black-22.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ee227b696ca60dd1c507be80a6bc849a5a6ab57ac7352aad1ffec9e8b805f21"},
|
||||
{file = "black-22.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:9b542ced1ec0ceeff5b37d69838106a6348e60db7b8fdd245294dc1d26136265"},
|
||||
{file = "black-22.3.0-py3-none-any.whl", hash = "sha256:bc58025940a896d7e5356952228b68f793cf5fcb342be703c3a2669a1488cb72"},
|
||||
{file = "black-22.3.0.tar.gz", hash = "sha256:35020b8886c022ced9282b51b5a875b6d1ab0c387b31a065b84db7c33085ca79"},
|
||||
]
|
||||
bleach = [
|
||||
{file = "bleach-5.0.0-py3-none-any.whl", hash = "sha256:08a1fe86d253b5c88c92cc3d810fd8048a16d15762e1e5b74d502256e5926aa1"},
|
||||
@@ -2386,8 +2406,8 @@ charset-normalizer = [
|
||||
{file = "charset_normalizer-2.0.12-py3-none-any.whl", hash = "sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"},
|
||||
]
|
||||
click = [
|
||||
{file = "click-8.0.4-py3-none-any.whl", hash = "sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1"},
|
||||
{file = "click-8.0.4.tar.gz", hash = "sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"},
|
||||
{file = "click-8.1.3-py3-none-any.whl", hash = "sha256:bb4d8133cb15a609f44e8213d9b391b0809795062913b383c62be0ee95b1db48"},
|
||||
{file = "click-8.1.3.tar.gz", hash = "sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e"},
|
||||
]
|
||||
click-log = [
|
||||
{file = "click-log-0.4.0.tar.gz", hash = "sha256:3970f8570ac54491237bcdb3d8ab5e3eef6c057df29f8c3d1151a51a9c23b975"},
|
||||
@@ -2612,8 +2632,8 @@ jinja2 = [
|
||||
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
|
||||
]
|
||||
jsonschema = [
|
||||
{file = "jsonschema-4.4.0-py3-none-any.whl", hash = "sha256:77281a1f71684953ee8b3d488371b162419767973789272434bbc3f29d9c8823"},
|
||||
{file = "jsonschema-4.4.0.tar.gz", hash = "sha256:636694eb41b3535ed608fe04129f26542b59ed99808b4f688aa32dcf55317a83"},
|
||||
{file = "jsonschema-4.5.1-py3-none-any.whl", hash = "sha256:71b5e39324422543546572954ce71c67728922c104902cb7ce252e522235b33f"},
|
||||
{file = "jsonschema-4.5.1.tar.gz", hash = "sha256:7c6d882619340c3347a1bf7315e147e6d3dae439033ae6383d6acb908c101dfc"},
|
||||
]
|
||||
jupyter = [
|
||||
{file = "jupyter-1.0.0-py2.py3-none-any.whl", hash = "sha256:5b290f93b98ffbc21c0c7e749f054b3267782166d72fa5e3ed1ed4eaf34a2b78"},
|
||||
@@ -2621,8 +2641,8 @@ jupyter = [
|
||||
{file = "jupyter-1.0.0.zip", hash = "sha256:3e1f86076bbb7c8c207829390305a2b1fe836d471ed54be66a3b8c41e7f46cc7"},
|
||||
]
|
||||
jupyter-client = [
|
||||
{file = "jupyter_client-7.3.0-py3-none-any.whl", hash = "sha256:671dd2d90d03f41716b09627a4eb06bb37875f92bf6563cc2ce4fe71c61c5cda"},
|
||||
{file = "jupyter_client-7.3.0.tar.gz", hash = "sha256:3bcc8e08a294d0fa9406e48cfe17e11ef0efdb7c504fe8cc335128e3ef8f3dac"},
|
||||
{file = "jupyter_client-7.3.1-py3-none-any.whl", hash = "sha256:404abe552540aff3527e66e16beb114b6b4ff58479d51a301f4eb9701e4f52ef"},
|
||||
{file = "jupyter_client-7.3.1.tar.gz", hash = "sha256:05d4ff6a0ade25138c6bb0fbeac7ddc26b5fe835e7dd816b64b4a45b931bdc0b"},
|
||||
]
|
||||
jupyter-console = [
|
||||
{file = "jupyter_console-6.4.3-py3-none-any.whl", hash = "sha256:e630bcb682c0088dda45688ad7c2424d4a825c8acf494cb036ced03ed0424841"},
|
||||
@@ -3468,8 +3488,8 @@ toml = [
|
||||
{file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"},
|
||||
]
|
||||
tomli = [
|
||||
{file = "tomli-1.2.3-py3-none-any.whl", hash = "sha256:e3069e4be3ead9668e21cb9b074cd948f7b3113fd9c8bba083f48247aab8b11c"},
|
||||
{file = "tomli-1.2.3.tar.gz", hash = "sha256:05b6166bff487dc068d322585c7ea4ef78deed501cc124060e0f238e89a9231f"},
|
||||
{file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"},
|
||||
{file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"},
|
||||
]
|
||||
tomlkit = [
|
||||
{file = "tomlkit-0.7.0-py2.py3-none-any.whl", hash = "sha256:6babbd33b17d5c9691896b0e68159215a9387ebfa938aa3ac42f4a4beeb2b831"},
|
||||
@@ -3556,8 +3576,8 @@ types-setuptools = [
|
||||
{file = "types_setuptools-57.4.14-py3-none-any.whl", hash = "sha256:828f7e7e51e157876f47c80518b23ba0c3c36aa8081efd39d5d39f393938aec9"},
|
||||
]
|
||||
types-toml = [
|
||||
{file = "types-toml-0.10.6.tar.gz", hash = "sha256:6aeb3ed7bfa869381551c774ed6a9142e3eed98a83efa5108a9632eafd56dcd3"},
|
||||
{file = "types_toml-0.10.6-py3-none-any.whl", hash = "sha256:c1289e9fb748a6a1ed068694ded1eb16f83df22d58cc1abae8ef6262403545d8"},
|
||||
{file = "types-toml-0.10.7.tar.gz", hash = "sha256:a567fe2614b177d537ad99a661adc9bfc8c55a46f95e66370a4ed2dd171335f9"},
|
||||
{file = "types_toml-0.10.7-py3-none-any.whl", hash = "sha256:05a8da4bfde2f1ee60e90c7071c063b461f74c63a9c3c1099470c08d6fa58615"},
|
||||
]
|
||||
typing-extensions = [
|
||||
{file = "typing_extensions-4.2.0-py3-none-any.whl", hash = "sha256:6657594ee297170d19f67d55c05852a874e7eb634f4f753dbd667855e07c1708"},
|
||||
|
||||
@@ -53,9 +53,7 @@ extras = ["pygraphviz"]
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
isort = "^5.10.1"
|
||||
black = "^21.12b0"
|
||||
# pinning click due to: https://github.com/psf/black/issues/2964
|
||||
click = "8.0.4"
|
||||
black = "^22.3.0"
|
||||
pylint = "2.11.1"
|
||||
pytest = "^6.2.5"
|
||||
pytest-cov = "^3.0.0"
|
||||
|
||||
@@ -23,7 +23,7 @@ def test_circuit_str(helpers):
|
||||
def f(x, y):
|
||||
return x + y
|
||||
|
||||
inputset = [(np.random.randint(0, 2 ** 4), np.random.randint(0, 2 ** 5)) for _ in range(100)]
|
||||
inputset = [(np.random.randint(0, 2**4), np.random.randint(0, 2**5)) for _ in range(100)]
|
||||
circuit = f.compile(inputset, configuration)
|
||||
|
||||
assert str(circuit) == (
|
||||
@@ -49,7 +49,7 @@ def test_circuit_draw(helpers):
|
||||
def f(x, y):
|
||||
return x + y
|
||||
|
||||
inputset = [(np.random.randint(0, 2 ** 4), np.random.randint(0, 2 ** 5)) for _ in range(100)]
|
||||
inputset = [(np.random.randint(0, 2**4), np.random.randint(0, 2**5)) for _ in range(100)]
|
||||
circuit = f.compile(inputset, configuration)
|
||||
|
||||
with tempfile.TemporaryDirectory() as path:
|
||||
@@ -72,7 +72,7 @@ def test_circuit_bad_run(helpers):
|
||||
def f(x, y):
|
||||
return x + y
|
||||
|
||||
inputset = [(np.random.randint(0, 2 ** 4), np.random.randint(0, 2 ** 5)) for _ in range(100)]
|
||||
inputset = [(np.random.randint(0, 2**4), np.random.randint(0, 2**5)) for _ in range(100)]
|
||||
circuit = f.compile(inputset, configuration)
|
||||
|
||||
# with 1 argument
|
||||
@@ -143,7 +143,7 @@ def test_circuit_virtual_explicit_api(helpers):
|
||||
def f(x, y):
|
||||
return x + y
|
||||
|
||||
inputset = [(np.random.randint(0, 2 ** 4), np.random.randint(0, 2 ** 5)) for _ in range(100)]
|
||||
inputset = [(np.random.randint(0, 2**4), np.random.randint(0, 2**5)) for _ in range(100)]
|
||||
circuit = f.compile(inputset, configuration, virtual=True)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
|
||||
@@ -13,7 +13,7 @@ def identity_table_lookup_generator(n):
|
||||
Get identity table lookup function.
|
||||
"""
|
||||
|
||||
return lambda x: cnp.LookupTable(range(2 ** n))[x]
|
||||
return lambda x: cnp.LookupTable(range(2**n))[x]
|
||||
|
||||
|
||||
def random_table_lookup_1b(x):
|
||||
@@ -128,7 +128,7 @@ def negative_identity_table_lookup_generator(n):
|
||||
Get negative identity table lookup function.
|
||||
"""
|
||||
|
||||
return lambda x: cnp.LookupTable([-i for i in range(2 ** n)])[x]
|
||||
return lambda x: cnp.LookupTable([-i for i in range(2**n)])[x]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -168,10 +168,10 @@ def test_direct_table_lookup(bits, function, helpers):
|
||||
|
||||
compiler = cnp.Compiler(function, {"x": "encrypted"})
|
||||
|
||||
inputset = range(2 ** bits)
|
||||
inputset = range(2**bits)
|
||||
circuit = compiler.compile(inputset, configuration)
|
||||
|
||||
sample = int(np.random.randint(0, 2 ** bits))
|
||||
sample = int(np.random.randint(0, 2**bits))
|
||||
helpers.check_execution(circuit, function, sample, retries=10)
|
||||
|
||||
# tensor
|
||||
@@ -179,10 +179,10 @@ def test_direct_table_lookup(bits, function, helpers):
|
||||
|
||||
compiler = cnp.Compiler(function, {"x": "encrypted"})
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** bits, size=(3, 2), dtype=np.uint8) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**bits, size=(3, 2), dtype=np.uint8) for _ in range(100)]
|
||||
circuit = compiler.compile(inputset, configuration)
|
||||
|
||||
sample = np.random.randint(0, 2 ** bits, size=(3, 2), dtype=np.uint8)
|
||||
sample = np.random.randint(0, 2**bits, size=(3, 2), dtype=np.uint8)
|
||||
helpers.check_execution(circuit, function, sample, retries=10)
|
||||
|
||||
|
||||
@@ -209,10 +209,10 @@ def test_direct_multi_table_lookup(helpers):
|
||||
|
||||
compiler = cnp.Compiler(function, {"x": "encrypted"})
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 2, size=(3, 2), dtype=np.uint8) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**2, size=(3, 2), dtype=np.uint8) for _ in range(100)]
|
||||
circuit = compiler.compile(inputset, configuration)
|
||||
|
||||
sample = np.random.randint(0, 2 ** 2, size=(3, 2), dtype=np.uint8)
|
||||
sample = np.random.randint(0, 2**2, size=(3, 2), dtype=np.uint8)
|
||||
helpers.check_execution(circuit, function, sample, retries=10)
|
||||
|
||||
|
||||
|
||||
@@ -173,14 +173,14 @@ def fusable_with_one_of_the_start_nodes_is_lca_generator():
|
||||
id="(127 / x).astype(np.int64)",
|
||||
),
|
||||
pytest.param(
|
||||
lambda x: x ** 2,
|
||||
lambda x: x**2,
|
||||
{
|
||||
"x": {"status": "encrypted", "range": [0, 11]},
|
||||
},
|
||||
id="x ** 2",
|
||||
),
|
||||
pytest.param(
|
||||
lambda x: 2 ** x,
|
||||
lambda x: 2**x,
|
||||
{
|
||||
"x": {"status": "encrypted", "range": [0, 6]},
|
||||
},
|
||||
@@ -571,7 +571,7 @@ return %4
|
||||
return np.abs(np.sin(x)).reshape((2, 3)).astype(np.int64)
|
||||
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
inputset = [np.random.randint(0, 2 ** 7, size=(3, 2)) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**7, size=(3, 2)) for _ in range(100)]
|
||||
function3.compile(inputset, configuration)
|
||||
|
||||
helpers.check_str(
|
||||
|
||||
@@ -124,12 +124,12 @@ def test_reshape(shape, newshape, helpers):
|
||||
def method(x):
|
||||
return x.reshape(newshape)
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 5, size=shape) for i in range(100)]
|
||||
inputset = [np.random.randint(0, 2**5, size=shape) for i in range(100)]
|
||||
|
||||
function_circuit = function.compile(inputset, configuration)
|
||||
method_circuit = method.compile(inputset, configuration)
|
||||
|
||||
sample = np.random.randint(0, 2 ** 5, size=shape, dtype=np.uint8)
|
||||
sample = np.random.randint(0, 2**5, size=shape, dtype=np.uint8)
|
||||
|
||||
helpers.check_execution(function_circuit, function, sample)
|
||||
helpers.check_execution(method_circuit, method, sample)
|
||||
@@ -163,8 +163,8 @@ def test_flatten(shape, helpers):
|
||||
def function(x):
|
||||
return x.flatten()
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 5, size=shape) for i in range(100)]
|
||||
inputset = [np.random.randint(0, 2**5, size=shape) for i in range(100)]
|
||||
circuit = function.compile(inputset, configuration)
|
||||
|
||||
sample = np.random.randint(0, 2 ** 5, size=shape, dtype=np.uint8)
|
||||
sample = np.random.randint(0, 2**5, size=shape, dtype=np.uint8)
|
||||
helpers.check_execution(circuit, function, sample)
|
||||
|
||||
@@ -156,10 +156,10 @@ def test_static_indexing(shape, function, helpers):
|
||||
configuration = helpers.configuration()
|
||||
compiler = cnp.Compiler(function, {"x": "encrypted"})
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 5, size=shape) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**5, size=shape) for _ in range(100)]
|
||||
circuit = compiler.compile(inputset, configuration)
|
||||
|
||||
sample = np.random.randint(0, 2 ** 5, size=shape, dtype=np.uint8)
|
||||
sample = np.random.randint(0, 2**5, size=shape, dtype=np.uint8)
|
||||
helpers.check_execution(circuit, function, sample)
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ def test_bad_static_indexing(helpers):
|
||||
|
||||
compiler = cnp.Compiler(lambda x: x[1.5], {"x": "encrypted"})
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 3, size=(3,)) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**3, size=(3,)) for _ in range(100)]
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
compiler.compile(inputset, configuration)
|
||||
|
||||
@@ -186,7 +186,7 @@ def test_bad_static_indexing(helpers):
|
||||
|
||||
compiler = cnp.Compiler(lambda x: x[slice(1.5, 2.5, None)], {"x": "encrypted"})
|
||||
|
||||
inputset = [np.random.randint(0, 2 ** 3, size=(3,)) for _ in range(100)]
|
||||
inputset = [np.random.randint(0, 2**3, size=(3,)) for _ in range(100)]
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
compiler.compile(inputset, configuration)
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import concrete.onnx as connx
|
||||
pytest.param(
|
||||
lambda x, y: (x - y, x + y),
|
||||
{"x": "encrypted", "y": "clear"},
|
||||
[(np.random.randint(0, 2 ** 3), np.random.randint(0, 2 ** 3)) for _ in range(100)],
|
||||
[(np.random.randint(0, 2**3), np.random.randint(0, 2**3)) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
@@ -73,8 +73,8 @@ return %1
|
||||
{"x": "encrypted", "y": "clear"},
|
||||
[
|
||||
(
|
||||
np.random.randint(0, 2 ** 3, size=(3, 2)),
|
||||
np.random.randint(0, 2 ** 3, size=(3, 2)),
|
||||
np.random.randint(0, 2**3, size=(3, 2)),
|
||||
np.random.randint(0, 2**3, size=(3, 2)),
|
||||
)
|
||||
for _ in range(100)
|
||||
],
|
||||
@@ -165,8 +165,8 @@ return %2
|
||||
{"x": "encrypted", "y": "encrypted"},
|
||||
[
|
||||
(
|
||||
np.random.randint(0, 2 ** 2, size=(1,)),
|
||||
np.random.randint(0, 2 ** 2, size=(1,)),
|
||||
np.random.randint(0, 2**2, size=(1,)),
|
||||
np.random.randint(0, 2**2, size=(1,)),
|
||||
)
|
||||
for _ in range(100)
|
||||
],
|
||||
@@ -186,7 +186,7 @@ return %2
|
||||
pytest.param(
|
||||
lambda x: x[0],
|
||||
{"x": "clear"},
|
||||
[np.random.randint(0, 2 ** 3, size=(4,)) for _ in range(100)],
|
||||
[np.random.randint(0, 2**3, size=(4,)) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
@@ -204,8 +204,8 @@ return %1
|
||||
{"x": "encrypted", "y": "encrypted"},
|
||||
[
|
||||
(
|
||||
np.random.randint(0, 2 ** 2, size=(1, 1)),
|
||||
np.random.randint(0, 2 ** 2, size=(1, 1)),
|
||||
np.random.randint(0, 2**2, size=(1, 1)),
|
||||
np.random.randint(0, 2**2, size=(1, 1)),
|
||||
)
|
||||
for _ in range(100)
|
||||
],
|
||||
@@ -225,7 +225,7 @@ return %2
|
||||
pytest.param(
|
||||
lambda x, y: x * y,
|
||||
{"x": "encrypted", "y": "encrypted"},
|
||||
[(np.random.randint(0, 2 ** 3), np.random.randint(0, 2 ** 3)) for _ in range(100)],
|
||||
[(np.random.randint(0, 2**3), np.random.randint(0, 2**3)) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
@@ -242,7 +242,7 @@ return %2
|
||||
pytest.param(
|
||||
lambda x: -x,
|
||||
{"x": "clear"},
|
||||
[np.random.randint(0, 2 ** 3) for _ in range(100)],
|
||||
[np.random.randint(0, 2**3) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
@@ -258,7 +258,7 @@ return %1
|
||||
pytest.param(
|
||||
lambda x: x.reshape((3, 2)),
|
||||
{"x": "clear"},
|
||||
[np.random.randint(0, 2 ** 3, size=(2, 3)) for _ in range(100)],
|
||||
[np.random.randint(0, 2**3, size=(2, 3)) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
@@ -274,7 +274,7 @@ return %1
|
||||
pytest.param(
|
||||
lambda x: x - 1,
|
||||
{"x": "clear"},
|
||||
[np.random.randint(0, 2 ** 3, size=(2, 3)) for _ in range(100)],
|
||||
[np.random.randint(0, 2**3, size=(2, 3)) for _ in range(100)],
|
||||
RuntimeError,
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user