File existence validation for Nd4j.createFromNpyFile()
Signed-off-by: raver119 <raver119@gmail.com>master
parent
91a8fb0d90
commit
c9e867b2e8
|
@ -6916,6 +6916,9 @@ public class Nd4j {
|
|||
* @return the created ndarray
|
||||
*/
|
||||
public static INDArray createFromNpyFile(File file) {
|
||||
if (!file.exists())
|
||||
throw new IllegalArgumentException("File [" + file.getAbsolutePath() + "] doesn't exist");
|
||||
|
||||
return INSTANCE.createFromNpyFile(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -304,6 +304,12 @@ public class NumpyFormatTests extends BaseNd4jTest {
|
|||
boolean eq = exp.equals(probablyShouldntLoad); //And is actually equal content
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testAbsentNumpyFile_1() throws Exception {
|
||||
val f = new File("pew-pew-zomg.some_extension_that_wont_exist");
|
||||
INDArray act1 = Nd4j.createFromNpyFile(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char ordering() {
|
||||
return 'c';
|
||||
|
|
Loading…
Reference in New Issue