# HG changeset patch # User Teemu Piippo # Date 1449885850 -7200 # Node ID d24fe5e3e4204a4d20b4fa9624245ccc2b30e0e7 # Parent 6e7cb38f248d68fc770ba5ca56c74b34a19e848d Added cdf (aka Φ(x)) to the calculator, removed unneeded list comprehensions diff -r 6e7cb38f248d -r d24fe5e3e420 calculator.py --- a/calculator.py Mon Oct 05 23:35:44 2015 +0300 +++ b/calculator.py Sat Dec 12 04:04:10 2015 +0200 @@ -253,6 +253,7 @@ 'sdword': { 'function': intf (lambda x: integerclamp (x, bits=32, signed=True)) }, 'qword': { 'function': intf (lambda x: integerclamp (x, bits=64, signed=False)) }, 'sqword': { 'function': intf (lambda x: integerclamp (x, bits=64, signed=True)) }, + 'cdf': { 'function': realf (lambda x: (1 + math.erf (x / math.sqrt(2))) / 2) }, } Tokens = {'(', ')'} @@ -270,6 +271,7 @@ 'ε': 'epsilon', '∨': '||', '∧': '&&', + 'Φ': 'cdf', } for name, value in Constants.items(): @@ -308,7 +310,7 @@ Attributes['bin'] = Attributes['binary'] Attributes['dec'] = Attributes['decimal'] -AttributeNames = sorted ([key for key in Attributes], key=lambda x:len(x), reverse=True) +AttributeNames = sorted ((key for key in Attributes), key=lambda x:len(x), reverse=True) def is_int (x): return math.fabs (x - math.floor(x)) < ε @@ -424,8 +426,12 @@ def parse_symbol (self, expr): for sym in Symbols: - if expr[:len (sym)].lower() == sym.lower(): - return sym.lower() + if len(sym) == 1 and ord(sym) > 256: + if expr[0] == sym: + return sym + else: + if expr[:len (sym)].lower() == sym.lower(): + return sym.lower() return None diff -r 6e7cb38f248d -r d24fe5e3e420 hgpoll.py --- a/hgpoll.py Mon Oct 05 23:35:44 2015 +0300 +++ b/hgpoll.py Sat Dec 12 04:04:10 2015 +0200 @@ -77,7 +77,7 @@ comms=['log', 'incoming', 'pull', 'commit', 'push', 'outgoing', 'strip', 'transplant'] try: with open (os.path.join (repo.name, '.hg', 'hgrc'), 'a') as fp: - fp.write ('\n[alias]\n' + ''.join(['%s=%s\n' % (x, x) for x in comms])) + fp.write ('\n[alias]\n' + ''.join('%s=%s\n' % (x, x) for x in comms)) except Exception as e: print ('Warning: unable to alter hgrc of %s: %s' % repo.name, e) print ('Cloning done.') diff -r 6e7cb38f248d -r d24fe5e3e420 hgrepo.py --- a/hgrepo.py Mon Oct 05 23:35:44 2015 +0300 +++ b/hgrepo.py Sat Dec 12 04:04:10 2015 +0200 @@ -57,7 +57,7 @@ return os.path.isdir (os.path.join (self.name, '.hg')) def split_template (self, kvargs, separator): - return separator.join (['{%s}' % x[1] for x in kvargs.items()]) + return separator.join ('{%s}' % x[1] for x in kvargs.items()) def merge_template (self, data, args): result = {} diff -r 6e7cb38f248d -r d24fe5e3e420 mod_util.py --- a/mod_util.py Mon Oct 05 23:35:44 2015 +0300 +++ b/mod_util.py Sat Dec 12 04:04:10 2015 +0200 @@ -124,8 +124,8 @@ @modulecore.irc_command() def calcfunctions (bot, reply, **rest): '''Lists the functions supported by .calc.''' - reply ('Available functions for .calc: %s' % \ - ', '.join (sorted ([name for name, data in calc.Functions.items()]))) + names = ', '.join (sorted (name for name, data in calculator.Functions.items())) + reply ('Available functions for .calc:', names) @modulecore.irc_command (args='') def calc (bot, reply, args, **rest): diff -r 6e7cb38f248d -r d24fe5e3e420 munge.py --- a/munge.py Mon Oct 05 23:35:44 2015 +0300 +++ b/munge.py Sat Dec 12 04:04:10 2015 +0200 @@ -21,4 +21,4 @@ ''' Munges the given string ''' - return ''.join ([mungeone (ch) for ch in a]) + return ''.join (mungeone(ch) for ch in a)