Skip to content

Commit fbacdd2

Browse files
authored
Chore: Many small corrections and Nada Numpy update to 2.0.0 (#52)
* chore: updated numpy to version 2.0.0 * chore: added optional dependencies for examples and linting * fix: added .gitignore to prevent not found file errors * fix: Added linear_regression to testing infrastructure * chore: bump version number
1 parent 17b8eca commit fbacdd2

38 files changed

+384
-155
lines changed

examples/broadcasting/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import asyncio
99

10-
import nada_numpy.client as na_client
1110
import numpy as np
1211
import py_nillion_client as nillion
12+
from common.utils import compute, store_program, store_secret_array
1313
from config import DIM
1414
from cosmpy.aerial.client import LedgerClient
1515
from cosmpy.aerial.wallet import LocalWallet
@@ -20,7 +20,7 @@
2020
get_quote_and_pay, pay_with_quote)
2121
from py_nillion_client import NodeKey, UserKey
2222

23-
from common.utils import compute, store_program, store_secret_array
23+
import nada_numpy.client as na_client
2424

2525
home = os.getenv("HOME")
2626
load_dotenv(f"{home}/.config/nillion/nillion-devnet.env")

examples/broadcasting/src/broadcasting.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
from typing import List
44

5-
# Step 0: Nada Numpy is imported with this line
6-
import nada_numpy as na
75
from config import DIM
86
from nada_dsl import Output, SecretInteger
97

8+
# Step 0: Nada Numpy is imported with this line
9+
import nada_numpy as na
10+
1011

1112
def nada_main() -> List[Output]:
1213
"""

examples/common/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import time
55
from typing import Any, Callable, Dict, List
66

7-
import nada_numpy as na
8-
import nada_numpy.client as na_client
97
import numpy as np
108
import py_nillion_client as nillion
119
from cosmpy.aerial.client import LedgerClient
@@ -14,6 +12,9 @@
1412
create_payments_config, get_quote,
1513
get_quote_and_pay, pay_with_quote)
1614

15+
import nada_numpy as na
16+
import nada_numpy.client as na_client
17+
1718

1819
def async_timer(file_path: os.PathLike) -> Callable:
1920
"""

examples/dot_product/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import asyncio
99

10-
import nada_numpy.client as na_client
1110
import numpy as np
1211
import py_nillion_client as nillion
12+
from common.utils import compute, store_program, store_secret_array
1313
from config import DIM
1414
from cosmpy.aerial.client import LedgerClient
1515
from cosmpy.aerial.wallet import LocalWallet
@@ -20,11 +20,10 @@
2020
get_quote_and_pay, pay_with_quote)
2121
from py_nillion_client import NodeKey, UserKey
2222

23-
from common.utils import compute, store_program, store_secret_array
23+
import nada_numpy.client as na_client
2424

2525
home = os.getenv("HOME")
2626
load_dotenv(f"{home}/.config/nillion/nillion-devnet.env")
27-
# load_dotenv(f"/workspaces/ai/.nillion-testnet.env")
2827

2928

3029
# Main asynchronous function to coordinate the process

examples/dot_product/src/dot_product.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from typing import List
44

55
from config import DIM
6+
from nada_dsl import Output, SecretInteger
67

78
# Step 0: Nada Numpy is imported with this line
89
import nada_numpy as na
9-
from nada_dsl import Output, SecretInteger
1010

1111

1212
def nada_main() -> List[Output]:

examples/linear-regression/main.py renamed to examples/linear_regression/main.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import asyncio
99

10-
import nada_numpy.client as na_client
1110
import numpy as np
1211
import py_nillion_client as nillion
12+
from common.utils import compute, store_program, store_secret_array
1313
from cosmpy.aerial.client import LedgerClient
1414
from cosmpy.aerial.wallet import LocalWallet
1515
from cosmpy.crypto.keypairs import PrivateKey
@@ -20,12 +20,10 @@
2020
from py_nillion_client import NodeKey, UserKey
2121
from sklearn.linear_model import Ridge
2222

