prettyjoey 0.1.2__tar.gz

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.
@@ -0,0 +1,4 @@
1
+ /target
2
+ dist/
3
+ .venv/
4
+ __pycache__/
@@ -0,0 +1 @@
1
+ 3.12
@@ -0,0 +1,133 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "heck"
7
+ version = "0.5.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
10
+
11
+ [[package]]
12
+ name = "libc"
13
+ version = "0.2.189"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
16
+
17
+ [[package]]
18
+ name = "once_cell"
19
+ version = "1.21.4"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
22
+
23
+ [[package]]
24
+ name = "portable-atomic"
25
+ version = "1.15.0"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
28
+
29
+ [[package]]
30
+ name = "prettyjoey"
31
+ version = "0.1.0"
32
+ dependencies = [
33
+ "pyo3",
34
+ ]
35
+
36
+ [[package]]
37
+ name = "proc-macro2"
38
+ version = "1.0.107"
39
+ source = "registry+https://github.com/rust-lang/crates.io-index"
40
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
41
+ dependencies = [
42
+ "unicode-ident",
43
+ ]
44
+
45
+ [[package]]
46
+ name = "pyo3"
47
+ version = "0.28.3"
48
+ source = "registry+https://github.com/rust-lang/crates.io-index"
49
+ checksum = "91fd8e38a3b50ed1167fb981cd6fd60147e091784c427b8f7183a7ee32c31c12"
50
+ dependencies = [
51
+ "libc",
52
+ "once_cell",
53
+ "portable-atomic",
54
+ "pyo3-build-config",
55
+ "pyo3-ffi",
56
+ "pyo3-macros",
57
+ ]
58
+
59
+ [[package]]
60
+ name = "pyo3-build-config"
61
+ version = "0.28.3"
62
+ source = "registry+https://github.com/rust-lang/crates.io-index"
63
+ checksum = "e368e7ddfdeb98c9bca7f8383be1648fd84ab466bf2bc015e94008db6d35611e"
64
+ dependencies = [
65
+ "target-lexicon",
66
+ ]
67
+
68
+ [[package]]
69
+ name = "pyo3-ffi"
70
+ version = "0.28.3"
71
+ source = "registry+https://github.com/rust-lang/crates.io-index"
72
+ checksum = "7f29e10af80b1f7ccaf7f69eace800a03ecd13e883acfacc1e5d0988605f651e"
73
+ dependencies = [
74
+ "libc",
75
+ "pyo3-build-config",
76
+ ]
77
+
78
+ [[package]]
79
+ name = "pyo3-macros"
80
+ version = "0.28.3"
81
+ source = "registry+https://github.com/rust-lang/crates.io-index"
82
+ checksum = "df6e520eff47c45997d2fc7dd8214b25dd1310918bbb2642156ef66a67f29813"
83
+ dependencies = [
84
+ "proc-macro2",
85
+ "pyo3-macros-backend",
86
+ "quote",
87
+ "syn",
88
+ ]
89
+
90
+ [[package]]
91
+ name = "pyo3-macros-backend"
92
+ version = "0.28.3"
93
+ source = "registry+https://github.com/rust-lang/crates.io-index"
94
+ checksum = "c4cdc218d835738f81c2338f822078af45b4afdf8b2e33cbb5916f108b813acb"
95
+ dependencies = [
96
+ "heck",
97
+ "proc-macro2",
98
+ "pyo3-build-config",
99
+ "quote",
100
+ "syn",
101
+ ]
102
+
103
+ [[package]]
104
+ name = "quote"
105
+ version = "1.0.47"
106
+ source = "registry+https://github.com/rust-lang/crates.io-index"
107
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
108
+ dependencies = [
109
+ "proc-macro2",
110
+ ]
111
+
112
+ [[package]]
113
+ name = "syn"
114
+ version = "2.0.119"
115
+ source = "registry+https://github.com/rust-lang/crates.io-index"
116
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
117
+ dependencies = [
118
+ "proc-macro2",
119
+ "quote",
120
+ "unicode-ident",
121
+ ]
122
+
123
+ [[package]]
124
+ name = "target-lexicon"
125
+ version = "0.13.5"
126
+ source = "registry+https://github.com/rust-lang/crates.io-index"
127
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
128
+
129
+ [[package]]
130
+ name = "unicode-ident"
131
+ version = "1.0.24"
132
+ source = "registry+https://github.com/rust-lang/crates.io-index"
133
+ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75"
@@ -0,0 +1,15 @@
1
+ [package]
2
+ name = "prettyjoey"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ readme = "README.md"
6
+
7
+ [lib]
8
+ name = "_core"
9
+ # "cdylib" is necessary to produce a shared library for Python to import from.
10
+ crate-type = ["cdylib"]
11
+
12
+ [dependencies]
13
+ # "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
14
+ # "abi3-py39" tells pyo3 (and maturin) to build using the stable ABI with minimum Python version 3.9
15
+ pyo3 = { version = "0.28.2", features = ["extension-module", "abi3-py39"] }
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: prettyjoey
3
+ Version: 0.1.2
4
+ Summary: Add your description here
5
+ Author-email: prettyjoey <prettyjoey46@gmail.com>
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
8
+
9
+ not empty now
@@ -0,0 +1 @@
1
+ not empty now
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "prettyjoey"
3
+ version = "0.1.2"
4
+ description = "Add your description here"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "prettyjoey", email = "prettyjoey46@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.12"
10
+ dependencies = []
11
+
12
+ [tool.maturin]
13
+ module-name = "prettyjoey._core"
14
+ python-packages = ["prettyjoey"]
15
+ python-source = "src"
16
+
17
+ [tool.uv]
18
+ cache-keys = [{ file = "pyproject.toml" }, { file = "src/**/*.rs" }, { file = "Cargo.toml" }, { file = "Cargo.lock" }]
19
+
20
+ [build-system]
21
+ requires = ["maturin>=1.0,<2.0"]
22
+ build-backend = "maturin"
23
+
24
+ [dependency-groups]
25
+ dev = [
26
+ "maturin>=1.14.1",
27
+ ]
@@ -0,0 +1,14 @@
1
+ use pyo3::prelude::*;
2
+
3
+ /// A Python module implemented in Rust. The name of this module must match
4
+ /// the `lib.name` setting in the `Cargo.toml`, else Python will not be able to
5
+ /// import the module.
6
+ #[pymodule]
7
+ mod _core {
8
+ use pyo3::prelude::*;
9
+
10
+ #[pyfunction]
11
+ fn hello_from_bin() -> String {
12
+ "Hello from prettyjoey!".to_string()
13
+ }
14
+ }
@@ -0,0 +1,5 @@
1
+ from prettyjoey._core import hello_from_bin
2
+
3
+
4
+ def hello() -> str:
5
+ return hello_from_bin()
@@ -0,0 +1 @@
1
+ def hello_from_bin() -> str: ...
@@ -0,0 +1 @@
1
+ from .discrete import diff
@@ -0,0 +1,22 @@
1
+ def diff(t,x):
2
+ """
3
+ computes discrete derivative v(t) from a given timeseries x(t)
4
+ following
5
+ v(t) = x(tk) - x(tk-1) / (tk - tk-1)
6
+ input 1: time value tk, k is index of time
7
+ input 2: signal value x
8
+
9
+ -must return v(t) as array
10
+ -must check for equal length arrays
11
+ """
12
+ #same length?
13
+ if len(x) != len(t):
14
+ raise ValueError("input arrays must have the same length")
15
+ #store results
16
+ v = []
17
+ #computation
18
+ for k in range(1,len(t)):
19
+ der_v = (x[k] - x[k-1]) / (t[k] - t[k-1])
20
+ v.append(der_v) #append results to list previously created
21
+
22
+ return v
@@ -0,0 +1 @@
1
+ from .elementary import rowreplacement, rowscale, rowswap, rref
@@ -0,0 +1,108 @@
1
+ import torch
2
+ # matrix as input, index of source row, and target row
3
+ def rowswap(matrix, source_row_index, target_index):
4
+ # fixed bug, I think memory overwrites destroys good data
5
+ # using [[]] fixes this overwriting issue
6
+ matrix[[source_row_index, target_index]] = matrix[[target_index, source_row_index]]
7
+ return matrix
8
+
9
+
10
+
11
+ # input matrix, index of source row, and scaling factor
12
+ def rowscale(matrix, source_row_index, scaling_factor):
13
+ matrix[source_row_index] = matrix[source_row_index] * scaling_factor
14
+ return matrix
15
+
16
+ def rowreplacement(matrix, row_i, row_j, j,k):
17
+ """
18
+ perform jRi + kRj that takes a matrix as an
19
+ input, first row, the second row, the scaling factors j and k. You may use function
20
+ rowscale for scaling operation.
21
+ """
22
+ # cannot perform both using rowscale in two instances because the scaling factor will
23
+ # permanently alter row_j in the matrix, when row_j should remain unchanged
24
+ # only row_i is supposed to be replaced by the operation jRi + kRj
25
+ rowscale(matrix,row_i,j) # Ri -> j * Ri
26
+ matrix[row_i] = matrix[row_i] + k * matrix[row_j] # ... + k*Rj
27
+ return matrix
28
+
29
+ def rref(matrix):
30
+ """
31
+ notes:
32
+ ref:
33
+ 1. all 0 rows at bottom
34
+ 2. pviot of all non 0 rows are on the left of all rows below
35
+ 3. pivot must be a value of "1"
36
+ rref:
37
+ everything above +
38
+ 4. each pivot column has zero's everywhere else
39
+
40
+ """
41
+ # python struggles to do the math without a locked type as float
42
+ # was throwing garbage values out without it
43
+ matrix = matrix.to(torch.float64)
44
+ # recall: shape returns tuple of values returns: (rows,cols)
45
+ row_len, col_len = matrix.shape
46
+ locked_rows = []
47
+ # 1: iterate over column starting in the top left
48
+ for col_i in range(col_len):
49
+ # 2a: select pivot row
50
+ pivot_row_i = -1 # -1 means "no pivot found yet" for this column
51
+
52
+ # search for a row (not already used as a pivot) with a nonzero entry here
53
+ for row_i in range(row_len):
54
+ # skip this row, will -> 0 regardless
55
+ if row_i in locked_rows:
56
+ continue
57
+ # check if current element is a non zero value
58
+ if (matrix[row_i][col_i]) != 0:
59
+ pivot_row_i = row_i
60
+ break
61
+
62
+ # no usable pivot in this column, go to the next
63
+ if pivot_row_i == -1:
64
+ continue
65
+
66
+ # 2b: bring pivot row -> locked_row indices
67
+ next_pivot_row_i = (locked_rows[-1] + 1) if len(locked_rows) > 0 else 0
68
+
69
+ # if not already there, swap it into place with rowswap funct.
70
+ # if we find a non zero pivot in a subsequent row we need to verfiy the previous row has its pivot in place, if no we need to move it up
71
+ if pivot_row_i != next_pivot_row_i:
72
+ rowswap(matrix, next_pivot_row_i, pivot_row_i)
73
+ pivot_row_i = next_pivot_row_i # pivot moved, update index
74
+
75
+ # 3: scale the pivot row so its leading entry becomes 1 via. rowscale funct.
76
+ pivot_val = matrix[pivot_row_i][col_i]
77
+ # eqn:
78
+ rowscale(matrix, pivot_row_i, 1 / pivot_val)
79
+
80
+ # 4: eliminate this column in every other rows with rowreplacement funct.
81
+ for row_i in range(row_len):
82
+ if row_i == pivot_row_i:
83
+ continue
84
+ lead_coefficient = matrix[row_i][col_i]
85
+ if (lead_coefficient) != 0:
86
+ rowreplacement(matrix, row_i, pivot_row_i, 1, -lead_coefficient)
87
+ # 5: prep to move onto next column
88
+ locked_rows.append(pivot_row_i)
89
+
90
+
91
+ return matrix
92
+
93
+
94
+ def main():
95
+ # testing
96
+ """
97
+ test = torch.tensor([ [1, 3, 0, 0, 3],[0, 0, 1, 0, 9],[0, 0, 0, 1, -4] ], dtype=torch.float64)
98
+ print(test)
99
+ test2 = rowswap(test,0,1) #correctly swaps rows 1 & 2
100
+ print("\n", test2)
101
+ test3 = rowscale(test2, 0, 1 / 3)
102
+ print("\n",test3)
103
+ test4 = rowreplacement(test3, 2, 0, 1, -3)
104
+ print("\n",test4)
105
+ if __name__ == "__main__":
106
+ main()
107
+
108
+ """
File without changes
@@ -0,0 +1,39 @@
1
+ version = 1
2
+ revision = 3
3
+ requires-python = ">=3.12"
4
+
5
+ [[package]]
6
+ name = "maturin"
7
+ version = "1.14.1"
8
+ source = { registry = "https://pypi.org/simple" }
9
+ sdist = { url = "https://files.pythonhosted.org/packages/e7/b3/addd877f871fb1860d46d3a4f206ecb10b946c85846805e6367631926fd3/maturin-1.14.1.tar.gz", hash = "sha256:9d6577a62cd08e0ceba7a0db06fb098e0c9b1b3429bad747a4f3a18215a1b3df", size = 369637, upload-time = "2026-06-19T05:19:49.774Z" }
10
+ wheels = [
11
+ { url = "https://files.pythonhosted.org/packages/f4/f0/97c5a5bd9c71653a066c0976a484eaaae50b9369557838a4176b7b0bdaa5/maturin-1.14.1-py3-none-linux_armv6l.whl", hash = "sha256:522292398945442cdafa9daeb2271b2340fbde57027b818f923f88eab04174f8", size = 10207496, upload-time = "2026-06-19T05:19:09.321Z" },
12
+ { url = "https://files.pythonhosted.org/packages/fe/83/294bca639b0e052f1e2f65199b3db258780c7d4e31408b934c9c974a1379/maturin-1.14.1-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:ffe5ad71f21d1e6603c4dd75f7fee34adf5ed5ebcebb692886549888ebb329ed", size = 19680113, upload-time = "2026-06-19T05:19:13.43Z" },
13
+ { url = "https://files.pythonhosted.org/packages/43/b6/79c881410a3b1c187f7eb3d407aecae646c6a4433d630d72200359015e83/maturin-1.14.1-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:f3306078070c1508fd715b9116070cbcaff5959024272a9f1e6f5cb29768b86c", size = 10169205, upload-time = "2026-06-19T05:19:16.615Z" },
14
+ { url = "https://files.pythonhosted.org/packages/93/9d/44b6f26dcb7f7a04c5501ac2dbb6ca1490150682baa525ca5860504f9eab/maturin-1.14.1-py3-none-manylinux_2_12_i686.manylinux2010_i686.musllinux_1_1_i686.whl", hash = "sha256:cd457cd88961156e26379e1155bd287cc0ec1c8b2f1582b0660fb31b87c8842d", size = 10188098, upload-time = "2026-06-19T05:19:19.736Z" },
15
+ { url = "https://files.pythonhosted.org/packages/1a/bd/9c0d5d6983905ce2c9edaa073a7e89355a9cf7f396988e05d32f1c37785d/maturin-1.14.1-py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.musllinux_1_1_x86_64.whl", hash = "sha256:dfc54ae32e6fcb18302193ab9a30b0b25eefffba994ae13238974805533ef75e", size = 10627576, upload-time = "2026-06-19T05:19:22.713Z" },
16
+ { url = "https://files.pythonhosted.org/packages/e5/33/b096412bd6a7cb399652b260666f901adf88a687181a6dbd6a3f89f0a94e/maturin-1.14.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:a131d912b5267e640bc96d70f4914e10590aed64082ec9abacba7cea52004224", size = 10085181, upload-time = "2026-06-19T05:19:25.69Z" },
17
+ { url = "https://files.pythonhosted.org/packages/56/8d/08c3bf469c38a23c9e6c877e338193001eb604d010fedc08341974e38528/maturin-1.14.1-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.musllinux_1_1_armv7l.whl", hash = "sha256:be18fc568fb76884c0205456336892a75105ec398e6b667cd777c6268bd06d69", size = 10026363, upload-time = "2026-06-19T05:19:28.904Z" },
18
+ { url = "https://files.pythonhosted.org/packages/3a/a4/c4d1a92839f8745ab4aab988a7db884a79d6d710bd3b286fcf9316dece1a/maturin-1.14.1-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.musllinux_1_1_ppc64le.whl", hash = "sha256:994a0c8ba3ad8a92b3a9ee1b02645d200d610216b15cff5102b0fe65e8e08666", size = 13321347, upload-time = "2026-06-19T05:19:32.411Z" },
19
+ { url = "https://files.pythonhosted.org/packages/b3/fa/170f04624d03fd07d2a8b1b67de83a127af93aef9eaa425839553347297b/maturin-1.14.1-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:be80866363e605d137991b491a741a84cde9ae350183c4c85f49690ca9aaaa65", size = 10877609, upload-time = "2026-06-19T05:19:35.448Z" },
20
+ { url = "https://files.pythonhosted.org/packages/61/ad/1ae2e1d0ded282bf2c55ac13f0811d87deb425e200ae64a15785675dede9/maturin-1.14.1-py3-none-manylinux_2_31_riscv64.musllinux_1_1_riscv64.whl", hash = "sha256:5282dffd4b539d2be245f4e5b1a5ab6bc1033b58f4a4872f5833f9d43c954aa4", size = 10417316, upload-time = "2026-06-19T05:19:38.28Z" },
21
+ { url = "https://files.pythonhosted.org/packages/fb/27/bf677183920718da49cd7982d6a3ffc440aad8919329f571d189f81b7bdf/maturin-1.14.1-py3-none-win32.whl", hash = "sha256:1a04de0a20188f95c721b5702eed18140bdcccb28c386797093eca3f62f4d4e0", size = 8931293, upload-time = "2026-06-19T05:19:41.183Z" },
22
+ { url = "https://files.pythonhosted.org/packages/63/4b/585adeb9167b08d3cdff0032a938b0e72655c92003df4f52c3f696a1bcc2/maturin-1.14.1-py3-none-win_amd64.whl", hash = "sha256:3c9f94640ecc4895e94abaf834a0684430032c865b2748a36c12461fd9252fdd", size = 10314067, upload-time = "2026-06-19T05:19:44.389Z" },
23
+ { url = "https://files.pythonhosted.org/packages/51/d4/dac8c0720ae246be1700afb6fbdbbea20fe35b13f6570b2f70faa005df77/maturin-1.14.1-py3-none-win_arm64.whl", hash = "sha256:15cea8fcb3ba47dd636f50092bb34baea8b04ac777392f23e6bf8a9a61efb894", size = 9718943, upload-time = "2026-06-19T05:19:47.49Z" },
24
+ ]
25
+
26
+ [[package]]
27
+ name = "prettyjoey"
28
+ version = "0.1.0"
29
+ source = { editable = "." }
30
+
31
+ [package.dev-dependencies]
32
+ dev = [
33
+ { name = "maturin" },
34
+ ]
35
+
36
+ [package.metadata]
37
+
38
+ [package.metadata.requires-dev]
39
+ dev = [{ name = "maturin", specifier = ">=1.14.1" }]