Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
24 changes: 12 additions & 12 deletions backspinpy/Cef_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -130,32 +130,32 @@ 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'))



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')



2 changes: 1 addition & 1 deletion backspinpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from __future__ import absolute_import

from .backSPIN import SPIN, backSPIN, fit_CV, feature_selection
from .Cef_tools import CEF_obj
2 changes: 1 addition & 1 deletion backspinpy/backSPIN.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down