NdArray implementations don't throw IllegalRankException as documented if no coordinates provided
未关闭
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 928
- 派生
- 227
- PR 合并指标
- 30 天内没有已合并 PR
描述
Instead, when no coordinates are provided, we return the scalar at (0, 0, ...). Is this an important idiom that we are preserving, or a questionable choice, or simply a bug?
Here's an example of an abstract method of FloatNdArray that is documented to throw IllegalRankException:
/**
* Returns the float value of the scalar found at the given coordinates.
*
* . . .
*
* @param coordinates coordinates of the scalar to resolve
* @return value of that scalar
* @throws IndexOutOfBoundsException if some coordinates are outside the limits of their respective dimension
* @throws IllegalRankException if number of coordinates is not sufficient to access a scalar element
*/
float getFloat(long... coordinates);
Here's the implementation in FloatDenseNdArray:
@Override
public float getFloat(long... indices) {
return buffer.getFloat(positionOf(indices, true));
}
But if indices.length == 0, then positionOf does not throw the claimed IllegalRankException:
long positionOf(long[] coords, boolean isValue) {
if (coords == null || coords.length == 0) {
return 0;
}
Validator.coordinates(dimensions, coords, isValue);
return dimensions.positionOf(coords);
}
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从文档化的 FloatNdArray.getFloat 合约开始,将其与 FloatDenseNdArray.getFloat 和 positionOf 进行比较,尤其是零坐标分支。确定返回位置 0 处的标量是有意为之,还是违反了文档化的异常行为;当行为与其文档一致,并且在项目提供相关覆盖的情况下已添加或更新相关覆盖时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- machine-learning
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100