1

Here is my code, and there is a "compiler" warning (is that the correct term for it?) under the instantiation of normDataSet below:

def autoNorm(dataSet):
    minVals = dataSet.min(0)
    maxVals = dataSet.max(0)
    ranges = maxVals - minVals
    normDataSet = np.zeros(np.shape(dataSet)) # Warning under "normDataSet" here.
    m = dataSet.shape[0]
    normDataSet = dataSet - np.tile(minVals, (m, 1))
    normDataSet = normDataSet / np.tile(ranges, (m, 1)) 
    return normDataSet, ranges, minVals

The full warning in PyDev reads: Unused variable: normDataSet Is there a way to eliminate this warning without having to suppress it with @UnusedVariable? Or am I missing something?

1
  • 2
    Just my two cents but I think it's actually an IDE warning as Python does not have a compiler ;) Commented Jan 26, 2014 at 21:21

1 Answer 1

3

The variable isn't unused, but the assignment you're making is pointless, since you reassign to normDataSet without ever using the value you first assigned. The line flagged can be removed entirely.

Don't suppress the warning; it's there to tell you there's a problem.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I took this code from a textbook, so I overlooked the redundant assignment. A fresh set of eyes helps because I was suspecting the IDE instead of the code! I'll let the author know to add this to their errata.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.