Clip

Open
#470 7 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
numpy, rust
Domain
data

Research direction

Start by reviewing ndarray's existing mapv operation and the proposed clip, clip_min, and clip_max entry points in the issue. Check whether ndarray already has related minimum or maximum APIs. Done would require a decided clipping API and corresponding implementation, but the issue does not record a design decision or name tests or files.

Written by the indexing model from the issue text.

Description

I can't find a numpy::clip function in ndarray. Is there one?

If not, I know I can use something like

arr.mapv(|v| if v < 4.0 { 0.0 } else { v } );

but do you think it would be better to have a clip function?

// min and max in the same function
arr.clip(Some(0.0), None);

// or 3 functions
arr.clip_min(0.0);
arr.clip_max(1.0);
arr.clip(0.0, 1.0);

I can code it, I just wonder if we want it.

Dominant language
Rust
Stars
4.3k
Forks
391
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-ndarray/ndarray

All issues in rust-ndarray/ndarray

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.