numrs2 0.3.2

A Rust implementation inspired by NumPy for numerical computing (NumRS2)
Documentation
[package]
name = "numrs2"
version = "0.3.2"
edition = "2021"
authors = ["COOLJAPAN OU (Team KitaSan)"]
description = "A Rust implementation inspired by NumPy for numerical computing (NumRS2)"
license = "Apache-2.0"
repository = "https://github.com/cool-japan/numrs"
homepage = "https://github.com/cool-japan/numrs"
documentation = "https://docs.rs/numrs2"
readme = "README.md"
keywords = ["numpy", "numerical", "array", "linear-algebra", "mathematics"]
categories = ["science"]

[lib]
name = "numrs2"
# Note: For Python extension, use maturin to build. cdylib is not needed in Cargo.toml
# as maturin handles this automatically. Only rlib is needed for Rust library usage.

[lints]
workspace = true

[features]
default = ["matrix_decomp", "scirs"]
matrix_decomp = []
validation = []
unstable = []
fast = []  # Minimal feature set for fast compilation during development
scirs = []  # MANDATORY: Always enabled by default per SCIRS2 POLICY - DO NOT DISABLE
# SciRS2 integration is mandatory - this feature exists only for backward compatibility
gpu = ["dep:wgpu", "dep:bytemuck", "dep:futures-intrusive", "dep:tokio"]
lapack = []  # Enable LAPACK-dependent linear algebra operations (through scirs2-linalg which uses OxiBLAS)
python = ["dep:pyo3", "dep:scirs2-numpy"]  # Python bindings via PyO3
arrow = ["dep:arrow", "dep:arrow-array", "dep:arrow-buffer", "dep:arrow-cast", "dep:arrow-schema"]  # Apache Arrow integration
parquet = ["dep:parquet"]  # Apache Parquet format support (pure Rust)
netcdf = ["dep:netcdf3"]  # NetCDF-3 format support (pure Rust)
matlab = ["dep:matfile"]  # MATLAB .mat file I/O (pure Rust)
messagepack = ["dep:rmp-serde"]  # MessagePack serialization (pure Rust)
bson = ["dep:bson"]  # BSON format support (pure Rust)
io-all = ["arrow", "parquet", "netcdf", "matlab", "messagepack", "bson"]  # Enable all I/O formats
wasm = ["dep:wasm-bindgen", "dep:wasm-bindgen-futures", "dep:js-sys", "dep:web-sys", "dep:console_error_panic_hook", "dep:wee_alloc"]  # WebAssembly support
distributed = ["dep:tokio", "tokio/net", "tokio/io-util", "tokio/rt-multi-thread", "tokio/macros", "tokio/time"]  # Distributed computing support (Pure Rust, no MPI)
visualization = ["dep:plotters", "dep:plotters-backend", "dep:plotters-svg", "dep:resvg", "dep:usvg", "dep:tiny-skia", "dep:rgb"]  # Advanced visualization tools (pure Rust)
ci-safe = ["matrix_decomp", "validation"]  # Safe features for CI without external dependencies

[dependencies]
# ===================================================================
# SCIRS2 ECOSYSTEM DEPENDENCIES (MANDATORY) - Using crates.io v0.3.0
# ===================================================================
# ALL external functionality (ndarray, rand, rayon, BLAS) goes through scirs2-core
# Using crates.io versions for stable 0.3.0 release
scirs2-core = { version = "0.4.0", features = ["random", "array", "simd", "parallel", "linalg"] }
scirs2-stats = { version = "0.4.0" }
scirs2-linalg = { version = "0.4.0" }
scirs2-ndimage = { version = "0.4.0" }
scirs2-spatial = { version = "0.4.0", features = ["parallel"] }
scirs2-special = { version = "0.4.0" }
scirs2-fft = { version = "0.4.0" }

# ===================================================================
# ALLOWED DEPENDENCIES (Non-conflicting)
# ===================================================================
num-traits = "0.2.19"  # Numeric traits for generic math (compatible with SciRS2)
paste = "1.0.15"       # For macro development
thiserror = "2.0.18"   # Error handling
lazy_static = "1.5.0"  # For static initialization patterns

# Serialization/IO support
serde = { version = "1.0.228", features = ["derive"] }
serde_json = "1.0.149"
csv = "1.4.0"
oxicode = { version = "0.2", features = ["serde"] }
byteorder = "1.5.0"    # For NPY format byte order handling
oxiarc-archive = { version = "0.2.6" }  # Pure Rust ZIP/archive support (COOLJAPAN Policy)
# NPZ format support with pure Rust compression (DEFLATE via OxiARC)
serde-pickle = "1.2.0" # Python pickle format support
memmap2 = "0.9.10"      # Memory-mapped file I/O
num_cpus = "1.17.0"
regex = "1.12.3"
chrono = { version = "0.4.44", default-features = false, features = ["std", "clock"] }  # Date and time for model metadata

# Note: BLAS/LAPACK operations go through scirs2-linalg (which uses OxiBLAS internally)
# No direct BLAS/LAPACK dependencies needed - pure Rust via SciRS2 ecosystem

# ===================================================================
# FORBIDDEN (Removed per SCIRS2 POLICY)
# ===================================================================
# ❌ ndarray = "0.16.1"        # FORBIDDEN - Use scirs2_core::ndarray
# ❌ rand = "0.9.2"            # FORBIDDEN - Use scirs2_core::random
# ❌ rand_distr = "0.5.1"      # FORBIDDEN - Use scirs2_core::random
# ❌ rayon = "1.11.0"          # FORBIDDEN - Use scirs2_core::parallel_ops
# ❌ num-complex = "0.4.6"     # FORBIDDEN - Use scirs2_core::complex
# ❌ nalgebra = "0.34.1"       # FORBIDDEN - BLAS through scirs2-core
# ❌ simba = "0.9.1"           # FORBIDDEN - SIMD through scirs2_core::simd_ops
# ❌ blas = "0.23.0"           # FORBIDDEN - Use oxiblas-blas (pure Rust)
# ❌ lapack = "0.20.0"         # FORBIDDEN - Use oxiblas-lapack (pure Rust)
# ❌ openblas-src = "*"        # FORBIDDEN - Use oxiblas (pure Rust, no C dependencies)
# ❌ ndarray-linalg = "*"      # FORBIDDEN - Use oxiblas-ndarray (pure Rust)

# Optional GPU acceleration dependencies
wgpu = { version = "29.0.1", optional = true }
bytemuck = { version = "1.25.0", features = ["derive"], optional = true }
futures-intrusive = { version = "0.5.0", optional = true }
tokio = { version = "1.50.0", features = ["sync", "rt", "net", "io-util", "rt-multi-thread", "macros"], optional = true }

# Optional Python bindings dependencies
pyo3 = { version = "0.28.2", features = ["extension-module"], optional = true }
scirs2-numpy = { workspace = true, optional = true }

# Optional Apache Arrow dependencies (via SciRS2 workspace)
arrow = { workspace = true, optional = true }
arrow-array = { workspace = true, optional = true }
arrow-buffer = { workspace = true, optional = true }
arrow-cast = { workspace = true, optional = true }
arrow-schema = { workspace = true, optional = true }

# Optional I/O format dependencies (Pure Rust - COOLJAPAN Policy)
parquet = { workspace = true, optional = true }  # Apache Parquet (pure Rust)
netcdf3 = { version = "0.6.0", optional = true }  # NetCDF-3 (pure Rust)
matfile = { version = "0.5.0", optional = true, features = ["ndarray"] }  # MATLAB .mat files (pure Rust)
rmp-serde = { version = "1.3.1", optional = true }  # MessagePack (pure Rust)
bson = { version = "3.1.0", optional = true, features = ["serde"] }  # BSON (pure Rust)