23-
from common.utils import compute, store_program, store_secret_array
23+
import nada_numpy.client as na_client
2424

2525
home = os.getenv("HOME")
26-
2726
load_dotenv(f"{home}/.config/nillion/nillion-devnet.env")
28-
# load_dotenv(f"/workspaces/ai/.nillion-testnet.env")
2927

3028

3129
# Main asynchronous function to coordinate the process

examples/linear-regression/src/determinant.py renamed to examples/linear_regression/src/determinant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import nada_numpy as na
21
import numpy as np
32
from nada_dsl import *
3+
4+
import nada_numpy as na
45
from nada_numpy.array import NadaArray
56

67

examples/linear-regression/src/gauss_jordan.py renamed to examples/linear_regression/src/gauss_jordan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import nada_numpy as na
21
import numpy as np
32
from modular_inverse import PRIME, public_modular_inverse
43
from nada_dsl import *
54

5+
import nada_numpy as na
6+
67
# from nada_crypto import random_lu_matrix, public_modular_inverse
78

89

examples/linear-regression/src/linear_regression.py renamed to examples/linear_regression/src/linear_regression.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import nada_numpy as na
21
import numpy as np
32
from determinant import determinant
43
from gauss_jordan import gauss_jordan_zn
54
from modular_inverse import (PRIME, private_modular_inverse,
65
public_modular_inverse)
76
from nada_dsl import *
7+
8+
import nada_numpy as na
89
from nada_numpy.array import NadaArray
910

1011

examples/linear-regression/src/linear_regression_256.py renamed to examples/linear_regression/src/linear_regression_256.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import nada_numpy as na
21
import numpy as np
32
from nada_dsl import *
3+
4+
import nada_numpy as na
45
from nada_numpy.array import NadaArray
56

67
# LOG_SCALE = 8

examples/linear-regression/src/matrix_inverse.py renamed to examples/linear_regression/src/matrix_inverse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import time
22

3-
import nada_numpy as na
43
import numpy as np
54
from nada_dsl import *
5+
6+
import nada_numpy as na
67
from nada_numpy.array import NadaArray
78

89
LOG_SCALE = 16

examples/linear-regression/src/modular_inverse.py renamed to examples/linear_regression/src/modular_inverse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
import nada_numpy as na
21
import numpy as np
32
from nada_dsl import *
43

4+
import nada_numpy as na
5+
56
LOG_SCALE = 16
67
SCALE = 1 << LOG_SCALE
78
PRIME_64 = 18446744072637906947
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This directory is kept purposely, so that no compilation errors arise.
2+
# Ignore everything in this directory
3+
*
4+
# Except this file
5+
!.gitignore
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
program: linear_regression
3+
inputs:
4+
A_0_0:
5+
SecretInteger: "-256"
6+
A_0_1:
7+
SecretInteger: "-199"
8+
A_0_2:
9+
SecretInteger: "-142"
10+
A_1_0:
11+
SecretInteger: "-85"
12+
A_1_1:
13+
SecretInteger: "-28"
14+
A_1_2:
15+
SecretInteger: "28"
16+
A_2_0:
17+
SecretInteger: "85"
18+
A_2_1:
19+
SecretInteger: "142"
20+
A_2_2:
21+
SecretInteger: "256"
22+
b_0:
23+
SecretInteger: "-256"
24+
b_1:
25+
SecretInteger: "-199"
26+
b_2:
27+
SecretInteger: "-142"
28+
# lambda_0:
29+
# Integer: "1"
30+
expected_outputs:
31+
b:
32+
SecretInteger: "330643400256"
33+
w_0:
34+
SecretInteger: "1102041164640"
35+
w_1:
36+
SecretInteger: "-993683999568"
37+
w_2:
38+
SecretInteger: "1868226984"

