From a221783bcd6310ea236ba2c90d46c82fb60d88aa Mon Sep 17 00:00:00 2001 From: tyarkoni Date: Tue, 1 Sep 2015 09:50:51 -0400 Subject: [PATCH] more python3 fixes and cleanup --- .gitignore | 5 +- neurosynth/analysis/decode.py | 3 +- neurosynth/base/lextab.py | 10 - neurosynth/base/parser.out | 403 ---------------------------------- neurosynth/base/parsetab.py | 40 ---- 5 files changed, 5 insertions(+), 456 deletions(-) delete mode 100644 neurosynth/base/lextab.py delete mode 100644 neurosynth/base/parser.out delete mode 100644 neurosynth/base/parsetab.py diff --git a/.gitignore b/.gitignore index f5ffad4..a78f2c8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,7 @@ dist dist/* .ipynb_checkpoints docs/_*/* -neurosynth.egg-info \ No newline at end of file +neurosynth.egg-info +neurosynth/base/lextab.py +neurosynth/base/parser.out +neurosynth/base/parsetab.py \ No newline at end of file diff --git a/neurosynth/analysis/decode.py b/neurosynth/analysis/decode.py index 28bb838..f95cada 100644 --- a/neurosynth/analysis/decode.py +++ b/neurosynth/analysis/decode.py @@ -163,8 +163,7 @@ def _load_features_from_dataset(self, features=None, image_type=None, """ self.feature_names = self.dataset.feature_table.feature_names if features is not None: - self.feature_names = filter( - lambda x: x in self.feature_names, features) + self.feature_names = [f for f in features if f in self.feature_names] from neurosynth.analysis import meta self.feature_images = meta.analyze_features( self.dataset, self.feature_names, image_type=image_type, diff --git a/neurosynth/base/lextab.py b/neurosynth/base/lextab.py deleted file mode 100644 index 9d50d80..0000000 --- a/neurosynth/base/lextab.py +++ /dev/null @@ -1,10 +0,0 @@ -# lextab.py. This file automatically created by PLY (version 3.6). Don't edit! -_tabversion = '3.5' -_lextokens = {'ANDNOT', 'LT', 'RPAR', 'LPAR', 'OR', 'WORD', 'FLOAT', 'AND', 'RT'} -_lexreflags = 0 -_lexliterals = '' -_lexstateinfo = {'INITIAL': 'inclusive'} -_lexstatere = {'INITIAL': [('(?P[a-zA-Z\\_\\-\\*]+)|(?P[0-9\\.]+)|(?P\\&\\~)|(?P\\&)|(?P\\()|(?P\\))|(?P\\>)|(?P\\<)|(?P\\|)', [None, ('t_WORD', 'WORD'), ('t_FLOAT', 'FLOAT'), (None, 'ANDNOT'), (None, 'AND'), (None, 'LPAR'), (None, 'RPAR'), (None, 'RT'), (None, 'LT'), (None, 'OR')])]} -_lexstateignore = {'INITIAL': ' \t'} -_lexstateerrorf = {'INITIAL': 't_error'} -_lexstateeoff = {} diff --git a/neurosynth/base/parser.out b/neurosynth/base/parser.out deleted file mode 100644 index 4fb22ab..0000000 --- a/neurosynth/base/parser.out +++ /dev/null @@ -1,403 +0,0 @@ -Created by PLY version 3.6 (http://www.dabeaz.com/ply) - -Grammar - -Rule 0 S' -> list -Rule 1 list -> list ANDNOT list -Rule 2 list -> list AND list -Rule 3 list -> list OR list -Rule 4 list -> list LT freq -Rule 5 list -> list RT freq -Rule 6 feature -> WORD WORD -Rule 7 feature -> feature WORD -Rule 8 list -> feature -Rule 9 list -> WORD -Rule 10 list -> LPAR list RPAR -Rule 11 freq -> FLOAT - -Terminals, with rules where they appear - -AND : 2 -ANDNOT : 1 -FLOAT : 11 -LPAR : 10 -LT : 4 -OR : 3 -RPAR : 10 -RT : 5 -WORD : 6 6 7 9 -error : - -Nonterminals, with rules where they appear - -feature : 7 8 -freq : 4 5 -list : 1 1 2 2 3 3 4 5 10 0 - -Parsing method: LALR - -state 0 - - (0) S' -> . list - (1) list -> . list ANDNOT list - (2) list -> . list AND list - (3) list -> . list OR list - (4) list -> . list LT freq - (5) list -> . list RT freq - (8) list -> . feature - (9) list -> . WORD - (10) list -> . LPAR list RPAR - (6) feature -> . WORD WORD - (7) feature -> . feature WORD - - WORD shift and go to state 2 - LPAR shift and go to state 1 - - feature shift and go to state 3 - list shift and go to state 4 - -state 1 - - (10) list -> LPAR . list RPAR - (1) list -> . list ANDNOT list - (2) list -> . list AND list - (3) list -> . list OR list - (4) list -> . list LT freq - (5) list -> . list RT freq - (8) list -> . feature - (9) list -> . WORD - (10) list -> . LPAR list RPAR - (6) feature -> . WORD WORD - (7) feature -> . feature WORD - - WORD shift and go to state 2 - LPAR shift and go to state 1 - - feature shift and go to state 3 - list shift and go to state 5 - -state 2 - - (9) list -> WORD . - (6) feature -> WORD . WORD - - ANDNOT reduce using rule 9 (list -> WORD .) - AND reduce using rule 9 (list -> WORD .) - OR reduce using rule 9 (list -> WORD .) - LT reduce using rule 9 (list -> WORD .) - RT reduce using rule 9 (list -> WORD .) - $end reduce using rule 9 (list -> WORD .) - RPAR reduce using rule 9 (list -> WORD .) - WORD shift and go to state 6 - - -state 3 - - (8) list -> feature . - (7) feature -> feature . WORD - - ANDNOT reduce using rule 8 (list -> feature .) - AND reduce using rule 8 (list -> feature .) - OR reduce using rule 8 (list -> feature .) - LT reduce using rule 8 (list -> feature .) - RT reduce using rule 8 (list -> feature .) - $end reduce using rule 8 (list -> feature .) - RPAR reduce using rule 8 (list -> feature .) - WORD shift and go to state 7 - - -state 4 - - (0) S' -> list . - (1) list -> list . ANDNOT list - (2) list -> list . AND list - (3) list -> list . OR list - (4) list -> list . LT freq - (5) list -> list . RT freq - - ANDNOT shift and go to state 10 - AND shift and go to state 11 - OR shift and go to state 9 - LT shift and go to state 12 - RT shift and go to state 8 - - -state 5 - - (10) list -> LPAR list . RPAR - (1) list -> list . ANDNOT list - (2) list -> list . AND list - (3) list -> list . OR list - (4) list -> list . LT freq - (5) list -> list . RT freq - - RPAR shift and go to state 13 - ANDNOT shift and go to state 10 - AND shift and go to state 11 - OR shift and go to state 9 - LT shift and go to state 12 - RT shift and go to state 8 - - -state 6 - - (6) feature -> WORD WORD . - - WORD reduce using rule 6 (feature -> WORD WORD .) - ANDNOT reduce using rule 6 (feature -> WORD WORD .) - AND reduce using rule 6 (feature -> WORD WORD .) - OR reduce using rule 6 (feature -> WORD WORD .) - LT reduce using rule 6 (feature -> WORD WORD .) - RT reduce using rule 6 (feature -> WORD WORD .) - $end reduce using rule 6 (feature -> WORD WORD .) - RPAR reduce using rule 6 (feature -> WORD WORD .) - - -state 7 - - (7) feature -> feature WORD . - - WORD reduce using rule 7 (feature -> feature WORD .) - ANDNOT reduce using rule 7 (feature -> feature WORD .) - AND reduce using rule 7 (feature -> feature WORD .) - OR reduce using rule 7 (feature -> feature WORD .) - LT reduce using rule 7 (feature -> feature WORD .) - RT reduce using rule 7 (feature -> feature WORD .) - $end reduce using rule 7 (feature -> feature WORD .) - RPAR reduce using rule 7 (feature -> feature WORD .) - - -state 8 - - (5) list -> list RT . freq - (11) freq -> . FLOAT - - FLOAT shift and go to state 14 - - freq shift and go to state 15 - -state 9 - - (3) list -> list OR . list - (1) list -> . list ANDNOT list - (2) list -> . list AND list - (3) list -> . list OR list - (4) list -> . list LT freq - (5) list -> . list RT freq - (8) list -> . feature - (9) list -> . WORD - (10) list -> . LPAR list RPAR - (6) feature -> . WORD WORD - (7) feature -> . feature WORD - - WORD shift and go to state 2 - LPAR shift and go to state 1 - - feature shift and go to state 3 - list shift and go to state 16 - -state 10 - - (1) list -> list ANDNOT . list - (1) list -> . list ANDNOT list - (2) list -> . list AND list - (3) list -> . list OR list - (4) list -> . list LT freq - (5) list -> . list RT freq - (8) list -> . feature - (9) list -> . WORD - (10) list -> . LPAR list RPAR - (6) feature -> . WORD WORD - (7) feature -> . feature WORD - - WORD shift and go to state 2 - LPAR shift and go to state 1 - - feature shift and go to state 3 - list shift and go to state 17 - -state 11 - - (2) list -> list AND . list - (1) list -> . list ANDNOT list - (2) list -> . list AND list - (3) list -> . list OR list - (4) list -> . list LT freq - (5) list -> . list RT freq - (8) list -> . feature - (9) list -> . WORD - (10) list -> . LPAR list RPAR - (6) feature -> . WORD WORD - (7) feature -> . feature WORD - - WORD shift and go to state 2 - LPAR shift and go to state 1 - - feature shift and go to state 3 - list shift and go to state 18 - -state 12 - - (4) list -> list LT . freq - (11) freq -> . FLOAT - - FLOAT shift and go to state 14 - - freq shift and go to state 19 - -state 13 - - (10) list -> LPAR list RPAR . - - ANDNOT reduce using rule 10 (list -> LPAR list RPAR .) - AND reduce using rule 10 (list -> LPAR list RPAR .) - OR reduce using rule 10 (list -> LPAR list RPAR .) - LT reduce using rule 10 (list -> LPAR list RPAR .) - RT reduce using rule 10 (list -> LPAR list RPAR .) - $end reduce using rule 10 (list -> LPAR list RPAR .) - RPAR reduce using rule 10 (list -> LPAR list RPAR .) - - -state 14 - - (11) freq -> FLOAT . - - ANDNOT reduce using rule 11 (freq -> FLOAT .) - AND reduce using rule 11 (freq -> FLOAT .) - OR reduce using rule 11 (freq -> FLOAT .) - LT reduce using rule 11 (freq -> FLOAT .) - RT reduce using rule 11 (freq -> FLOAT .) - $end reduce using rule 11 (freq -> FLOAT .) - RPAR reduce using rule 11 (freq -> FLOAT .) - - -state 15 - - (5) list -> list RT freq . - - ANDNOT reduce using rule 5 (list -> list RT freq .) - AND reduce using rule 5 (list -> list RT freq .) - OR reduce using rule 5 (list -> list RT freq .) - LT reduce using rule 5 (list -> list RT freq .) - RT reduce using rule 5 (list -> list RT freq .) - $end reduce using rule 5 (list -> list RT freq .) - RPAR reduce using rule 5 (list -> list RT freq .) - - -state 16 - - (3) list -> list OR list . - (1) list -> list . ANDNOT list - (2) list -> list . AND list - (3) list -> list . OR list - (4) list -> list . LT freq - (5) list -> list . RT freq - - ! shift/reduce conflict for ANDNOT resolved as shift - ! shift/reduce conflict for AND resolved as shift - ! shift/reduce conflict for OR resolved as shift - ! shift/reduce conflict for LT resolved as shift - ! shift/reduce conflict for RT resolved as shift - $end reduce using rule 3 (list -> list OR list .) - RPAR reduce using rule 3 (list -> list OR list .) - ANDNOT shift and go to state 10 - AND shift and go to state 11 - OR shift and go to state 9 - LT shift and go to state 12 - RT shift and go to state 8 - - ! ANDNOT [ reduce using rule 3 (list -> list OR list .) ] - ! AND [ reduce using rule 3 (list -> list OR list .) ] - ! OR [ reduce using rule 3 (list -> list OR list .) ] - ! LT [ reduce using rule 3 (list -> list OR list .) ] - ! RT [ reduce using rule 3 (list -> list OR list .) ] - - -state 17 - - (1) list -> list ANDNOT list . - (1) list -> list . ANDNOT list - (2) list -> list . AND list - (3) list -> list . OR list - (4) list -> list . LT freq - (5) list -> list . RT freq - - ! shift/reduce conflict for ANDNOT resolved as shift - ! shift/reduce conflict for AND resolved as shift - ! shift/reduce conflict for OR resolved as shift - ! shift/reduce conflict for LT resolved as shift - ! shift/reduce conflict for RT resolved as shift - $end reduce using rule 1 (list -> list ANDNOT list .) - RPAR reduce using rule 1 (list -> list ANDNOT list .) - ANDNOT shift and go to state 10 - AND shift and go to state 11 - OR shift and go to state 9 - LT shift and go to state 12 - RT shift and go to state 8 - - ! ANDNOT [ reduce using rule 1 (list -> list ANDNOT list .) ] - ! AND [ reduce using rule 1 (list -> list ANDNOT list .) ] - ! OR [ reduce using rule 1 (list -> list ANDNOT list .) ] - ! LT [ reduce using rule 1 (list -> list ANDNOT list .) ] - ! RT [ reduce using rule 1 (list -> list ANDNOT list .) ] - - -state 18 - - (2) list -> list AND list . - (1) list -> list . ANDNOT list - (2) list -> list . AND list - (3) list -> list . OR list - (4) list -> list . LT freq - (5) list -> list . RT freq - - ! shift/reduce conflict for ANDNOT resolved as shift - ! shift/reduce conflict for AND resolved as shift - ! shift/reduce conflict for OR resolved as shift - ! shift/reduce conflict for LT resolved as shift - ! shift/reduce conflict for RT resolved as shift - $end reduce using rule 2 (list -> list AND list .) - RPAR reduce using rule 2 (list -> list AND list .) - ANDNOT shift and go to state 10 - AND shift and go to state 11 - OR shift and go to state 9 - LT shift and go to state 12 - RT shift and go to state 8 - - ! ANDNOT [ reduce using rule 2 (list -> list AND list .) ] - ! AND [ reduce using rule 2 (list -> list AND list .) ] - ! OR [ reduce using rule 2 (list -> list AND list .) ] - ! LT [ reduce using rule 2 (list -> list AND list .) ] - ! RT [ reduce using rule 2 (list -> list AND list .) ] - - -state 19 - - (4) list -> list LT freq . - - ANDNOT reduce using rule 4 (list -> list LT freq .) - AND reduce using rule 4 (list -> list LT freq .) - OR reduce using rule 4 (list -> list LT freq .) - LT reduce using rule 4 (list -> list LT freq .) - RT reduce using rule 4 (list -> list LT freq .) - $end reduce using rule 4 (list -> list LT freq .) - RPAR reduce using rule 4 (list -> list LT freq .) - -WARNING: -WARNING: Conflicts: -WARNING: -WARNING: shift/reduce conflict for ANDNOT in state 16 resolved as shift -WARNING: shift/reduce conflict for AND in state 16 resolved as shift -WARNING: shift/reduce conflict for OR in state 16 resolved as shift -WARNING: shift/reduce conflict for LT in state 16 resolved as shift -WARNING: shift/reduce conflict for RT in state 16 resolved as shift -WARNING: shift/reduce conflict for ANDNOT in state 17 resolved as shift -WARNING: shift/reduce conflict for AND in state 17 resolved as shift -WARNING: shift/reduce conflict for OR in state 17 resolved as shift -WARNING: shift/reduce conflict for LT in state 17 resolved as shift -WARNING: shift/reduce conflict for RT in state 17 resolved as shift -WARNING: shift/reduce conflict for ANDNOT in state 18 resolved as shift -WARNING: shift/reduce conflict for AND in state 18 resolved as shift -WARNING: shift/reduce conflict for OR in state 18 resolved as shift -WARNING: shift/reduce conflict for LT in state 18 resolved as shift -WARNING: shift/reduce conflict for RT in state 18 resolved as shift diff --git a/neurosynth/base/parsetab.py b/neurosynth/base/parsetab.py deleted file mode 100644 index 67c036b..0000000 --- a/neurosynth/base/parsetab.py +++ /dev/null @@ -1,40 +0,0 @@ - -# /Users/tal/Dropbox/Code/neurosynth/neurosynth/base/parsetab.py -# This file is automatically generated. Do not edit. -_tabversion = '3.5' - -_lr_method = 'LALR' - -_lr_signature = '3CFA3369D62E748D41C546F02C0CB00D' - -_lr_action_items = {'LPAR':([0,1,9,10,11,],[1,1,1,1,1,]),'AND':([2,3,4,5,6,7,13,14,15,16,17,18,19,],[-9,-8,11,11,-6,-7,-10,-11,-5,11,11,11,-4,]),'OR':([2,3,4,5,6,7,13,14,15,16,17,18,19,],[-9,-8,9,9,-6,-7,-10,-11,-5,9,9,9,-4,]),'ANDNOT':([2,3,4,5,6,7,13,14,15,16,17,18,19,],[-9,-8,10,10,-6,-7,-10,-11,-5,10,10,10,-4,]),'WORD':([0,1,2,3,6,7,9,10,11,],[2,2,6,7,-6,-7,2,2,2,]),'FLOAT':([8,12,],[14,14,]),'RT':([2,3,4,5,6,7,13,14,15,16,17,18,19,],[-9,-8,8,8,-6,-7,-10,-11,-5,8,8,8,-4,]),'$end':([2,3,4,6,7,13,14,15,16,17,18,19,],[-9,-8,0,-6,-7,-10,-11,-5,-3,-1,-2,-4,]),'LT':([2,3,4,5,6,7,13,14,15,16,17,18,19,],[-9,-8,12,12,-6,-7,-10,-11,-5,12,12,12,-4,]),'RPAR':([2,3,5,6,7,13,14,15,16,17,18,19,],[-9,-8,13,-6,-7,-10,-11,-5,-3,-1,-2,-4,]),} - -_lr_action = {} -for _k, _v in _lr_action_items.items(): - for _x,_y in zip(_v[0],_v[1]): - if not _x in _lr_action: _lr_action[_x] = {} - _lr_action[_x][_k] = _y -del _lr_action_items - -_lr_goto_items = {'feature':([0,1,9,10,11,],[3,3,3,3,3,]),'freq':([8,12,],[15,19,]),'list':([0,1,9,10,11,],[4,5,16,17,18,]),} - -_lr_goto = {} -for _k, _v in _lr_goto_items.items(): - for _x, _y in zip(_v[0], _v[1]): - if not _x in _lr_goto: _lr_goto[_x] = {} - _lr_goto[_x][_k] = _y -del _lr_goto_items -_lr_productions = [ - ("S' -> list","S'",1,None,None,None), - ('list -> list ANDNOT list','list',3,'p_list_andnot','lexparser.py',67), - ('list -> list AND list','list',3,'p_list_and','lexparser.py',71), - ('list -> list OR list','list',3,'p_list_or','lexparser.py',76), - ('list -> list LT freq','list',3,'p_list_lt','lexparser.py',81), - ('list -> list RT freq','list',3,'p_list_rt','lexparser.py',85), - ('feature -> WORD WORD','feature',2,'p_feature_words','lexparser.py',89), - ('feature -> feature WORD','feature',2,'p_feature_words','lexparser.py',90), - ('list -> feature','list',1,'p_list_feature','lexparser.py',94), - ('list -> WORD','list',1,'p_list_feature','lexparser.py',95), - ('list -> LPAR list RPAR','list',3,'p_list_expr','lexparser.py',101), - ('freq -> FLOAT','freq',1,'p_freq_float','lexparser.py',105), -]