imagej / imagej/imagej-ops

Wrongly typed signature of ops.stats().mean(Img<Float>)

Open
#506 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
94
Forks
44
PR merge metrics
No merged PRs in 30d

Description

The following piece of code produces a ClassCastException on runtime:
```
Img img = ArrayImgs.floats(1, 1);
FloatType mean = ops.stats().mean(img);
```
The method `ops.stats().mean(Img)` always returns an instance of DoubleType on runtime.
But the methods signature is wrongly typed, thats why the compiler accepts FloatType as return type.

The signature of this method should be fixed, such that an error is raised during compilation.

See: https://github.com/maarzt/imagej-ops/commit/a0b08e4f70adea88fe6d267c94f89f33bca7b629

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the ops.stats().mean(Img) entry point and compare its declared return type with the runtime DoubleType shown in the example. Use the provided FloatType assignment as the reproduction, then confirm that an incompatible return type is rejected at compilation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
computer-vision
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.