diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7d03ea8 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +sudo: false +language: python +python: + - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.6" + - "3.7-dev" # 3.7 development branch + +install: "pip install -r requirements.txt; pip install tox-travis" +env: + - TOXENV=pep8 + - TOXENV=coverage +script: tox +before_install: + - pip install codecov +after_success: + - codecov \ No newline at end of file diff --git a/backspinpy/Cef_tools.py b/backspinpy/Cef_tools.py index 9d56f8a..c9fbfe4 100644 --- a/backspinpy/Cef_tools.py +++ b/backspinpy/Cef_tools.py @@ -40,7 +40,7 @@ # attribute_values_list2 = cef.col_attr_values[2] # ... -from builtins import str as unicode +from builtins import str as str from io import open from builtins import range @@ -73,7 +73,7 @@ def update(self): self.rows = len(self.matrix) self.cols = len(self.matrix[0]) self.tab_fields = max(7, self.cols + self.row_attr + 1) - self.linestr = u'%s' + u'\t%s' * (self.tab_fields-1) + u'\n' + self.linestr = '%s' + '\t%s' * (self.tab_fields-1) + '\n' def add_header(self, name, value): self.header_names.append(name) @@ -130,7 +130,7 @@ def readCEF(self, filepath, matrix_dtype = 'auto'): try: self.matrix.append( [matrix_dtype(el) for el in linelist[self.row_attr+1:] ]) except ValueError: - print(repr(el), ' is invalid') + print((repr(el), ' is invalid')) @@ -138,24 +138,24 @@ def writeCEF(self, filepath, matrix_str_fmt = '%i'): self.update() with open(filepath, 'w') as fout: #Write cef file first line - fout.write( self.linestr % ( ('CEF', unicode(self.headers), unicode(self.row_attr),\ - unicode(self.col_attr) , unicode(self.rows), unicode(self.cols), unicode(self.flags) ) +\ + fout.write( self.linestr % ( ('CEF', str(self.headers), str(self.row_attr),\ + str(self.col_attr) , str(self.rows), str(self.cols), str(self.flags) ) +\ ('',) * (self.tab_fields - 7) ) ) #Write header for i in range(self.headers): - fout.write(self.linestr % ( (unicode( self.header_names[i]), unicode( self.header_values[i]) ) + ('',) * (self.tab_fields - 2) )) + fout.write(self.linestr % ( (str( self.header_names[i]), str( self.header_values[i]) ) + ('',) * (self.tab_fields - 2) )) #Write col attributes for i in range( self.col_attr ): - fout.write( self.linestr % ( ('',) * (self.row_attr) + (unicode( self.col_attr_names[i] ),) + tuple( unicode(el) for el in self.col_attr_values[i] ) )) + fout.write( self.linestr % ( ('',) * (self.row_attr) + (str( self.col_attr_names[i] ),) + tuple( str(el) for el in self.col_attr_values[i] ) )) #Write headers of row attributes - fout.write( self.linestr % ( tuple(unicode(el) for el in self.row_attr_names) + ('',)*(self.tab_fields-self.row_attr) ) ) + fout.write( self.linestr % ( tuple(str(el) for el in self.row_attr_names) + ('',)*(self.tab_fields-self.row_attr) ) ) #Write rows for i in range(self.rows): for j in range(self.row_attr): - fout.write(unicode(self.row_attr_values[j][i]) + u'\t') - fout.write(u'\t') - fout.write(u'\t'.join([unicode(matrix_str_fmt % el) for el in self.matrix[i]] ) ) - fout.write(u'\n') + fout.write(str(self.row_attr_values[j][i]) + '\t') + fout.write('\t') + fout.write('\t'.join([str(matrix_str_fmt % el) for el in self.matrix[i]] ) ) + fout.write('\n') diff --git a/backspinpy/__init__.py b/backspinpy/__init__.py index 2b92ec8..5b7711f 100644 --- a/backspinpy/__init__.py +++ b/backspinpy/__init__.py @@ -1,3 +1,3 @@ -from __future__ import absolute_import + from .backSPIN import SPIN, backSPIN, fit_CV, feature_selection from .Cef_tools import CEF_obj diff --git a/backspinpy/backSPIN.py b/backspinpy/backSPIN.py index 02bc3bd..baf9208 100755 --- a/backspinpy/backSPIN.py +++ b/backspinpy/backSPIN.py @@ -34,7 +34,7 @@ # pyinstaller -F backSPIN.py -n backspin-mac-64-bit # -from __future__ import division, print_function, absolute_import + from numpy import * import getopt import sys