rsnumpy 0.1.6__tar.gz → 0.1.7__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.
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/.gitignore +2 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/Cargo.lock +1 -1
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/Cargo.toml +1 -1
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/PKG-INFO +1 -4
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/build_wheel.sh +6 -12
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/pyproject.toml +3 -7
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/__init__.py +3 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/src/lib.rs +26 -8
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/.github/ci.yml +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/.github/release.yml +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/LICENSE +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/README.md +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/plots.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/array_methods.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/array_ops.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/io.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/linalg/__init__.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/math_functions.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/polynomial/__init__.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/random/__init__.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7/python}/rsnumpy/statistics.py +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/src/fft.rs +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/src/linalg.rs +0 -0
- {rsnumpy-0.1.6 → rsnumpy-0.1.7}/src/random.rs +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rsnumpy
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.7
|
|
4
4
|
Classifier: License :: OSI Approved :: MIT License
|
|
5
5
|
Classifier: Programming Language :: Rust
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
7
7
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
8
|
-
Requires-Dist: maturin>=1.14.0
|
|
9
|
-
Requires-Dist: rsplotlib>=0.1.4
|
|
10
|
-
Requires-Dist: xlrd>=2.0.2
|
|
11
8
|
License-File: LICENSE
|
|
12
9
|
Summary: A Rust-powered NumPy-compatible array library.
|
|
13
10
|
Author: YJ-Niu
|
|
@@ -6,10 +6,16 @@ set -euo pipefail
|
|
|
6
6
|
|
|
7
7
|
RELEASE=true
|
|
8
8
|
OUT_DIR="wheelhouse"
|
|
9
|
+
cache_file="/Users/user/Desktop/rust_project/rsplotlib/python/rsplotlib/rsplotlib.cpython-313-darwin.so"
|
|
9
10
|
# 如果 wheelhouse 目录存在, 则删除
|
|
10
11
|
if [[ -d "$OUT_DIR" ]]; then
|
|
11
12
|
rm -rf "$OUT_DIR"
|
|
12
13
|
fi
|
|
14
|
+
# 如果 cache_file 目录存在, 则删除
|
|
15
|
+
if [[ -f "$cache_file" ]]; then
|
|
16
|
+
rm "$cache_file"
|
|
17
|
+
fi
|
|
18
|
+
|
|
13
19
|
# Default python executable; may be overridden by --python or positional arg
|
|
14
20
|
PYTHON_EXEC="python"
|
|
15
21
|
# Flag set when the user explicitly provided a Python executable
|
|
@@ -70,18 +76,6 @@ if [[ -n "$WHEEL" && -f "$WHEEL" ]]; then
|
|
|
70
76
|
else
|
|
71
77
|
echo "Warning: .venv not found; skip install. Wheels available in $OUT_DIR" >&2
|
|
72
78
|
fi
|
|
73
|
-
# 同步 .so 到项目内的 rsnumpy 包目录,避免本地源包遮蔽安装的 wheel
|
|
74
|
-
SO_FILE=".venv/lib/python${PYTHON_VERSION:-3.13}/site-packages/rsnumpy/_core.cpython-${PYTHON_VERSION:-313}-darwin.so"
|
|
75
|
-
if [[ -f "$SO_FILE" ]]; then
|
|
76
|
-
cp -f "$SO_FILE" "rsnumpy/_core.cpython-${PYTHON_VERSION:-313}-darwin.so" 2>/dev/null || true
|
|
77
|
-
fi
|
|
78
|
-
# 通用回退:找任何 .venv 中刚生成的 _core .so
|
|
79
|
-
SO_GLOB=$(ls .venv/lib/python*/site-packages/rsnumpy/_core.cpython-*-darwin.so 2>/dev/null | head -1)
|
|
80
|
-
if [[ -n "$SO_GLOB" && -f "$SO_GLOB" ]]; then
|
|
81
|
-
DEST="rsnumpy/$(basename "$SO_GLOB")"
|
|
82
|
-
cp -f "$SO_GLOB" "$DEST"
|
|
83
|
-
echo "Synced $DEST"
|
|
84
|
-
fi
|
|
85
79
|
else
|
|
86
80
|
echo "Warning: no .whl file found in $OUT_DIR; skip install." >&2
|
|
87
81
|
fi
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "rsnumpy"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.7"
|
|
8
8
|
requires-python = ">=3.8"
|
|
9
9
|
description = "A Rust-powered NumPy-compatible array library."
|
|
10
10
|
readme = "README.md"
|
|
@@ -19,12 +19,8 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python :: Implementation :: PyPy",
|
|
20
20
|
]
|
|
21
21
|
dynamic = ["version"]
|
|
22
|
-
dependencies = [
|
|
23
|
-
"maturin>=1.14.0",
|
|
24
|
-
"rsplotlib>=0.1.4",
|
|
25
|
-
"xlrd>=2.0.2",
|
|
26
|
-
]
|
|
27
22
|
|
|
28
23
|
[tool.maturin]
|
|
29
24
|
module-name = "rsnumpy._core"
|
|
30
|
-
|
|
25
|
+
python-source = "python"
|
|
26
|
+
include = ["python/rsnumpy/__init__.py", "python/rsnumpy/linalg/__init__.py", "python/rsnumpy/random/__init__.py"]
|
|
@@ -107,13 +107,9 @@ fn format_array_repr(arr: &Array<f64, IxDyn>, _prefix: &str) -> String {
|
|
|
107
107
|
let mut s = String::from("[");
|
|
108
108
|
for (i, val) in arr.iter().enumerate() {
|
|
109
109
|
if i > 0 {
|
|
110
|
-
s.push_str("
|
|
111
|
-
}
|
|
112
|
-
if *val == val.floor() && val.is_finite() {
|
|
113
|
-
s.push_str(&format!("{}.", val));
|
|
114
|
-
} else {
|
|
115
|
-
s.push_str(&format!("{}", val));
|
|
110
|
+
s.push_str(" ");
|
|
116
111
|
}
|
|
112
|
+
s.push_str(&format_scalar(*val));
|
|
117
113
|
}
|
|
118
114
|
s.push(']');
|
|
119
115
|
return s;
|
|
@@ -122,17 +118,34 @@ fn format_array_repr(arr: &Array<f64, IxDyn>, _prefix: &str) -> String {
|
|
|
122
118
|
let n = arr.shape()[0];
|
|
123
119
|
for i in 0..n {
|
|
124
120
|
if i > 0 {
|
|
125
|
-
s.push_str("
|
|
121
|
+
s.push_str("\n ");
|
|
126
122
|
}
|
|
127
123
|
let sub = arr.index_axis(Axis(0), i).to_owned().into_dyn();
|
|
128
124
|
let row_str = format_array_repr(&sub, "");
|
|
129
|
-
s.push_str(" ");
|
|
130
125
|
s.push_str(&row_str);
|
|
131
126
|
}
|
|
132
127
|
s.push_str("]");
|
|
133
128
|
s
|
|
134
129
|
}
|
|
135
130
|
|
|
131
|
+
fn format_scalar(val: f64) -> String {
|
|
132
|
+
if val.is_nan() {
|
|
133
|
+
return "nan".to_string();
|
|
134
|
+
}
|
|
135
|
+
if val.is_infinite() {
|
|
136
|
+
return if val > 0.0 { "inf".to_string() } else { "-inf".to_string() };
|
|
137
|
+
}
|
|
138
|
+
if val == val.floor() && val.is_finite() && val.abs() < 1e16 {
|
|
139
|
+
// 整数值不显示小数点,与 numpy print 输出一致
|
|
140
|
+
let v = val as i64;
|
|
141
|
+
if v as f64 == val {
|
|
142
|
+
return format!("{}", v);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
let s = format!("{}", val);
|
|
146
|
+
s
|
|
147
|
+
}
|
|
148
|
+
|
|
136
149
|
/// NdArray: 类似 NumPy ndarray 的多维数组
|
|
137
150
|
#[pyclass(name = "ndarray", from_py_object)]
|
|
138
151
|
#[derive(Clone)]
|
|
@@ -161,6 +174,11 @@ impl NdArray {
|
|
|
161
174
|
Ok(format!("rsnumpy.ndarray({}) dtype=float64", arr_str))
|
|
162
175
|
}
|
|
163
176
|
|
|
177
|
+
fn __str__(&self) -> PyResult<String> {
|
|
178
|
+
let arr_str = format_array_repr(&self.data, "");
|
|
179
|
+
Ok(arr_str)
|
|
180
|
+
}
|
|
181
|
+
|
|
164
182
|
fn __len__(&self) -> PyResult<usize> {
|
|
165
183
|
if self.data.ndim() == 0 {
|
|
166
184
|
return Err(PyTypeError::new_err("len() of unsized object"));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|