Skip to content

Commit

Permalink
Upgrade gradle to 6.7.1
Browse files Browse the repository at this point in the history
Change-Id: I3ee48ec254bba343a2dc42226d39b7cf22c48fc0
  • Loading branch information
frankfliu committed Nov 21, 2020
1 parent cafc92f commit f6aca20
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/src/main/java/ai/djl/modality/cv/ImageFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public abstract class ImageFactory {

private static ImageFactory newInstance() {
String className = "ai.djl.modality.cv.BufferedImageFactory";
if (System.getProperty("java.vendor.url").equals("http://www.android.com/")) {
if ("http://www.android.com/".equals(System.getProperty("java.vendor.url"))) {
className = "ai.djl.android.core.BitmapImageFactory";
}
try {
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/ai/djl/ndarray/index/NDIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public final NDIndex addIndices(String indices, Object... args) {
rank += indexItems.length;
int argIndex = 0;
for (int i = 0; i < indexItems.length; ++i) {
if (indexItems[i].trim().equals("...")) {
if ("...".equals(indexItems[i].trim())) {
// make sure ellipsis appear only once
if (ellipsisIndex != -1) {
throw new IllegalArgumentException(
Expand Down
2 changes: 1 addition & 1 deletion api/src/main/java/ai/djl/training/optimizer/Optimizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ protected NDArray withDefaultState(
return map;
});
return arrayMap.computeIfAbsent(
device, k -> ((NDArray) arrayMap.values().toArray()[0]).toDevice(device, true));
device, k -> arrayMap.values().iterator().next().toDevice(device, true));
}

/** The Builder to construct an {@link Optimizer}. */
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testToTensor() {
}
}

@Test(expectedExceptions = IllegalArgumentException.class)
@Test
public void testResize() {
try (NDManager manager = NDManager.newBaseManager()) {
Image.Interpolation[] interpolations = {
Expand Down Expand Up @@ -127,13 +127,20 @@ public void testResize() {
expected = manager.ones(new Shape(5, 50, 25, 3));
Assertions.assertAlmostEquals(result, expected);

// test zero-dim
image = manager.create(new Shape(0, 2, 3));
// throw IllegalArgumentException
result = NDImageUtils.resize(image, 20);
batchImages = manager.create(new Shape(5, 0, 1, 3));
// throw IllegalArgumentException
result = NDImageUtils.resize(batchImages, 20);
Assert.expectThrows(
IllegalArgumentException.class,
() -> {
// test zero-dim
NDArray img = manager.create(new Shape(0, 2, 3));
NDImageUtils.resize(img, 20);
});

Assert.expectThrows(
IllegalArgumentException.class,
() -> {
NDArray img = manager.create(new Shape(5, 0, 1, 3));
NDImageUtils.resize(img, 20);
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private LibUtils() {}
public static void loadLibrary() {
// TODO workaround to make it work on Android Studio
// It should search for several places to find the native library
if (System.getProperty("java.vendor.url").equals("http://www.android.com/")) {
if ("http://www.android.com/".equals(System.getProperty("java.vendor.url"))) {
System.loadLibrary(LIB_NAME); // NOPMD
return;
}
Expand Down
8 changes: 4 additions & 4 deletions testing/src/main/java/ai/djl/testing/CoverageUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static void testGetterSetters(Class<?> baseClass)

private static List<Class<?>> getClasses(Class<?> clazz)
throws IOException, ReflectiveOperationException, URISyntaxException {
ClassLoader appClassLoader = clazz.getClassLoader();
ClassLoader appClassLoader = Thread.currentThread().getContextClassLoader();
Field field = appClassLoader.getClass().getDeclaredField("ucp");
field.setAccessible(true);
Object ucp = field.get(appClassLoader);
Expand Down Expand Up @@ -227,10 +227,10 @@ private static Object getMockInstance(Class<?> clazz, boolean useConstructor) {
return null;
}

@SuppressWarnings("rawtypes")
@SuppressWarnings({"rawtypes", "PMD.UseProperClassLoader"})
private static Object newProxyInstance(Class<?> clazz) {
return Proxy.newProxyInstance(
clazz.getClassLoader(), new Class[] {clazz}, (proxy, method, args) -> null);
ClassLoader cl = clazz.getClassLoader();
return Proxy.newProxyInstance(cl, new Class[] {clazz}, (proxy, method, args) -> null);
}

private static final class TestClassLoader extends URLClassLoader {
Expand Down

0 comments on commit f6aca20

Please sign in to comment.