This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import clyther | |
import copencl as cl | |
@clyther.kernel | |
def broken(a): | |
b = a << 2 | |
c = a >> 2 | |
if __name__ == '__main__': | |
clyther.init('GPU') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/clyther/api/ast/astgen.py | |
=================================================================== | |
--- lib/clyther/api/ast/astgen.py (revision 68) | |
+++ lib/clyther/api/ast/astgen.py (working copy) | |
@@ -584,6 +584,14 @@ | |
return ast.Bitor( cl_nodes, node.lineno ), nd_type | |
+ def visitBitxor(self,node): | |
+ nd, nd_type = self.dispatch(node.nodes[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// === === === === === === === | |
//CLyther Module | |
struct _array_desc_ { | |
size_t start[3]; | |
size_t stop[3]; | |
size_t step[3]; | |
size_t shape[3]; | |
size_t size; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: lib/clyther/tests/test_integer_ops.py | |
=================================================================== | |
--- lib/clyther/tests/test_integer_ops.py (revision 71) | |
+++ lib/clyther/tests/test_integer_ops.py (working copy) | |
@@ -178,6 +178,22 @@ | |
_test_unary_minus.func(a, output) | |
self.failUnlessEqual(clout.item(), output[0]) | |
+ | |
+ def test_mod(self): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace all of the lxml cssselect calls in a python script with | |
# equivalent xpath calls. | |
import re | |
import sys | |
import lxml.cssselect | |
def cssselect_replace(match): | |
xpath = lxml.cssselect.css_to_xpath(match.group(2)) | |
xpath = xpath.replace("'", "\\'").replace('"', '\\"') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train <- read.csv("~/code/informs/TrainingData.csv", row.names=1, header=TRUE) | |
test <- read.csv("~/code/informs/ResultData.csv", row.names=1, header=TRUE) | |
for (col in c("Variable142OPEN", "Variable142LOW", "Variable142HIGH", | |
"Variable142LAST", "Variable158OPEN", "Variable158LOW", | |
"Variable158HIGH", "Variable158LAST")) { | |
train[col] <- NULL | |
test[col] <- NULL | |
} | |
train[is.na(train)] <- 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unicodedata | |
from pymongo.son import SON | |
from pymongo.son_manipulator import SONManipulator | |
class NormalizeUnicode(SONManipulator): | |
def __init__(self, form="NFKD"): | |
self.__form = form |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Levenshtein Distance: | |
# NLTK: 446.74 usec/call | |
# strfry: 1.86 usec/call | |
import timeit | |
nltk_lev = timeit.Timer(stmt="nltk.metrics.edit_distance('this is a string', 'this is another string')", | |
setup="import nltk.metrics") | |
str_lev = timeit.Timer(stmt="strfry.levenshtein_distance('this is a string', 'this is another string')", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check that nltk and strfry produce same levenshtein distance on | |
# a bunch of randomly generated strings | |
import strfry | |
import nltk.metrics | |
import random | |
for i in xrange(0, 10000): | |
a = ''.join([chr(random.randint(1, 255)) for x in xrange(0, random.randint(0, 20))]) | |
b = ''.join([chr(random.randint(1, 255)) for x in xrange(0, random.randint(0, 20))]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ddg -h | |
Usage: ddg [options] query | |
Options: | |
--version show program's version number and exit | |
-h, --help show this help message and exit | |
-o, --open open results in a browser | |
-n N number of results to show | |
-d D disambiguation choice |