examples/matrix_multiplication/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import asyncio
99

10-
import nada_numpy.client as na_client
1110
import numpy as np
1211
import py_nillion_client as nillion
12+
from common.utils import compute, store_program, store_secret_array
1313
from config import DIM
1414
from cosmpy.aerial.client import LedgerClient
1515
from cosmpy.aerial.wallet import LocalWallet
@@ -20,11 +20,10 @@
2020
get_quote_and_pay, pay_with_quote)
2121
from py_nillion_client import NodeKey, UserKey
2222

23-
from common.utils import compute, store_program, store_secret_array
23+
import nada_numpy.client as na_client
2424

2525
home = os.getenv("HOME")
2626
load_dotenv(f"{home}/.config/nillion/nillion-devnet.env")
27-
# load_dotenv(f"/workspaces/ai/.nillion-testnet.env")
2827

2928

3029
# Main asynchronous function to coordinate the process

examples/matrix_multiplication/src/matrix_multiplication.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
from typing import List
44

5-
# Step 0: Nada Numpy is imported with this line
6-
import nada_numpy as na
75
from config import DIM
86
from nada_dsl import Output, SecretInteger
97

8+
# Step 0: Nada Numpy is imported with this line
9+
import nada_numpy as na
10+
1011

1112
def nada_main() -> List[Output]:
1213
"""

examples/rational_numbers/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77

88
import asyncio
99

10-
import nada_numpy.client as na_client
1110
import numpy as np
1211
import py_nillion_client as nillion
12+
from common.utils import compute, store_program, store_secret_value
1313
from cosmpy.aerial.client import LedgerClient
1414
from cosmpy.aerial.wallet import LocalWallet
1515
from cosmpy.crypto.keypairs import PrivateKey
@@ -18,11 +18,10 @@
1818
create_payments_config)
1919
from py_nillion_client import NodeKey, UserKey
2020

21-
from common.utils import compute, store_program, store_secret_value
21+
import nada_numpy.client as na_client
2222

2323
home = os.getenv("HOME")
2424
load_dotenv(f"{home}/.config/nillion/nillion-devnet.env")
25-
# load_dotenv(f"/workspaces/ai/.nillion-testnet.env")
2625

2726

2827
# Main asynchronous function to coordinate the process

examples/rational_numbers/src/rational_numbers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from typing import List
44

5-
import nada_numpy as na
65
from nada_dsl import Output
76

7+
import nada_numpy as na
8+
89

910
def nada_main() -> List[Output]:
1011
"""

nada_numpy/array.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# pylint:disable=too-many-lines
77

8-
from typing import Any, Callable, Optional, Sequence, Union, get_args, overload
8+
from typing import Any, Callable, Optional, Sequence, Union, get_args
99

1010
import numpy as np
1111
from nada_dsl import (Boolean, Input, Integer, Output, Party, PublicInteger,
@@ -870,28 +870,6 @@ def item(self, *args, **kwargs):
870870
return NadaArray(result)
871871
return result
872872

873-
@overload
874-
def itemset(self, value: Any): ...
875-
@overload
876-
def itemset(self, item: Any, value: Any): ...
877-
878-
# pylint:disable=missing-function-docstring
879-
@copy_metadata(np.ndarray.itemset)
880-
def itemset(self, *args, **kwargs):
881-
value = None
882-
if len(args) == 1:
883-
value = args[0]
884-
elif len(args) == 2:
885-
value = args[1]
886-
else:
887-
value = kwargs["value"]
888-
889-
_check_type_compatibility(value, self.dtype)
890-
result = self.inner.itemset(*args, **kwargs)
891-
if isinstance(result, np.ndarray):
892-
return NadaArray(result)
893-
return result
894-
895873
# pylint:disable=missing-function-docstring
896874
@copy_metadata(np.ndarray.prod)
897875
def prod(self, *args, **kwargs):

0 commit comments

Comments
 (0)