Skip to content

Avoid dependency on specific version of ndarray #60

@wangjia184

Description

@wangjia184

First of all, thank you for your great work on powerboxesrs — it’s very useful!

I wanted to share a suggestion regarding the function APIs. Currently, many function parameters depend directly on the ndarray crate types. This tight coupling means that users must depend on the exact same ndarray version to avoid compilation conflicts, which can be quite limiting in real projects with multiple dependencies.

Take this method as an example, https://docs.rs/powerboxesrs/latest/powerboxesrs/nms/fn.nms.html

pub fn nms<'a, N, BA, SA>(
    boxes: BA,
    scores: SA,
    iou_threshold: f64,
    score_threshold: f64,
) -> Vec<usize>
where
    N: Num + PartialEq + PartialOrd + ToPrimitive + Copy + PartialEq + 'a,
    BA: Into<ArrayView2<'a, N>>,
    SA: Into<ArrayView1<'a, f64>>,

BA: Into<ArrayView2<'a, N>> means I have to use the exact version of ndarray.

Would it be possible to provide alternative overloads or versions of these functions that accept raw slices like &[f32] (using unsafe if needed)? This could help significantly reduce version conflicts and make the library easier to integrate. Alternatively, any other approaches you might recommend to decouple the API from a specific ndarray version would also be appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions