Package: python3-pudb
Version: 2014.1-1
Severity: normal

Dear Maintainer,

Traceback (most recent call last):
  File "01.py", line 47, in <module>
    main()
  File "01.py", line 24, in main
    dic = read('text.txt')
  File "01.py", line 21, in read
    return dic
  File "01.py", line 21, in read
    return dic
  File "/usr/lib/python3.4/bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "/usr/lib/python3.4/bdb.py", line 66, in dispatch_line
    self.user_line(frame)
  File "/usr/lib/python3/dist-packages/pudb/debugger.py", line 323, in
user_line
    self.interaction(frame)
  File "/usr/lib/python3/dist-packages/pudb/debugger.py", line 291, in
interaction
    show_exc_dialog=show_exc_dialog)
  File "/usr/lib/python3/dist-packages/pudb/debugger.py", line 1903, in
call_with_ui
    return f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pudb/debugger.py", line 2092, in
interaction
    self.event_loop()
  File "/usr/lib/python3/dist-packages/pudb/debugger.py", line 2051, in
event_loop
    self.screen.draw_screen(self.size, canvas)
  File "/usr/lib/python3/dist-packages/urwid/curses_display.py", line 539, in
draw_screen
    self.s.addstr(seg.decode('utf-8'))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 55:
unexpected end of data


file:
#!/usr/bin/env python3
#coding: utf-8

from pudb import set_trace; set_trace()

import math

def read(filename):
    with open(filename, 'r') as f:
        data = f.read()
    data = data.lower()
    ALPHA = ['
','й','ц','у','к','е','н','г','ш','щ','з','х','ъ','ф','ы','в','а','п','р','о','л','д','ж','э','я','ч','с','м','и','т','ь','б','ю','ё','.',',',':','-']
    dic = {} #словарь
    for i in data:
        if i not in ALPHA:
            continue
        if i not in dic:
            dic[i] = 1
        else:
            dic[i] += 1
    return dic

def main():
    dic = read('text.txt')
    n = 0
    for i in dic.values():
        n += i
    print('n = {}\n'.format(n))

    for i in dic.keys():
        dic[i] = dic[i]/n

    l = list(dic.items())
    l = sorted(l, key=lambda i: -i[1])

    for (i,p) in l:
        print("'{}' - {:.6f}".format(i,p))

    h = 0
    for (_,p) in l:
    #for p in dic.values():
        h += p*math.log(p,2)
    h = -h
    print('\nH(x) = {:.6f}'.format(h))

if __name__=='__main__':
    main()



-- System Information:
Debian Release: fox ^_^
  APT prefers stable
  APT policy: (501, 'stable'), (500, 'stable-updates'), (500, 
'proposed-updates'), (500, 'oldstable-updates'), (500, 'oldoldstable-updates'), 
(500, 'oldoldstable-proposed-updates'), (202, 'oldstable-proposed-updates'), 
(201, 'oldstable'), (101, 'oldoldstable')
Architecture: i386 (i686)

Kernel: Linux 3.16.0-4-686-pae (SMP w/2 CPU cores)
Locale: LANG=ru_RU.utf8, LC_CTYPE=ru_RU.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages python3-pudb depends on:
ii  dpkg              1.18.1
ii  python3-pygments  2.0.1+dfsg-1.1
ii  python3-urwid     1.2.1-2+b1
ii  python3.4         3.4.3-7
pn  python3:any       <none>

python3-pudb recommends no packages.

Versions of packages python3-pudb suggests:
pn  ipython3  <none>

-- debconf-show failed

Reply via email to