[ python-Bugs-1621367 ] random import works?
Bugs item #1621367, was opened at 2006-12-23 11:04 Message generated for change (Comment added) made by mark-roberts You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Extension Modules Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Msword (msword) Assigned to: Nobody/Anonymous (nobody) Summary: random import works? Initial Comment: I'm just starting working with python, and it seems that random.choice() isn't all that random. After running the program(attached) a few times, each and every time it selects 1 < 2 < 3 < 4 < 5 and I can expect this to happen, meaning it isn't all that random. Email: [EMAIL PROTECTED] Thanks -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 02:51 Message: Logged In: YES user_id=1591633 Originator: NO This is an issue with the way you have written your initial application. See the attachment that I've supplied to explain what is going wrong in your program. It really boils down to you adding X to each value, while X is steadily increasing in value (1, 2, 3, 4, 5). At one point, you actually add 1 to one value, and add 5 to another (for the same random choice). - Mark -- Comment By: Dennis Allison (dallison) Date: 2006-12-23 12:32 Message: Logged In: YES user_id=31903 Originator: NO I believe the problem is with your test framework and not with random.choice(). The library function random.choice( seq ) selects, using a uniform distribution, one item from the sequence at each call. By the law of large numbers, if you have K items in the sequence, each should be returned K/N times, on average, after N calls. You should expect deviations even for fairly large N. If you want to test the randomess, use a chi-square test to test against the hypothes of uniform random selection with replacement. Of course there are many other statistical properties which ought to be checked, for example, the distribution of runs. Consider the program: import random dist = [0,0,0,0,0] for i in range(10): j = random.choice([0,1,2,3,4]) dist[j] += 1 print dist which prints the distribution observed for each choice. With 10 tries you'd expect each one to appear (on average) 2 time. Running it on my a three times gives: [19839, 19871, 19996, 20035, 20259] [20043, 19870, 20025, 20109, 19953] [19947, 20033, 19970, 20111, 19939] -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1621367 ] random import works?
Bugs item #1621367, was opened at 2006-12-23 11:04 Message generated for change (Comment added) made by mark-roberts You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Extension Modules Group: Python 2.5 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Msword (msword) Assigned to: Nobody/Anonymous (nobody) Summary: random import works? Initial Comment: I'm just starting working with python, and it seems that random.choice() isn't all that random. After running the program(attached) a few times, each and every time it selects 1 < 2 < 3 < 4 < 5 and I can expect this to happen, meaning it isn't all that random. Email: [EMAIL PROTECTED] Thanks -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 02:54 Message: Logged In: YES user_id=1591633 Originator: NO Sorry, it appears that I can't upload a file, or I'm missing the button. Anyway, you can find the file you're lookign for here: http://www.pandapocket.com/python/rand2.pys -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 02:51 Message: Logged In: YES user_id=1591633 Originator: NO This is an issue with the way you have written your initial application. See the attachment that I've supplied to explain what is going wrong in your program. It really boils down to you adding X to each value, while X is steadily increasing in value (1, 2, 3, 4, 5). At one point, you actually add 1 to one value, and add 5 to another (for the same random choice). - Mark -- Comment By: Dennis Allison (dallison) Date: 2006-12-23 12:32 Message: Logged In: YES user_id=31903 Originator: NO I believe the problem is with your test framework and not with random.choice(). The library function random.choice( seq ) selects, using a uniform distribution, one item from the sequence at each call. By the law of large numbers, if you have K items in the sequence, each should be returned K/N times, on average, after N calls. You should expect deviations even for fairly large N. If you want to test the randomess, use a chi-square test to test against the hypothes of uniform random selection with replacement. Of course there are many other statistical properties which ought to be checked, for example, the distribution of runs. Consider the program: import random dist = [0,0,0,0,0] for i in range(10): j = random.choice([0,1,2,3,4]) dist[j] += 1 print dist which prints the distribution observed for each choice. With 10 tries you'd expect each one to appear (on average) 2 time. Running it on my a three times gives: [19839, 19871, 19996, 20035, 20259] [20043, 19870, 20025, 20109, 19953] [19947, 20033, 19970, 20111, 19939] -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1619659 ] htonl, ntohl don't handle negative longs
Bugs item #1619659, was opened at 2006-12-20 12:42 Message generated for change (Comment added) made by mark-roberts You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619659&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Adam Olsen (rhamphoryncus) Assigned to: Nobody/Anonymous (nobody) Summary: htonl, ntohl don't handle negative longs Initial Comment: >>> htonl(-5) -67108865 >>> htonl(-5L) Traceback (most recent call last): File "", line 1, in ? OverflowError: can't convert negative value to unsigned long It works fine in 2.1 and 2.2, but fails in 2.3, 2.4, 2.5. htons, ntohs do not appear to have the bug, but I'm not 100% sure. -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 03:24 Message: Logged In: YES user_id=1591633 Originator: NO >From man page for htonl and friends: #include uint32_t htonl(uint32_t hostlong); uint16_t htons(uint16_t hostshort); uint32_t ntohl(uint32_t netlong); uint16_t ntohs(uint16_t netshort); Python does call these underlying functions in Modules/socketmodule.c. The problem comes from that PyLong_AsUnsignedLong() called in socket_htonl() specifically checks to see that the value cannot be less than 0. The error checking was rather exquisite, I might add. - Mark -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1619659&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1622533 ] null bytes in docstrings
Bugs item #1622533, was opened at 2006-12-26 18:47 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622533&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Fredrik Lundh (effbot) Assigned to: Nobody/Anonymous (nobody) Summary: null bytes in docstrings Initial Comment: the following docstrings contain bogus control characters: module difflib, function _mdiff, contains four invalid bytes: ['\x00', '\x00', '\x00', '\x01'] module StringIO, method readline, contains a null byte: ['\x00'] since this breaks help() and probably a bunch of other documentation tools, it would probably be a good idea to add the missing backslashes... -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622533&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1622533 ] null bytes in docstrings
Bugs item #1622533, was opened at 2006-12-26 12:47 Message generated for change (Comment added) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622533&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Fredrik Lundh (effbot) Assigned to: Nobody/Anonymous (nobody) Summary: null bytes in docstrings Initial Comment: the following docstrings contain bogus control characters: module difflib, function _mdiff, contains four invalid bytes: ['\x00', '\x00', '\x00', '\x01'] module StringIO, method readline, contains a null byte: ['\x00'] since this breaks help() and probably a bunch of other documentation tools, it would probably be a good idea to add the missing backslashes... -- >Comment By: Raymond Hettinger (rhettinger) Date: 2006-12-26 13:27 Message: Logged In: YES user_id=80475 Originator: NO Clearer and simpler to make the whole docstring raw. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622533&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1621367 ] random import works?
Bugs item #1621367, was opened at 2006-12-23 12:04 Message generated for change (Settings changed) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Extension Modules Group: Python 2.5 >Status: Closed >Resolution: Invalid Priority: 5 Private: No Submitted By: Msword (msword) Assigned to: Nobody/Anonymous (nobody) Summary: random import works? Initial Comment: I'm just starting working with python, and it seems that random.choice() isn't all that random. After running the program(attached) a few times, each and every time it selects 1 < 2 < 3 < 4 < 5 and I can expect this to happen, meaning it isn't all that random. Email: [EMAIL PROTECTED] Thanks -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 03:54 Message: Logged In: YES user_id=1591633 Originator: NO Sorry, it appears that I can't upload a file, or I'm missing the button. Anyway, you can find the file you're lookign for here: http://www.pandapocket.com/python/rand2.pys -- Comment By: Mark Roberts (mark-roberts) Date: 2006-12-26 03:51 Message: Logged In: YES user_id=1591633 Originator: NO This is an issue with the way you have written your initial application. See the attachment that I've supplied to explain what is going wrong in your program. It really boils down to you adding X to each value, while X is steadily increasing in value (1, 2, 3, 4, 5). At one point, you actually add 1 to one value, and add 5 to another (for the same random choice). - Mark -- Comment By: Dennis Allison (dallison) Date: 2006-12-23 13:32 Message: Logged In: YES user_id=31903 Originator: NO I believe the problem is with your test framework and not with random.choice(). The library function random.choice( seq ) selects, using a uniform distribution, one item from the sequence at each call. By the law of large numbers, if you have K items in the sequence, each should be returned K/N times, on average, after N calls. You should expect deviations even for fairly large N. If you want to test the randomess, use a chi-square test to test against the hypothes of uniform random selection with replacement. Of course there are many other statistical properties which ought to be checked, for example, the distribution of runs. Consider the program: import random dist = [0,0,0,0,0] for i in range(10): j = random.choice([0,1,2,3,4]) dist[j] += 1 print dist which prints the distribution observed for each choice. With 10 tries you'd expect each one to appear (on average) 2 time. Running it on my a three times gives: [19839, 19871, 19996, 20035, 20259] [20043, 19870, 20025, 20109, 19953] [19947, 20033, 19970, 20111, 19939] -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1621367&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1545837 ] array.array borks on deepcopy
Bugs item #1545837, was opened at 2006-08-24 04:49 Message generated for change (Settings changed) made by rhettinger You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1545837&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.5 Status: Open Resolution: Later Priority: 7 Private: No Submitted By: Václav Haisman (wilx) >Assigned to: Neal Norwitz (nnorwitz) Summary: array.array borks on deepcopy Initial Comment: Hi, I think there is a bug arraymodule.c this line: {"__deepcopy__",(PyCFunction)array_copy,METH_NOARGS, copy_doc}, should probably have METH_O instead of METH_NOARGS there, since according to docs and the prototype of the array_copy() function there is one parameter. -- Comment By: Thomas Wouters (twouters) Date: 2006-08-29 02:35 Message: Logged In: YES user_id=34209 Not unless you want another release candidate. copy.deepcopy has never worked on array instances, so it's not a release-preventing bug (but each bugfix may *add* a release-preventing bug by accident :) -- Comment By: Raymond Hettinger (rhettinger) Date: 2006-08-28 08:32 Message: Logged In: YES user_id=80475 Should this be fixed in the release candidate? -- Comment By: Thomas Wouters (twouters) Date: 2006-08-24 13:50 Message: Logged In: YES user_id=34209 Thanks! Fixed in the trunk (which is 2.6-to-be) revision 51565, and it will also be fixed for Python 2.4.4 and 2.5.1. It's unfortunately just a bit too late for 2.5.0. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1545837&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1622664 ] language reference index links are broken
Bugs item #1622664, was opened at 2006-12-26 16:15 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622664&group_id=5470 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Documentation Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Drew Perttula (drewp) Assigned to: Nobody/Anonymous (nobody) Summary: language reference index links are broken Initial Comment: http://docs.python.org/ref/genindex.html For example, this text "globals() (built-in function)" links to http://docs.python.org/ref/exec.html#l2h-571, which is completely wrong. Some links are correct, but many others are broken. The page footer says "Release 2.5, documentation updated on 19th September, 2006." -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1622664&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com