Skip to content

Commit 419bc6e

Browse files
authored
Merge pull request #4336 from j143/experiment
resolve 'float' to 'int' conversion, StringIO import, conacat str + byte
2 parents e79232f + 76cdc52 commit 419bc6e

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

research/neural_gpu/data_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def init_data(task, length, nbr_cases, nclass):
111111
"""Data initialization."""
112112
def rand_pair(l, task):
113113
"""Random data pair for a task. Total length should be <= l."""
114-
k = (l-1)/2
114+
k = int((l-1)/2)
115115
base = 10
116116
if task[0] == "b": base = 2
117117
if task[0] == "q": base = 4
@@ -135,7 +135,7 @@ def rand_pair(l, task):
135135

136136
def rand_dup_pair(l):
137137
"""Random data pair for duplication task. Total length should be <= l."""
138-
k = l/2
138+
k = int(l/2)
139139
x = [np.random.randint(nclass - 1) + 1 for _ in xrange(k)]
140140
inp = x + [0 for _ in xrange(l - k)]
141141
res = x + x + [0 for _ in xrange(l - 2*k)]

research/neural_gpu/program_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616

1717
import contextlib
1818
import sys
19-
import StringIO
2019
import random
2120
import os
2221

22+
try:
23+
import StringIO
24+
except ImportError:
25+
from io import StringIO
26+
2327
class ListType(object):
2428
def __init__(self, arg):
2529
self.arg = arg

research/neural_gpu/wmt_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
_CHAR_MARKER_LEN = len(_CHAR_MARKER)
4444
_SPEC_CHARS = "" + chr(226) + chr(153) + chr(128)
4545
_PUNCTUATION = "][.,!?\"':;%$#@&*+}{|><=/^~)(_`,0123456789" + _SPEC_CHARS + "-"
46-
_WORD_SPLIT = re.compile(b"([" + _PUNCTUATION + "])")
46+
_WORD_SPLIT = re.compile("([" + _PUNCTUATION + "])")
4747
_OLD_WORD_SPLIT = re.compile(b"([.,!?\"':;)(])")
4848
_DIGIT_RE = re.compile(br"\d")
4949

0 commit comments

Comments
 (0)