Closed cclauss closed 6 years ago
@nealwu mind taking a quick look?
Hi @cclauss, we don't officially maintain the research/
folder; that is up to the individual researchers. However, if you're able to create a pull request to fix this issue en masse, I'm happy to take a look at it.
Or maybe something like this could be strategically placed?
import sys
if sys.version_info >= (3, 0):
def xrange(*args, **kwargs):
return iter(range(*args, **kwargs))
@rickhg12hs we prefer to use six
for this purpose. It also provides a number of other Python 2/3 compatibility fixes; you can see https://pythonhosted.org/six/for a full list.
@nealwu Yeah, six
should be a better solution. Is there a magical place to import it smartly?
Closing thanks to the above fix from @cclauss.
hello sir
import numpy as np import random from six.moves import cPickle as pickle from TwitterElection.Embedding import MeanEmbeddingVectorizer from TwitterElection.TopicModel import TopicModel from gensim.models.word2vec import Word2Vec
INPUT_DIR = '/path/to/data/en/' # subfolder with all english tweets only OUTPUT_DIR = '/path/to/data/'
def save_pickle(fname, tweets): with open(fname + '.pickle', 'wb') as f: pickle.dump(tweets, f, pickle.HIGHEST_PROTOCOL)
def load_pickle(fname): with open(fname + '.pickle', 'rb') as f: tweets = pickle.load(f) return tweets error is invaild path plz help us
FYI, I was trying to run model_builder_test.py and found another xrange without six.moves.xrange import statement in models/research/object_detection/anchor_generators/multiscale_grid_anchor_generator.py
@renewang Looking at models/research/object_detection/anchor_generators/multiscale_grid_anchor_generator.py
in the master branch, I don't see an xrange
.
flake8 running on Python 3.7 found 21 instances of xrange() as an undefined name...
./research/differential_privacy/pate/ICLR2018/rdp_bucketized.py:79:12: F821 undefined name 'xrange'
./research/differential_privacy/pate/ICLR2018/rdp_bucketized.py:106:12: F821 undefined name 'xrange'
./research/differential_privacy/pate/ICLR2018/rdp_bucketized.py:139:12: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/graph_builder_test.py:428:20: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/network_units.py:2334:14: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/network_units.py:2413:24: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/spec_builder.py:251:16: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/spec_builder.py:255:14: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/runtime_support.py:306:54: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/trainer_lib.py:40:16: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/trainer_lib.py:100:21: F821 undefined name 'xrange'
./research/syntaxnet/dragnn/python/trainer_lib.py:106:23: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/utils.py:123:12: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/utils.py:176:16: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/summary_utils.py:136:12: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/summary_utils.py:159:12: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/meta_objective/utils.py:53:14: F821 undefined name 'xrange'
./research/learning_unsupervised_learning/meta_objective/linear_regression.py:105:14: F821 undefined name 'xrange'
./research/seq2species/test_utils.py:70:14: F821 undefined name 'xrange'
./research/seq2species/test_utils.py:101:46: F821 undefined name 'xrange'
./research/seq2species/build_model.py:382:14: F821 undefined name 'xrange'
__./research/object_detection has at least three Python 3 incompatibilities but not an xrange() issue... (Unless of course it is hidden behind one of the legacy print__ statements).
./research/object_detection/utils/object_detection_evaluation.py:307:27: F821 undefined name 'unicode'
category_name = unicode(category_name, 'utf-8')
^
./research/object_detection/meta_architectures/ssd_meta_arch_test.py:684:21: E999 SyntaxError: invalid syntax
print num_classes, num_anchors
^
./research/object_detection/dataset_tools/oid_hierarchical_labels_expansion.py:157:55: E999 SyntaxError: invalid syntax
print '--annotation_type expected value is 1 or 2.'
^
The following files are incompatible with Python 3 at least in part because they use xrange() yet they lack the import: