A comprehensive numerical operations library in pure Python
Project description
numopspy
numopspy is a comprehensive Python library for numerical operations, mathematical computations, and array manipulations built with pure Python. It’s designed to be a robust alternative to popular libraries like NumPy, with added features and functionalities that simplify advanced numerical, statistical, geospatial, and time-series tasks.
Introduction
While existing libraries like NumPy are excellent for numerical computations, numopspy bridges the gap by introducing unique functionalities and eliminating common dependencies. Designed with simplicity and versatility in mind, numopspy empowers users to perform operations traditionally split across multiple libraries — all within a lightweight, dependency-free package.
Why Choose numopspy?
- No External Dependencies: Written entirely in pure Python.
- Expanded Functionality: Supports advanced features like geospatial operations, symbolic mathematics, dynamic arrays, and batch operations.
- Categorized Functions: A complete suite of 322 functions, categorized and easy to use.
- Enhanced Array Handling: Geospatial arrays, sparse arrays, hierarchical indexing, and more.
- Advanced Time Series and Statistical Analysis: Functions for rolling averages, seasonal decomposition, skewness, kurtosis, and other metrics.
New Features in numopspy
- Sparse Matrix and Array Support:
- Sparse to dense conversion, density-based sparse creation, and more.
- Comprehensive Complex Number Handling:
- Polar/Cartesian transformations, FFT for complex arrays, and more.
- Geospatial Functions:
- Euclidean, Manhattan, and geodesic distance computations.
- Differentiation and Integration:
- Numerical derivatives, gradients, and cumulative integrals.
- Time Series Analysis:
- Autocorrelation, moving averages, and trend decomposition.
- Array Validation and Meta Information:
- Validate shape compatibility, symmetry, and retrieve comprehensive statistics.
- Batch Operations:
- Batch-wise addition, multiplication, and aggregation of arrays.
Complete List of Functions (322)
Here’s the complete list of Core Array Functions categorized under Array Creation, with all functions detailed:
Array Creation Functions
zeros(shape)
: Create an array filled with zeros.ones(shape)
: Create an array filled with ones.full(shape, fill_value)
: Create an array filled with a specified value.empty(shape)
: Create an uninitialized array.arange(start, stop, step)
: Create an array with evenly spaced values.linspace(start, stop, num)
: Create an array withnum
evenly spaced points betweenstart
andstop
.logspace(start, stop, num, base)
: Create an array withnum
logarithmically spaced points betweenbase**start
andbase**stop
.eye(n, m)
: Create a 2D array with ones on the diagonal and zeros elsewhere.identity(n)
: Create an identity matrix.diag(v, k=0)
: Create a diagonal matrix from a 1D array or extract a diagonal from a 2D array.from_iterable(iterable)
: Create an array from an iterable object.from_function(func, shape)
: Create an array by applying a function to each coordinate.meshgrid(*arrays)
: Generate coordinate matrices from coordinate vectors.empty_like(array)
: Create an uninitialized array with the same shape as a given array.zeros_like(array)
: Create an array of zeros with the same shape as a given array.ones_like(array)
: Create an array of ones with the same shape as a given array.full_like(array, fill_value)
: Create an array filled with a specified value with the same shape as a given array.mgrid[start:stop:step]
: Create a dense multi-dimensional grid.ogrid[start:stop:step]
: Create an open multi-dimensional grid.random(shape, seed=None)
: Create an array filled with random values between 0 and 1.
Array Manipulation Functions
reshape(array, new_shape)
: Reshape an array without changing data.ravel(array)
: Flatten an array into 1D.flatten(array)
: Return a copy of the array collapsed into 1D.expand_dims(array, axis)
: Expand the shape of an array by adding a new axis.squeeze(array, axis=None)
: Remove single-dimensional entries from the shape of an array.concatenate(arrays, axis)
: Join arrays along a specified axis.stack(arrays, axis)
: Stack arrays along a new dimension.vstack(arrays)
: Stack arrays vertically (row-wise).hstack(arrays)
: Stack arrays horizontally (column-wise).dstack(arrays)
: Stack arrays along the depth (third dimension).column_stack(arrays)
: Stack 1D arrays as columns into a 2D array.row_stack(arrays)
: Stack 1D arrays as rows into a 2D array.split(array, indices, axis)
: Split an array into multiple sub-arrays along a specified axis.array_split(array, sections, axis)
: Split an array into unequal parts along a specified axis.hsplit(array, sections)
: Split an array horizontally (column-wise).vsplit(array, sections)
: Split an array vertically (row-wise).dsplit(array, sections)
: Split an array along the depth (third dimension).roll(array, shift, axis)
: Roll array elements along a specified axis.flip(array, axis)
: Reverse the order of elements along a specified axis.rot90(array, k, axes)
: Rotate an array by 90 degreesk
times.transpose(array, axes)
: Permute the dimensions of an array.swapaxes(array, axis1, axis2)
: Interchange two axes of an array.moveaxis(array, source, destination)
: Move specified axes to new positions.pad(array, pad_width, mode)
: Pad an array with specified values.repeat(array, repeats, axis)
: Repeat elements of an array along a specified axis.tile(array, reps)
: Construct an array by repeatingarray
the number of times given byreps
.resize(array, new_shape)
: Resize an array, trimming or padding with zeros as necessary.append(array, values, axis)
: Append values to an array along a specified axis.insert(array, index, values, axis)
: Insert values along a specified axis at a given index.delete(array, index, axis)
: Delete elements from an array along a specified axis.where(condition, x, y)
: Return elements chosen fromx
ory
depending oncondition
.nonzero(array)
: Return the indices of non-zero elements.argwhere(array)
: Return the indices where the condition isTrue
.flatnonzero(array)
: Return the indices of non-zero elements in the flattened array.diag(array, k=0)
: Extract or construct a diagonal matrix.tril(array, k=0)
: Lower triangle of an array.triu(array, k=0)
: Upper triangle of an array.indices(dimensions)
: Return a grid of indices for a given shape.broadcast(array1, array2)
: Broadcast two arrays to a common shape.broadcast_to(array, shape)
: Broadcast an array to a new shape.ix_(*arrays)
: Construct index arrays for advanced broadcasting.
Mathematical Functions
-
Arithmetic Operations
add_elementwise(array1, array2)
: Perform element-wise addition.subtract_elementwise(array1, array2)
: Perform element-wise subtraction.multiply_elementwise(array1, array2)
: Perform element-wise multiplication.divide_elementwise(array1, array2)
: Perform element-wise division.modulus(array1, array2)
: Compute the element-wise modulus.power(array, exponent)
: Raise each element of the array to the specified power.sqrt(array)
: Compute the square root of each element.absolute(array)
: Compute the absolute value of each element.reciprocal(array)
: Compute the reciprocal of each element.negate(array)
: Negate each element in the array.sign(array)
: Return the sign of each element (1
for positive,-1
for negative, and0
for zero).floor(array)
: Compute the floor of each element.ceil(array)
: Compute the ceiling of each element.round(array, decimals)
: Round each element to the specified number of decimals.clip(array, min_val, max_val)
: Clip values in the array to a specified range.exp(array)
: Compute the exponential of each element.log(array)
: Compute the natural logarithm of each element.log10(array)
: Compute the base-10 logarithm of each element.log2(array)
: Compute the base-2 logarithm of each element.sin(array)
: Compute the sine of each element.cos(array)
: Compute the cosine of each element.tan(array)
: Compute the tangent of each element.arcsin(array)
: Compute the inverse sine of each element.arccos(array)
: Compute the inverse cosine of each element.arctan(array)
: Compute the inverse tangent of each element.arctan2(y, x)
: Compute the element-wise arc tangent ofy/x
considering the quadrant.sinh(array)
: Compute the hyperbolic sine of each element.cosh(array)
: Compute the hyperbolic cosine of each element.tanh(array)
: Compute the hyperbolic tangent of each element.deg2rad(array)
: Convert degrees to radians for each element.rad2deg(array)
: Convert radians to degrees for each element.
-
Special Functions
gamma_function(array)
: Compute the gamma function for each element.beta_function(array1, array2)
: Compute the beta function element-wise.factorial(array)
: Compute the factorial for each integer in the array.digamma(array)
: Compute the digamma function for each element.erf(array)
: Compute the error function for each element.erfc(array)
: Compute the complementary error function for each element.zeta(array, q)
: Compute the Riemann zeta function for each element.lambertw(array)
: Compute the Lambert W function for each element.heaviside(array, value)
: Compute the Heaviside step function for each element.binomial_coefficient(n, k)
: Compute the binomial coefficient element-wise.legendre_polynomial(n, x)
: Compute the Legendre polynomial of degreen
atx
.hermite_polynomial(n, x)
: Compute the Hermite polynomial of degreen
atx
.laguerre_polynomial(n, x)
: Compute the Laguerre polynomial of degreen
atx
.
Statistical Operations
-
Descriptive Statistics
array_summary(array)
: Retrieve comprehensive statistics for an array.mean(array)
: Compute the mean.median(array)
: Compute the median.variance(array)
: Compute the variance.std(array)
: Compute the standard deviation.skewness(array)
: Compute the skewness.kurtosis(array)
: Compute the kurtosis.range(array)
: Compute the range of the array.min(array)
: Compute the minimum value in the array.max(array)
: Compute the maximum value in the array.percentile(array, q)
: Compute the q-th percentile of the array.quantiles(array, num_quantiles)
: Compute specified quantiles of the array.iqr(array)
: Compute the interquartile range.geometric_mean(array)
: Compute the geometric mean.harmonic_mean(array)
: Compute the harmonic mean.mode(array)
: Compute the mode of the array.
-
Correlation and Covariance
correlation_coefficient(array1, array2)
: Compute Pearson’s correlation coefficient.covariance(array1, array2)
: Compute the covariance between two arrays.spearman_rank_correlation(array1, array2)
: Compute Spearman’s rank correlation coefficient.kendall_tau(array1, array2)
: Compute Kendall’s Tau correlation coefficient.auto_correlation(array, lag)
: Compute the autocorrelation of an array for a given lag.partial_correlation(array1, array2, control)
: Compute the partial correlation between two arrays while controlling for a third.cross_correlation(array1, array2)
: Compute the cross-correlation between two arrays.distance_correlation(array1, array2)
: Compute the distance correlation between two arrays.correlation_matrix(matrix)
: Compute the correlation matrix for a set of variables.covariance_matrix(matrix)
: Compute the covariance matrix for a set of variables.
Linear Algebra
-
Matrix Operations
linalg_det(matrix)
: Compute the determinant of a matrix.linalg_inv(matrix)
: Compute the inverse of a matrix.transpose(matrix)
: Transpose a matrix.matrix_power(matrix, n)
: Raise a matrix to the powern
.kronecker_product(matrix1, matrix2)
: Compute the Kronecker product of two matrices.hadamard_product(matrix1, matrix2)
: Compute the Hadamard (element-wise) product of two matrices.dot(matrix1, matrix2)
: Compute the dot product of two matrices.vdot(matrix1, matrix2)
: Compute the vector dot product.inner_product(matrix1, matrix2)
: Compute the inner product of two matrices.outer_product(matrix1, matrix2)
: Compute the outer product of two matrices.tensordot(matrix1, matrix2, axes)
: Compute the tensor dot product along specified axes.cholesky_decomposition(matrix)
: Compute the Cholesky decomposition of a matrix.qr_decomposition(matrix)
: Compute the QR decomposition of a matrix.svd(matrix)
: Compute the Singular Value Decomposition (SVD) of a matrix.eigenvalues(matrix)
: Compute the eigenvalues of a matrix.eigenvectors(matrix)
: Compute the eigenvectors of a matrix.matrix_rank(matrix)
: Compute the rank of a matrix.pinv(matrix)
: Compute the pseudo-inverse of a matrix.trace(matrix)
: Compute the trace (sum of diagonal elements) of a matrix.norm(matrix, ord)
: Compute the matrix norm with a specified order.frobenius_norm(matrix)
: Compute the Frobenius norm of a matrix.
Geospatial Operations
-
Geospatial Calculations
euclidean_distance(coord1, coord2)
: Compute the Euclidean distance between two points.manhattan_distance(coord1, coord2)
: Compute the Manhattan distance between two points.geodesic_distance(coord1, coord2)
: Compute the geodesic distance (great-circle distance) between two points on the Earth's surface.rotate_coordinates(coords, angle, center)
: Rotate a set of coordinates around a specified center by a given angle.translate_coordinates(coords, vector)
: Translate a set of coordinates by a specified vector.midpoint(coord1, coord2)
: Compute the midpoint between two coordinates.bearing(coord1, coord2)
: Calculate the initial bearing (azimuth) between two points.bounding_box(coords)
: Compute the bounding box for a set of coordinates.polygon_area(vertices)
: Calculate the area of a polygon defined by its vertices.haversine_distance(coord1, coord2)
: Compute the Haversine distance between two geographical points.
Random Sampling
-
Random Generators
random_rand(n)
: Generaten
random numbers between 0 and 1.random_normal(mean, std, size)
: Generate samples from a normal distribution.random_uniform(low, high, size)
: Generate samples from a uniform distribution.random_choice(array, size)
: Randomly sample elements from an array.random_randint(low, high, size)
: Generate random integers within a specified range.random_beta(alpha, beta, size)
: Generate samples from a Beta distribution.random_binomial(n, p, size)
: Generate samples from a Binomial distribution.random_chisquare(df, size)
: Generate samples from a Chi-square distribution.random_exponential(scale, size)
: Generate samples from an Exponential distribution.random_f(dfnum, dfden, size)
: Generate samples from an F-distribution.random_gamma(shape, scale, size)
: Generate samples from a Gamma distribution.random_geometric(p, size)
: Generate samples from a Geometric distribution.random_gumbel(loc, scale, size)
: Generate samples from a Gumbel distribution.random_hypergeometric(ngood, nbad, nsample, size)
: Generate samples from a Hypergeometric distribution.random_laplace(loc, scale, size)
: Generate samples from a Laplace distribution.random_logistic(loc, scale, size)
: Generate samples from a Logistic distribution.random_lognormal(mean, sigma, size)
: Generate samples from a Log-Normal distribution.random_multinomial(n, pvals, size)
: Generate samples from a Multinomial distribution.random_multivariate_normal(mean, cov, size)
: Generate samples from a Multivariate Normal distribution.random_negative_binomial(n, p, size)
: Generate samples from a Negative Binomial distribution.random_noncentral_chisquare(df, nonc, size)
: Generate samples from a Noncentral Chi-square distribution.random_pareto(a, size)
: Generate samples from a Pareto distribution.random_poisson(lam, size)
: Generate samples from a Poisson distribution.random_power(a, size)
: Generate samples from a Power distribution.random_rayleigh(scale, size)
: Generate samples from a Rayleigh distribution.random_standard_cauchy(size)
: Generate samples from a Standard Cauchy distribution.random_standard_exponential(size)
: Generate samples from a Standard Exponential distribution.random_standard_normal(size)
: Generate samples from a Standard Normal distribution.random_standard_t(df, size)
: Generate samples from a Standard T-distribution.random_triangular(left, mode, right, size)
: Generate samples from a Triangular distribution.random_vonmises(mu, kappa, size)
: Generate samples from a Von Mises distribution.random_wald(mean, scale, size)
: Generate samples from a Wald distribution.random_weibull(a, size)
: Generate samples from a Weibull distribution.random_zipf(a, size)
: Generate samples from a Zipf distribution.random_seed(seed)
: Set the random seed for reproducibility.
Fourier Transforms
-
1D and Multi-Dimensional FFT
fft(array)
: Perform a 1D Fast Fourier Transform.ifft(array)
: Perform a 1D Inverse Fast Fourier Transform.fft2(array)
: Perform a 2D Fast Fourier Transform.ifft2(array)
: Perform a 2D Inverse Fast Fourier Transform.fftn(array, axes)
: Perform an n-dimensional Fast Fourier Transform along specified axes.ifftn(array, axes)
: Perform an n-dimensional Inverse Fast Fourier Transform along specified axes.rfft(array)
: Perform a 1D real-input Fast Fourier Transform.irfft(array)
: Perform a 1D Inverse Fast Fourier Transform on real input.rfft2(array)
: Perform a 2D real-input Fast Fourier Transform.irfft2(array)
: Perform a 2D Inverse Fast Fourier Transform on real input.rfftn(array, axes)
: Perform an n-dimensional real-input Fast Fourier Transform.irfftn(array, axes)
: Perform an n-dimensional Inverse Fast Fourier Transform on real input.fftshift(array)
: Shift the zero-frequency component to the center of the spectrum.ifftshift(array)
: Undo the shift applied byfftshift
.fftfreq(n, d)
: Return the Discrete Fourier Transform sample frequencies.rfftfreq(n, d)
: Return the sample frequencies for a real-input FFT.
Differentiation and Integration
-
Numerical Differentiation
finite_difference(array, dx)
: Compute numerical derivatives using finite differences.gradient(array, spacing)
: Compute the gradient of an array.jacobian_matrix(func, array)
: Compute the Jacobian matrix for a vector function.hessian_matrix(func, array)
: Compute the Hessian matrix for a scalar function.central_difference(array, dx)
: Compute numerical derivatives using the central difference method.forward_difference(array, dx)
: Compute numerical derivatives using the forward difference method.backward_difference(array, dx)
: Compute numerical derivatives using the backward difference method.partial_derivative(func, array, index, dx)
: Compute the partial derivative of a function with respect to a specific variable.
-
Numerical Integration
trapezoidal_integral(array, dx)
: Approximate the integral using the trapezoidal rule.simpsons_integral(array, dx)
: Approximate the integral using Simpson’s rule.cumulative_integral(array)
: Compute the cumulative integral of the array.midpoint_integral(func, a, b, n)
: Approximate the integral using the midpoint rule.monte_carlo_integral(func, bounds, samples)
: Approximate the integral using the Monte Carlo method.romberg_integral(func, a, b, tol)
: Approximate the integral using Romberg's method.gauss_quadrature(func, n, a, b)
: Approximate the integral using Gauss-Legendre quadrature.adaptive_quadrature(func, a, b, tol)
: Approximate the integral using adaptive quadrature.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file numopspy-1.0.0.tar.gz
.
File metadata
- Download URL: numopspy-1.0.0.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a664a6ab6e975ea15f452ee38e1d5db6b20393200fc06eacbefb975d941ef439 |
|
MD5 | ab20d7c278f190e321ba98d79c4042c5 |
|
BLAKE2b-256 | e09bf334e286a4331a6a6f522e47aadff5ba071fd5bf11c7d3120d599f894531 |
File details
Details for the file numopspy-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: numopspy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 21.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2617a96ef5a9f559f61a6accfc392ddc262299e8b67810bf04d5245f33638cc8 |
|
MD5 | 67f1d1ee1ee63d91b56bbdb9d04d2e0c |
|
BLAKE2b-256 | 46041026eaef552eafab7f0b00416637975c12f4178895abd71ceced0dffd210 |