def getPoint(self, x): e = utils.entropy(self.data, 32, x, len(self.symbol_map)) # http://www.wolframalpha.com/input/?i=plot+%284%28x-0.5%29-4%28x-0.5%29**2%29**4+from+0.5+to+1 def curve(v): f = (4 * v - 4 * v**2)**4 f = max(f, 0) return f r = curve(e - 0.5) if e > 0.5 else 0 b = e**2 red = int(255 * r) blue = int(255 * b) c = ord(self.data[x]) if c == 0: return [red, 0, blue] elif c == 255: return [red, 255, blue] elif chr(c) in string.ascii_lowercase: return [red, 126, blue] elif chr(c) in string.ascii_uppercase: return [red, 63, blue] elif chr(c) in string.digits: return [red, 32, blue] elif chr(c) in string.punctuation: return [red, 16, blue] return [red, 8, blue]
def getPoint(self, x): e = utils.entropy(self.data, 32, x, len(self.symbol_map)) # http://www.wolframalpha.com/input/?i=plot+%284%28x-0.5%29-4%28x-0.5%29**2%29**4+from+0.5+to+1 def curve(v): f = (4 * v - 4 * v**2)**4 f = max(f, 0) return f r = curve(e - 0.5) if e > 0.5 else 0 b = e**2 red = int(255 * r) blue = int(255 * b) c = ord(self.data[x]) if c == 0: return [red, 0, blue] elif c == 255: return [red, 255, blue] elif c in range(0, 16): return [red, 1, blue] elif c in range(16, 32): return [red, 17, blue] elif c in range(32, 48): return [red, 33, blue] elif c in range(48, 64): return [red, 49, blue] elif c in range(64, 80): return [red, 65, blue] elif c in range(80, 96): return [red, 81, blue] elif c in range(96, 112): return [red, 97, blue] elif c in range(112, 128): return [red, 113, blue] elif c in range(128, 144): return [red, 129, blue] elif c in range(144, 160): return [red, 145, blue] elif c in range(160, 176): return [red, 161, blue] elif c in range(176, 192): return [red, 177, blue] elif c in range(192, 208): return [red, 193, blue] elif c in range(208, 224): return [red, 209, blue] elif c in range(224, 240): return [red, 225, blue] else: return [red, 26, blue]
def getPoint(self, x): e = utils.entropy(self.data, 32, x, len(self.symbol_map)) # http://www.wolframalpha.com/input/?i=plot+%284%28x-0.5%29-4%28x-0.5%29**2%29**4+from+0.5+to+1 def curve(v): f = (4 * v - 4 * v**2)**4 f = max(f, 0) return f r = curve(e - 0.5) if e > 0.5 else 0 b = e**2 return [int(255 * r), 0, int(255 * b)]
def test_entropy(self): tutils.raises(ValueError, utils.entropy, "foo", 64, 0) assert utils.entropy("a"*64, 64, 1) == 0 d = "".join([chr(i) for i in range(256)]) assert utils.entropy(d, 64, 1) == 1