def setConfig(self, config):
        try:
            self.state = CubeState('barebones')

            if self.debug:
                print self.state

            # Modify the state to include [(color, direction), (color, direction), ...]
            # And then parse pieceId and orientationKey out of that

            def faceToAxis(face):
                if self.debug:
                    print face
                center = face[1][1]
                axis = [vec for vec in Cube.directions if 
                        Cube.directions[vec].lower() == center.lower()][0]
                return axis

            def setAxes(normal, known, dirString):
                dirString = dirString.lower()
                if dirString == 'up':
                    up = known
                elif dirString == 'down':
                    up = known * -1
                elif dirString == 'left':
                    up = (normal * known)
                elif dirString == 'right':
                    up = (known * normal)

                down = up * -1
                left = (up * normal)
                right = left * -1

                return (up, down, left, right)

            timesTouched = [[[0,0,0],[0,0,0],[0,0,0]],[[0,0,0],[0,0,0],[0,0,0]],[[0,0,0],[0,0,0],[0,0,0]]]

            for faceInfo in config:
                axis = faceToAxis(faceInfo.currentFace)
                prevAxis = nextAxis = None
                if faceInfo.prevFace:
                    prevAxis = faceToAxis(faceInfo.prevFace)
                if faceInfo.nextFace:
                    nextAxis = faceToAxis(faceInfo.nextFace)
                prevTurn = faceInfo.prevTurn
                nextTurn = faceInfo.nextTurn

                if self.debug:
                    print 'axis:', axis, Cube.directions[axis]
                    print 'prevAxis:', prevAxis,
                    if prevAxis:
                        print Cube.directions[prevAxis]
                    print 'nextAxis:', nextAxis, 
                    if nextAxis:
                        print Cube.directions[nextAxis]
                    print 'prevTurn:', prevTurn 
                    print 'nextTurn:', nextTurn

                if prevTurn:
                    (up, down, left, right) = setAxes(axis, prevAxis, prevTurn)
                elif nextTurn:
                    (up, down, left, right) = setAxes(axis, nextAxis * -1, nextTurn)

                if self.debug:
                    print 'up:', up, Cube.directions[up]
                    print 'down:', down, Cube.directions[down]
                    print 'left:', left, Cube.directions[left]
                    print 'right:', right, Cube.directions[right]

                for row in xrange(3):
                    for col in xrange(3):
                        pos = axis
                        pos = pos + (down * (row - 1))
                        pos = pos + (right * (col - 1))

                        (x, y, z) = pos.components
                        (x, y, z) = (int(x+1), int(y+1), int(z+1))
                        if self.debug:
                            print 'x,y,z', x, y, z,
                            print 'pos=', pos

                        timesTouched[z][y][x] += 1

                        cell = self.state.state[z][y][x]
                        if type(cell) == list:
                            cell.append((faceInfo.currentFace[row][col], axis))

            if self.debug:
                print 'state=', self.state
                print 'times', timesTouched

            # Cast each [ ] list to a ( ) tuple
            # [(color,dir),(color,dir),(color,dir)] ----> (pieceId, orientationKey)

            reverseZ = -1 if self.camera.view ** Vector(0,0,1) < 0 else 1
            reverseY = -1 if self.camera.view ** Vector(0,1,0) < 0 else 1
            reverseX = -1 if 0 < self.camera.view ** Vector(1,0,0) else 1

            zRange = range(3)[::reverseZ]
            yRange = range(3)[::reverseY]
            xRange = range(3)[::reverseX]


            for z in zRange:
                for y in yRange:
                    for x in xRange:
                        
                        cell = self.state.state[z][y][x]
                        if type(cell) == list:
                            pieceId = -1
                            colors = set()
                            for i in cell:
                                colors.add(i[0])
                            for key in Cube.faceColors:
                                if set(Cube.faceColors[key]) == colors:
                                    pieceId = key
                                    break
                            if pieceId >= 0:
                                desiredColorOrder = Cube.faceColors[pieceId]
                                currentOrder = [ ]
                                ori = 0
                                notAdded = set([0,1,2])

                                cell.sort(lambda a,b: cmp(desiredColorOrder.index(a[0]),
                                                          desiredColorOrder.index(b[0])))

                                for i in cell:
                                    ori *= 10
                                    if i[1] // Vector(0,0,1):
                                        ori += 2
                                        notAdded.discard(2)
                                    elif i[1] // Vector(0,1,0):
                                        ori += 1
                                        notAdded.discard(1)
                                    elif i[1] // Vector(1,0,0):
                                        ori += 0
                                        notAdded.discard(0)

                                while len(notAdded) > 0:
                                    ori *= 10
                                    ori += notAdded.pop()

                                orientationKey = ori

                            else:
                                raise ValueError('Invalid Cube')

                            if pieceId in (5, 11, 13, 14, 15, 17, 23):
                                raise ValueError('Invalid Cube') # Center piece

                            desired = Cube.faceColors[CubeState.solvedState[z][y][x][0]]

                            if self.debug:
                                print 'The piece with colors %s is at the position of %s' % (colors, desired)
                                print 'setting (%d,%d,%d) to (%s, %s)' % (z,y,x,pieceId,orientationKey)

                            self.state.state[z][y][x] = (pieceId, orientationKey)
        except:
            self.updateMessage('Unable to read camera input.')
            self.state.setSolved()
            self.redraw()
        if self.debug:
            print 'final state=', self.state
                
        self.redraw()
dataset/ETHPy150Open bluquar/cubr/cube.py/Cube.setConfig/swapped operands of `<`