Skip to content

Commit 97fb1fe

Browse files
* ensuring boolean columns get cast to float for statsmodels * editing setup files, cleanup * commenting out info * cleanup of setup.py * use iloc for float conversion in case there are duplicate columnes
1 parent f265fc7 commit 97fb1fe

File tree

5 files changed

+17
-148
lines changed

5 files changed

+17
-148
lines changed

ISLP/info.py

-83
This file was deleted.

ISLP/models/model_spec.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def build_model(column_info,
632632

633633
if len(dfs):
634634
if isinstance(X, (pd.Series, pd.DataFrame)):
635-
df = pd.concat(dfs, axis=1)
635+
df = pd.concat(dfs, axis='columns')
636636
df.index = X.index
637637
else:
638638
return np.column_stack(dfs).astype(float)
@@ -645,10 +645,11 @@ def build_model(column_info,
645645
return zero
646646

647647
# if we reach here, we will be returning a DataFrame
648-
649-
for col in df.columns:
650-
if df[col].dtype == bool:
651-
df[col] = df[col].astype(float)
648+
# make sure all columns are floats
649+
650+
for i, _ in enumerate(df.columns):
651+
if df.iloc[:,i].dtype == bool:
652+
df.iloc[:,i] = df.iloc[:,i].astype(float)
652653
return df
653654

654655
def derived_feature(variables, encoder=None, name=None, use_transform=True):

pyproject.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ISLP"
3-
version = "0.3.21"
3+
version = "0.3.22"
44
dependencies = ["numpy>=1.7.1,<1.25", # max version for numba
55
"scipy>=0.9",
66
"pandas>=0.20,<=1.9",
@@ -37,13 +37,17 @@ classifiers = ["Development Status :: 3 - Alpha",
3737
"Programming Language :: Python",
3838
"Topic :: Scientific/Engineering"
3939
]
40+
4041
[project.urls] # Optional
4142
"Homepage" = "https://github.com/intro-stat-learning/ISLP"
4243
"Bug Reports" = "https://github.com/intro-stat-learning/ISLP/issues"
4344
"Funding" = "https://donate.pypi.org"
4445
"Say Thanks!" = "http://saythanks.io/to/example"
4546
"Source" = "https://github.com/pypa/sampleproject/"
4647

48+
[project.optional-dependencies]
49+
doc = ['Sphinx>=3.0']
50+
4751
[build-system]
4852
requires = ["setuptools>=42",
4953
"wheel",

setup.cfg

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ style = pep440
44
versionfile_source = ISLP/_version.py
55
tag_prefix =
66
parentdir_prefix = ISLP-
7+
8+
[metadata]
9+
license_files = LICENSE.txt

setup.py

+3-59
Original file line numberDiff line numberDiff line change
@@ -16,74 +16,18 @@
1616

1717
from setuptools import setup
1818

19-
# Get various parameters for this version, stored in ISLP/info.py
20-
21-
class Bunch(object):
22-
def __init__(self, vars):
23-
for key, name in vars.items():
24-
if key.startswith('__'):
25-
continue
26-
self.__dict__[key] = name
27-
28-
def read_vars_from(ver_file):
29-
""" Read variables from Python text file
30-
31-
Parameters
32-
----------
33-
ver_file : str
34-
Filename of file to read
35-
36-
Returns
37-
-------
38-
info_vars : Bunch instance
39-
Bunch object where variables read from `ver_file` appear as
40-
attributes
41-
"""
42-
# Use exec for compabibility with Python 3
43-
ns = {}
44-
with open(ver_file, 'rt') as fobj:
45-
exec(fobj.read(), ns)
46-
return Bunch(ns)
47-
48-
info = read_vars_from(pjoin('ISLP', 'info.py'))
49-
50-
# Try to preempt setuptools monkeypatching of Extension handling when Pyrex
51-
# is missing. Otherwise the monkeypatched Extension will change .pyx
52-
# filenames to .c filenames, and we probably don't have the .c files.
53-
sys.path.insert(0, pjoin(dirname(__file__), 'fake_pyrex'))
54-
# Set setuptools extra arguments
55-
extra_setuptools_args = dict(
56-
tests_require=['nose'],
57-
test_suite='nose.collector',
58-
zip_safe=False,
59-
extras_require = dict(
60-
doc=['Sphinx>=1.0'],
61-
test=['nose>=0.10.1']))
6219

6320
# Define extensions
6421
EXTS = []
6522

66-
cmdclass=versioneer.get_cmdclass()
23+
cmdclass = versioneer.get_cmdclass()
6724

6825
# get long_description
6926

7027
long_description = open('README.md', 'rt', encoding='utf-8').read()
7128

7229
def main(**extra_args):
73-
setup(name=info.NAME,
74-
maintainer=info.MAINTAINER,
75-
maintainer_email=info.MAINTAINER_EMAIL,
76-
description=info.DESCRIPTION,
77-
url=info.URL,
78-
download_url=info.DOWNLOAD_URL,
79-
license=info.LICENSE,
80-
classifiers=info.CLASSIFIERS,
81-
author=info.AUTHOR,
82-
author_email=info.AUTHOR_EMAIL,
83-
platforms=info.PLATFORMS,
84-
version=versioneer.get_version(),
85-
requires=info.REQUIRES,
86-
provides=info.PROVIDES,
30+
setup(version=versioneer.get_version(),
8731
packages = ['ISLP',
8832
'ISLP.models',
8933
'ISLP.models',
@@ -104,4 +48,4 @@ def main(**extra_args):
10448
#simple way to test what setup will do
10549
#python setup.py install --prefix=/tmp
10650
if __name__ == "__main__":
107-
main(**extra_setuptools_args)
51+
main()

0 commit comments

Comments
 (0)