Skip to content

feat: add scalar support to minimum() and maximum() - #32

Merged
CodeWithKyrian merged 1 commit into
mainfrom
feat/minimum-maximum-scalar-support
Jun 15, 2026
Merged

CodeWithKyrian merged 1 commit into
mainfrom
feat/minimum-maximum-scalar-support

Conversation

@CodeWithKyrian

Copy link
Copy Markdown
Contributor

This PR adds scalar argument support to minimum() and maximum(), matching the API of add(), multiply(), and other element-wise operations.

Motivation and Context

minimum() and maximum() only accepted NDArray arguments, forcing callers to use awkward workarounds like $arr->clamp($value, INF) just to get a per-element floor. Every other element-wise operation (add, subtract, multiply, divide) already supported scalar arguments so this was an inconsistent gap.

What's Changed

  • minimum() and maximum() now accept Complex|float|int|NDArray — when a scalar is passed, each array element is compared against that value
  • Two new Rust FFI functions (ndarray_minimum_scalar, ndarray_maximum_scalar) handle all numeric dtypes via element-wise mapping
  • Added 5 test cases covering scalar float, scalar int, negative values, 2D arrays, and dtype preservation
  • Updated API documentation with scalar examples

Breaking Changes

None. The NDArray path is unchanged. The new scalar path returns the same dtype as the input array.

@CodeWithKyrian
CodeWithKyrian merged commit 7a0eb63 into main Jun 15, 2026
14 checks passed
@CodeWithKyrian
CodeWithKyrian deleted the feat/minimum-maximum-scalar-support branch June 15, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant