NdArray implementations don't throw IllegalRankException as documented if no coordinates provided
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Java
- Sterne
- 928
- Forks
- 227
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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);
}
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit dem dokumentierten FloatNdArray.getFloat-Vertrag und vergleichen Sie ihn mit FloatDenseNdArray.getFloat und positionOf, insbesondere mit dem Zweig für Nullkoordinaten. Ermitteln Sie, ob die Rückgabe des Skalars an Position 0 beabsichtigt ist oder gegen das dokumentierte Ausnahmeverhalten verstößt; abgeschlossen ist die Arbeit, wenn Verhalten und Dokumentation übereinstimmen und relevante Tests hinzugefügt oder aktualisiert wurden, sofern das Projekt entsprechende Tests bereitstellt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- machine-learning
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 35/100