TensorFlow.NET icon indicating copy to clipboard operation
TensorFlow.NET copied to clipboard

arguments to Array.Exists() hiding variables needed for correct function

Open gsw88 opened this issue 5 years ago • 0 comments

source file image_ops_impl.cs https://github.com/SciSharp/TensorFlow.NET/blob/a994a86794c6d26c4d33eb0529253c0f09433296/src/TensorFlowNET.Core/Operations/image_ops_impl.cs#L793

1st occurrence of error https://github.com/SciSharp/TensorFlow.NET/blob/a994a86794c6d26c4d33eb0529253c0f09433296/src/TensorFlowNET.Core/Operations/image_ops_impl.cs#L841

after pulling the latest repo i noticed VS giving several warnings: "comparison made to same variable, did you mean to compare something else?" with regard to the following code: else if (Array.Exists(scale_and_translate_methods, method => method == method))

it appears that the lambda function input parameter, "method", is hiding the argument to the original function with the same name and therefore the lamba function argument supplied to the Array.Exists() method is returning true at all times.

I haven't tested if this error is really happening, just going off of the compiler warning

The code appears to be attempting to test if the string is contained in the array defined prior, and analysis of the code seems to indicate it can't do that correctly as it is currently written. changing the name of the lamda function input parameter to something different is advised.

This issue appears in several places, i believe i found at least 9 occurrences across different files. There are 7 occurrences in image_ops_impl.cs. One other occurrence is in the unimplemented function "tensordot" where it looks like it could really be causing issues by returning true at all times instead of only when the "axes" int [] contains the number i. perhaps this error is contributing some difficulty in developing that function?

btw Thanks for developing this package cheers

gsw88 avatar Jun 11 '21 10:06 gsw88