sleipnirgroup-jormungandr 0.2.1.dev7__cp312-abi3-macosx_14_0_universal2.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of sleipnirgroup-jormungandr might be problematic. Click here for more details.
- jormungandr/__init__.py +8 -0
- jormungandr/__init__.pyi +1 -0
- jormungandr/_jormungandr.abi3.so +0 -0
- jormungandr/autodiff/__init__.py +58 -0
- jormungandr/autodiff/__init__.pyi +2528 -0
- jormungandr/optimization/__init__.py +39 -0
- jormungandr/optimization/__init__.pyi +674 -0
- jormungandr/py.typed +0 -0
- sleipnirgroup_jormungandr-0.2.1.dev7.dist-info/LICENSE.txt +11 -0
- sleipnirgroup_jormungandr-0.2.1.dev7.dist-info/METADATA +365 -0
- sleipnirgroup_jormungandr-0.2.1.dev7.dist-info/RECORD +13 -0
- sleipnirgroup_jormungandr-0.2.1.dev7.dist-info/WHEEL +4 -0
- sleipnirgroup_jormungandr-0.2.1.dev7.dist-info/entry_points.txt +0 -0
jormungandr/__init__.py
ADDED
jormungandr/__init__.pyi
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from . import autodiff as autodiff, optimization as optimization
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import scipy.sparse
|
|
2
|
+
|
|
3
|
+
from .._jormungandr.autodiff import *
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def spy(mat: scipy.sparse.csc_matrix):
|
|
7
|
+
"""
|
|
8
|
+
Plot the sparsity pattern of a sparse matrix.
|
|
9
|
+
|
|
10
|
+
Green points represent positive values and red points represent negative
|
|
11
|
+
values.
|
|
12
|
+
|
|
13
|
+
Parameter ``mat``:
|
|
14
|
+
The sparse matrix.
|
|
15
|
+
"""
|
|
16
|
+
import matplotlib.pyplot as plt
|
|
17
|
+
import matplotlib.ticker as mticker
|
|
18
|
+
from matplotlib.colors import ListedColormap
|
|
19
|
+
|
|
20
|
+
xs = []
|
|
21
|
+
ys = []
|
|
22
|
+
vs = []
|
|
23
|
+
|
|
24
|
+
cmat = mat.tocoo()
|
|
25
|
+
for row, col, value in zip(cmat.row, cmat.col, cmat.data):
|
|
26
|
+
xs.append(col)
|
|
27
|
+
ys.append(row)
|
|
28
|
+
if value > 0.0:
|
|
29
|
+
vs.append(1.0)
|
|
30
|
+
elif value < 0.0:
|
|
31
|
+
vs.append(-1.0)
|
|
32
|
+
else:
|
|
33
|
+
vs.append(0.0)
|
|
34
|
+
|
|
35
|
+
fig = plt.figure()
|
|
36
|
+
ax = fig.add_subplot()
|
|
37
|
+
|
|
38
|
+
# Display scatter plot
|
|
39
|
+
cmap = ListedColormap(["red", "green"])
|
|
40
|
+
sc = ax.scatter(xs, ys, s=1, c=vs, marker=".", cmap=cmap, vmin=-1, vmax=1)
|
|
41
|
+
|
|
42
|
+
# Display colorbar
|
|
43
|
+
colorbar = fig.colorbar(sc)
|
|
44
|
+
ticklabels = ["Negative", "Positive"]
|
|
45
|
+
colorbar.ax.yaxis.set_major_locator(mticker.FixedLocator(ticklabels))
|
|
46
|
+
colorbar.ax.set_yticks([-1, 1])
|
|
47
|
+
colorbar.ax.set_yticklabels(ticklabels)
|
|
48
|
+
|
|
49
|
+
ax.set_title("Sparsity")
|
|
50
|
+
ax.set_xlabel("Cols")
|
|
51
|
+
ax.set_ylabel("Rows")
|
|
52
|
+
|
|
53
|
+
ax.set_xlim([0, mat.shape[1]])
|
|
54
|
+
ax.set_ylim([0, mat.shape[0]])
|
|
55
|
+
ax.invert_yaxis()
|
|
56
|
+
ax.set_aspect(1.0)
|
|
57
|
+
|
|
58
|
+
plt.show()
|