# Optional WebAssembly dependencies (Pure Rust - COOLJAPAN Policy)
wasm-bindgen = { version = "0.2.114", optional = true, features = ["serde-serialize"] }  # WebAssembly bindings
wasm-bindgen-futures = { version = "0.4.64", optional = true }  # Async/await support for WASM
js-sys = { version = "0.3.91", optional = true }  # JavaScript standard library bindings
web-sys = { version = "0.3.91", optional = true, features = ["console", "Window", "Performance"] }  # Web API bindings
console_error_panic_hook = { version = "0.1.7", optional = true }  # Better panic messages in WASM
wee_alloc = { version = "0.4.5", optional = true }  # Small allocator for WASM

# Optional Visualization dependencies (Pure Rust - COOLJAPAN Policy)
plotters = { version = "0.3.7", optional = true }  # High-performance plotting library
plotters-backend = { version = "0.3.7", optional = true }  # Plotters backend API
plotters-svg = { version = "0.3.7", optional = true }  # SVG backend for plotters
resvg = { version = "0.47.0", optional = true }  # SVG rendering library
usvg = { version = "0.47.0", optional = true }  # SVG simplification library
tiny-skia = { version = "0.12.0", optional = true }  # Tiny Skia subset for rendering
rgb = { version = "0.8.53", optional = true }  # RGB color types

# Note: polars dependency has been removed to improve build speed

# WebAssembly target-specific dependencies
[target.'cfg(target_arch = "wasm32")'.dependencies]
# Enable getrandom for wasm32 (works for both 0.2 and 0.3)
# We need to add a build dependency that forces the correct features
# For now, we add getrandom to regular deps with wasm features

# Force getrandom v0.3 with WASM support enabled
getrandom = { version = "0.4", default-features = false, features = ["wasm_js"] }
# Also add v0.2 with renamed package for transitive deps using older rand
getrandom_02 = { package = "getrandom", version = "=0.2.17", default-features = false, features = ["js"] }
# uuid also needs WASM support enabled
uuid = { version = "1.23", features = ["js"] }  # Enable JS random for WASM

[dev-dependencies]
criterion = "0.8.2"  # Benchmarking library
approx = "0.5.1"     # Approximate floating-point comparisons for tests
tempfile = "3.27.0"   # Temporary files for testing I/O functionality
proptest = "1.11.0"   # Property-based testing for mathematical invariants
serial_test = "3.4.0"  # For tests that require serial execution (global state)
wasm-bindgen-test = "0.3.64"  # Testing framework for WebAssembly
# For performance benchmarks in bench.rs
serde_json = "1.0.149"  # For loading NumPy benchmark results
tokio = { version = "1.50.0", features = ["rt", "macros"] }  # For GPU tests

[workspace.lints.rust]
unused_variables = "allow"
unused_imports = "allow"
mismatched_lifetime_syntaxes = "allow"
dead_code = "allow"
unpredictable_function_pointer_comparisons = "allow"
unknown_lints = "allow"

# ===================================================================
# PERFORMANCE OPTIMIZATION PROFILES
# ===================================================================
# Optimized release profile for maximum performance
[profile.release]
opt-level = 3              # Maximum optimization level
lto = "fat"                # Full Link-Time Optimization for cross-crate inlining
codegen-units = 1          # Single codegen unit for better optimization (slower compile)
strip = true               # Strip symbols from binary (smaller size, no debug info)
panic = "abort"            # Abort on panic (smaller binary, faster code)
overflow-checks = false    # Disable overflow checks in release (use with caution)
debug = false              # No debug information in release builds

# Benchmark profile with debug info for profiling
[profile.bench]
inherits = "release"
debug = true               # Keep debug info for flamegraph/profiling tools
strip = false              # Keep symbols for profiling

# Development profile optimized for compilation speed
[profile.dev]
opt-level = 0              # No optimization for fast compilation
debug = true               # Full debug information
overflow-checks = true     # Enable overflow checks in debug

# Test profile with optimizations for faster test execution
[profile.test]
opt-level = 2              # Some optimization for faster tests
debug = true               # Keep debug info for debugging test failures
overflow-checks = true     # Keep safety checks in tests

[[bench]]
name = "numpy_comparison"
path = "bench/bench.rs"
harness = true

[[bench]]
name = "bench_distributions"
path = "bench/bench_distributions.rs"
harness = false

[[bench]]
name = "numpy_comparison_benchmark"
path = "bench/numpy_comparison_benchmark.rs"
harness = false

[[bench]]
name = "core_operations_benchmark"
path = "bench/core_operations_benchmark.rs"
harness = false

[[bench]]
name = "simd_vs_scalar_benchmark"
path = "bench/simd_vs_scalar_benchmark.rs"
harness = false

[[bench]]
name = "expression_templates_benchmark"
path = "bench/expression_templates_benchmark.rs"
harness = false

# ===================================================================
# COMPREHENSIVE BENCHMARK SUITE (v1.0.0 / 0.2.0)
# ===================================================================

[[bench]]
name = "linalg_benchmarks"
path = "bench/linalg_benchmarks.rs"
harness = false

[[bench]]
name = "stats_benchmarks"
path = "bench/stats_benchmarks.rs"
harness = false

[[bench]]
name = "fft_benchmarks"
path = "bench/fft_benchmarks.rs"
harness = false

[[bench]]
name = "array_ops_benchmarks"
path = "bench/array_ops_benchmarks.rs"
harness = false

[[bench]]
name = "optimization_benchmarks"
path = "bench/optimization_benchmarks.rs"
harness = false

[[bench]]
name = "simd_comparison_benchmark"
path = "bench/simd_comparison_benchmark.rs"
harness = false

[[bench]]
name = "parallel_benchmarks"
path = "bench/parallel_benchmarks.rs"
harness = false

[[bench]]
name = "memory_benchmarks"
path = "bench/memory_benchmarks.rs"
harness = false

[[bench]]
name = "nn_benchmarks"
path = "bench/nn_benchmarks.rs"
harness = false

[[bench]]
name = "distributed_benchmarks"
path = "bench/distributed_benchmarks.rs"
harness = false
required-features = ["distributed"]

# ===================================================================
# v0.2.0 ENHANCED BENCHMARKS (benches/ directory)
# ===================================================================

[[bench]]
name = "multi_objective_benchmark"
path = "benches/multi_objective_benchmark.rs"
harness = false

[[bench]]
name = "memory_optimization_benchmark"
path = "benches/memory_optimization_benchmark.rs"
harness = false

[[bench]]
name = "parallel_algorithms_benchmark"
path = "benches/parallel_algorithms_benchmark.rs"
harness = false

[[bench]]
name = "cache_alignment_benchmark"
path = "benches/cache_alignment_benchmark.rs"
harness = false

# ===================================================================
# WORKSPACE CONFIGURATION (SCIRS2 POLICY)
# ===================================================================
# Using crates.io releases for stable SciRS2 dependencies
[workspace.dependencies]
scirs2-core = { version = "0.4.0" }
scirs2-stats = { version = "0.4.0" }
scirs2-linalg = { version = "0.4.0" }
scirs2-ndimage = { version = "0.4.0" }
scirs2-spatial = { version = "0.4.0" }
scirs2-special = { version = "0.4.0" }
scirs2-fft = { version = "0.4.0" }
scirs2-numpy = { version = "0.4.0" }

# Apache Arrow ecosystem (from SciRS2 workspace)
arrow = "58.1.0"
arrow-array = "58.1.0"
arrow-buffer = "58.1.0"
arrow-cast = "58.1.0"
arrow-schema = "58.1.0"
parquet = "58.1.0"  # Apache Parquet (pure Rust)


# ===================================================================