Skip to content
Permalink
Browse files

python 3 compatibility

  • Loading branch information...
tyarkoni committed Jan 8, 2015
1 parent 45438b8 commit a53a2f9c50760856aedcc0dca72a6c751928c174
Showing with 13 additions and 13 deletions.
  1. +5 −5 precis/__init__.py
  2. +5 −6 precis/base.py
  3. +3 −2 requirements.txt
@@ -8,12 +8,12 @@
import logging
import sys
import os
from base import Dataset, Measure, AbbreviatedMeasure
from abbreviate import Abbreviator
from evaluate import Evaluator
from generate import Generator
from .base import Dataset, Measure, AbbreviatedMeasure
from .abbreviate import Abbreviator
from .evaluate import Evaluator
from .generate import Generator

from version import __version__
from .version import __version__

logger = logging.getLogger("precis")

@@ -1,12 +1,11 @@

import numpy as np
import pandas as pd
import logging
from precis import stats
from precis import plot
import copy
import os

from six import string_types

logger = logging.getLogger('precis')

@@ -37,7 +36,7 @@ class Dataset(object):
def __init__(self, X, y=None, sep='\t', missing=None, select_X=None,
select_y=None, keep_labels=False):
# Read in data
if isinstance(X, basestring):
if isinstance(X, string_types):
X = pd.read_csv(X, sep=sep).convert_objects(convert_numeric=True)
try:
X = X.drop('sample', axis=1)
@@ -46,7 +45,7 @@ def __init__(self, X, y=None, sep='\t', missing=None, select_X=None,
elif not hasattr(X, 'columns'):
X = pd.DataFrame(X)

if y is not None and isinstance(y, basestring):
if y is not None and isinstance(y, string_types):
y = pd.read_csv(y, sep=sep).convert_objects(convert_numeric=True)

self.X = X
@@ -165,7 +164,7 @@ def score(self, key, columns=None, rescale=True):
rescale (bool): If True, adjusts the total y scores to account for
the presence of reverse-keyed items.
'''
if isinstance(key, basestring):
if isinstance(key, string_types):
key = pd.read_csv(key, sep='\t', header=None).values
y = np.dot(self.X, key)
if rescale:
@@ -256,7 +255,7 @@ def set_key(self, key):
key. Key format is items in rows, scales in columns, with no
index or header.
"""
if isinstance(key, basestring):
if isinstance(key, string_types):
key = pd.read_csv(key, sep='\t', header=None)
if isinstance(key, pd.DataFrame):
key = key.values
@@ -1,4 +1,5 @@
numpy
deap
matplotlib
numpy
pandas
deap
six

0 comments on commit a53a2f9

Please sign in to comment.
You can’t perform that action at this time.