Skip to content

Commit

Permalink
Setup work (#18)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jonathan-taylor authored Jan 18, 2024
1 parent f265fc7 commit 97fb1fe
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 148 deletions.
83 changes: 0 additions & 83 deletions ISLP/info.py

This file was deleted.

11 changes: 6 additions & 5 deletions ISLP/models/model_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ def build_model(column_info,

if len(dfs):
if isinstance(X, (pd.Series, pd.DataFrame)):
df = pd.concat(dfs, axis=1)
df = pd.concat(dfs, axis='columns')
df.index = X.index
else:
return np.column_stack(dfs).astype(float)
Expand All @@ -645,10 +645,11 @@ def build_model(column_info,
return zero

# if we reach here, we will be returning a DataFrame

for col in df.columns:
if df[col].dtype == bool:
df[col] = df[col].astype(float)
# make sure all columns are floats

for i, _ in enumerate(df.columns):
if df.iloc[:,i].dtype == bool:
df.iloc[:,i] = df.iloc[:,i].astype(float)
return df

def derived_feature(variables, encoder=None, name=None, use_transform=True):
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "ISLP"
version = "0.3.21"
version = "0.3.22"
dependencies = ["numpy>=1.7.1,<1.25", # max version for numba
"scipy>=0.9",
"pandas>=0.20,<=1.9",
Expand Down Expand Up @@ -37,13 +37,17 @@ classifiers = ["Development Status :: 3 - Alpha",
"Programming Language :: Python",
"Topic :: Scientific/Engineering"
]

[project.urls] # Optional
"Homepage" = "https://github.com/intro-stat-learning/ISLP"
"Bug Reports" = "https://github.com/intro-stat-learning/ISLP/issues"
"Funding" = "https://donate.pypi.org"
"Say Thanks!" = "http://saythanks.io/to/example"
"Source" = "https://github.com/pypa/sampleproject/"

[project.optional-dependencies]
doc = ['Sphinx>=3.0']

[build-system]
requires = ["setuptools>=42",
"wheel",
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ style = pep440
versionfile_source = ISLP/_version.py
tag_prefix =
parentdir_prefix = ISLP-

[metadata]
license_files = LICENSE.txt
62 changes: 3 additions & 59 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,74 +16,18 @@

from setuptools import setup

# Get various parameters for this version, stored in ISLP/info.py

class Bunch(object):
def __init__(self, vars):
for key, name in vars.items():
if key.startswith('__'):
continue
self.__dict__[key] = name

def read_vars_from(ver_file):
""" Read variables from Python text file
Parameters
----------
ver_file : str
Filename of file to read
Returns
-------
info_vars : Bunch instance
Bunch object where variables read from `ver_file` appear as
attributes
"""
# Use exec for compabibility with Python 3
ns = {}
with open(ver_file, 'rt') as fobj:
exec(fobj.read(), ns)
return Bunch(ns)

info = read_vars_from(pjoin('ISLP', 'info.py'))

# Try to preempt setuptools monkeypatching of Extension handling when Pyrex
# is missing. Otherwise the monkeypatched Extension will change .pyx
# filenames to .c filenames, and we probably don't have the .c files.
sys.path.insert(0, pjoin(dirname(__file__), 'fake_pyrex'))
# Set setuptools extra arguments
extra_setuptools_args = dict(
tests_require=['nose'],
test_suite='nose.collector',
zip_safe=False,
extras_require = dict(
doc=['Sphinx>=1.0'],
test=['nose>=0.10.1']))

# Define extensions
EXTS = []

cmdclass=versioneer.get_cmdclass()
cmdclass = versioneer.get_cmdclass()

# get long_description

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

def main(**extra_args):
setup(name=info.NAME,
maintainer=info.MAINTAINER,
maintainer_email=info.MAINTAINER_EMAIL,
description=info.DESCRIPTION,
url=info.URL,
download_url=info.DOWNLOAD_URL,
license=info.LICENSE,
classifiers=info.CLASSIFIERS,
author=info.AUTHOR,
author_email=info.AUTHOR_EMAIL,
platforms=info.PLATFORMS,
version=versioneer.get_version(),
requires=info.REQUIRES,
provides=info.PROVIDES,
setup(version=versioneer.get_version(),
packages = ['ISLP',
'ISLP.models',
'ISLP.models',
Expand All @@ -104,4 +48,4 @@ def main(**extra_args):
#simple way to test what setup will do
#python setup.py install --prefix=/tmp
if __name__ == "__main__":
main(**extra_setuptools_args)
main()

0 comments on commit 97fb1fe

Please sign in to comment.