Skip to content

Commit

Permalink
Fix spotless check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jmao-denver committed Mar 15, 2024
1 parent f9c883a commit f4419e6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2786,10 +2786,10 @@ private void prepareVectorizationArgs(
}

// TODO related to core#709, but should be covered by PyCallableWrapper.verifyArguments, needs to verify
// if (!isSafelyCoerceable(argTypes[i], paramTypes.get(i))) {
// throw new PythonCallVectorizationFailure("Python vectorized function argument type mismatch: " + n + " "
// + argTypes[i].getSimpleName() + " -> " + paramTypes.get(i).getSimpleName());
// }
// if (!isSafelyCoerceable(argTypes[i], paramTypes.get(i))) {
// throw new PythonCallVectorizationFailure("Python vectorized function argument type mismatch: " + n + " "
// + argTypes[i].getSimpleName() + " -> " + paramTypes.get(i).getSimpleName());
// }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,23 +198,24 @@ public void parseSignature() {
throw new IllegalStateException("Signature should always be available.");
}

// List<Class<?>> paramTypes = new ArrayList<>();
// for (char numpyTypeChar : signatureString.toCharArray()) {
// if (numpyTypeChar != '-') {
// Class<?> paramType = numpyType2JavaClass.get(numpyTypeChar);
// if (paramType == null) {
// throw new IllegalStateException(
// "Parameters of vectorized functions should always be of integral, floating point, boolean, String, or Object type: "
// + numpyTypeChar + " of " + signatureString);
// }
// paramTypes.add(paramType);
// } else {
// break;
// }
// }
// this.paramTypes = paramTypes;
// List<Class<?>> paramTypes = new ArrayList<>();
// for (char numpyTypeChar : signatureString.toCharArray()) {
// if (numpyTypeChar != '-') {
// Class<?> paramType = numpyType2JavaClass.get(numpyTypeChar);
// if (paramType == null) {
// throw new IllegalStateException(
// "Parameters of vectorized functions should always be of integral, floating point, boolean, String, or Object
// type: "
// + numpyTypeChar + " of " + signatureString);
// }
// paramTypes.add(paramType);
// } else {
// break;
// }
// }
// this.paramTypes = paramTypes;
String pyEncodedParamsStr = signatureString.split("->")[0];
if (!pyEncodedParamsStr.isEmpty()){
if (!pyEncodedParamsStr.isEmpty()) {
String[] pyEncodedParams = pyEncodedParamsStr.split(",");
for (int i = 0; i < pyEncodedParams.length; i++) {
String[] paramDetail = pyEncodedParams[i].split(":");
Expand Down Expand Up @@ -263,13 +264,16 @@ public void verifyArguments(Class<?>[] argTypes) {
String callableName = pyCallable.getAttribute("__name__").toString();

if (argTypes.length != parameters.size()) {
throw new IllegalArgumentException(callableName + ": " + "Expected " + parameters.size() + " arguments, got " + argTypes.length);
throw new IllegalArgumentException(
callableName + ": " + "Expected " + parameters.size() + " arguments, got " + argTypes.length);
}
for (int i = 0; i < argTypes.length; i++) {
Set<Class<?>> types = parameters.get(i).getPossibleTypes();
if (!types.contains(argTypes[i]) && !types.contains(Object.class) && !isSafelyCastable(types, argTypes[i])) {
if (!types.contains(argTypes[i]) && !types.contains(Object.class)
&& !isSafelyCastable(types, argTypes[i])) {
throw new IllegalArgumentException(
callableName + ": " + "Expected argument (" + parameters.get(i).getName() + ") to be one of " + parameters.get(i).getPossibleTypes() + ", got "
callableName + ": " + "Expected argument (" + parameters.get(i).getName() + ") to be one of "
+ parameters.get(i).getPossibleTypes() + ", got "
+ argTypes[i]);
}
}
Expand Down

0 comments on commit f4419e6

Please sign in to comment.