Skip to content

Commit

Permalink
Merge pull request #118 from ealcobaca/release_0.4.1
Browse files Browse the repository at this point in the history
Release 0.4.1
  • Loading branch information
FelSiq committed Mar 19, 2021
2 parents 387c86b + 6b68508 commit 9591de2
Show file tree
Hide file tree
Showing 28 changed files with 1,774 additions and 1,264 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# envs
env3.7
env3.6

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ clean: ## Clean all undesired files such as .so, .pyc, build files and etc.
rm -rf docs/_build
rm -rf docs/source/generated
rm -rf docs/source/auto_examples
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf pymfe.egg-info/
cd docs ; make clean_all

cl: clean ## Shortcut to clean
Expand Down Expand Up @@ -59,3 +62,5 @@ h: help ## Shortcut to help

format: ## format all the package using black
@black --line-length 79 pymfe/
@black --line-length 79 tests/
@black --line-length 79 docs/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![Documentation Status](https://readthedocs.org/projects/pymfe/badge/?version=latest)](https://pymfe.readthedocs.io/en/latest/?badge=latest)
[![PythonVersion](https://img.shields.io/pypi/pyversions/pymfe.svg)](https://www.python.org/downloads/release/python-370/)
[![Pypi](https://badge.fury.io/py/pymfe.svg)](https://badge.fury.io/py/pymfe)
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

# pymfe: Python Meta-Feature Extractor
The pymfe (**py**thon **m**eta-**f**eature **e**xtractor) provides a
Expand Down
76 changes: 40 additions & 36 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('../sphinxext'))
sys.path.insert(0, os.path.abspath("../sphinxext"))
from github_link import make_linkcode_resolve
import sphinx_gallery

Expand All @@ -22,29 +22,30 @@
# General information about the project.

project = "pymfe"
copyright = "2018-2020, Edesio Alcobaça, Felipe Siqueira"
copyright = "2018-2021, Edesio Alcobaça, Felipe Siqueira"
author = "Edesio Alcobaça, Felipe Siqueira"

# The full version, including alpha/beta/rc tags.
from pymfe import __version__

version = release = __version__


# -- General configuration ---------------------------------------------------

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.linkcode',
'sphinx.ext.intersphinx',
'sphinx_gallery.gen_gallery',
'numpydoc',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.linkcode",
"sphinx.ext.intersphinx",
"sphinx_gallery.gen_gallery",
"numpydoc",
]

# see: https://github.com/phn/pytpm/issues/3#issuecomment-12133978
Expand All @@ -53,34 +54,33 @@


# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = False

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '_templates']
exclude_patterns = ["_build", "_templates"]
# exclude_patterns = []

autodoc_default_options = {'members': True, 'inherited-members': True}
autodoc_default_options = {"members": True, "inherited-members": True}
# autodoc_default_flags = ['members', 'inherited-members']

# generate autosummary even if no references
autosummary_generate = True



# -- Options for HTML output -------------------------------------------------

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"
# html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,
Expand All @@ -91,33 +91,35 @@


# Output file base name for HTML help builder.
htmlhelp_basename = 'pymfe-docs'
htmlhelp_basename = "pymfe-docs"


# intersphinx configuration
intersphinx_mapping = {
'python': ('https://docs.python.org/{.major}'.format(
sys.version_info), None),
'numpy': ('https://docs.scipy.org/doc/numpy/', None),
'scipy': ('https://docs.scipy.org/doc/scipy/reference', None),
'matplotlib': ('https://matplotlib.org/', None),
'sklearn': ('http://scikit-learn.org/stable', None),
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
'arff': ('https://pythonhosted.org/liac-arff/', None)
"python": (
"https://docs.python.org/{.major}".format(sys.version_info),
None,
),
"numpy": ("https://docs.scipy.org/doc/numpy/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None),
"matplotlib": ("https://matplotlib.org/", None),
"sklearn": ("http://scikit-learn.org/stable", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"arff": ("https://pythonhosted.org/liac-arff/", None),
}

# ------ sphinx gallery ----------------------------------------------------

sphinx_gallery_conf = {
'doc_module': 'pymfe',
'backreferences_dir': os.path.join('generated'),
"doc_module": "pymfe",
"backreferences_dir": os.path.join("generated"),
# path to your example scripts
'examples_dirs': '../../examples',
"examples_dirs": "../../examples",
# path where to save gallery generated examples
'gallery_dirs': 'auto_examples',
'reference_url': {
"gallery_dirs": "auto_examples",
"reference_url": {
# The module you locally document uses None
'pymfe': None,
"pymfe": None,
},
# 'thumbnail_size': (50, 50),
# 'junit': '../test-results/sphinx-gallery/junit.xml',
Expand All @@ -128,17 +130,19 @@
}



# --- GitHun link -----------------------------------------------------------

# The following is used by sphinx.ext.linkcode to provide links to github
linkcode_resolve = make_linkcode_resolve('pymfe',
u'https://github.com/ealcobaca/'
'pymfe/blob/{revision}/'
'{package}/{path}#L{lineno}')
linkcode_resolve = make_linkcode_resolve(
"pymfe",
u"https://github.com/ealcobaca/"
"pymfe/blob/{revision}/"
"{package}/{path}#L{lineno}",
)
# print(linkcode_resolve('py', {'module': 'pymfe.mfe', 'fullname': 'MFE'}))


# run auto pages
import os
os.system('python pages/run.py')

os.system("python pages/run.py")
10 changes: 3 additions & 7 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ The PyMFE package requires the following dependencies:

* numpy
* scipy
* sklearn
* pandas
* scikit-learn
* patsy
* pandas
* statsmodels
* texttable
* tqdm


Install
Expand Down Expand Up @@ -43,8 +44,3 @@ You want to test/test-coverage the code before to install::

$ make install-dev
$ make test-cov

Or::

$ make install-dev
$ pytest --cov=pymfe/ tests/
16 changes: 9 additions & 7 deletions docs/source/pages/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@

def meta_features_description():
"""Automatically create the meta-feature description file."""
data, _ = MFE.metafeature_description(sort_by_group=True,
sort_by_mtf=True,
print_table=False,
include_references=True)
data, _ = MFE.metafeature_description(
sort_by_group=True,
sort_by_mtf=True,
print_table=False,
include_references=True,
)

if not os.path.exists(AUTO_PAGES_PATH):
os.makedirs(AUTO_PAGES_PATH)
Expand All @@ -45,13 +47,13 @@ def meta_features_description():
del data[0]
df = pd.DataFrame(data, columns=col)

df.to_csv(AUTO_PAGES_PATH+"/meta_features_description.csv", index=False)
df.to_csv(AUTO_PAGES_PATH + "/meta_features_description.csv", index=False)

notes = NOTE_REL_SUB + "\n" + NOTE_OTHER_INFO

table_str = TABLE_CONF
f = open(AUTO_PAGES_PATH+"/meta_features_description.rst", "w")
f.write(TITLE + '\n' + table_str + '\n' + notes)
f = open(AUTO_PAGES_PATH + "/meta_features_description.rst", "w")
f.write(TITLE + "\n" + table_str + "\n" + notes)
f.close()


Expand Down
35 changes: 19 additions & 16 deletions docs/sphinxext/github_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
import sys
from functools import partial

REVISION_CMD = 'git rev-parse --short HEAD'
REVISION_CMD = "git rev-parse --short HEAD"


def _get_git_revision():
try:
revision = subprocess.check_output(REVISION_CMD.split()).strip()
except (subprocess.CalledProcessError, OSError):
print('Failed to execute git to get revision')
print("Failed to execute git to get revision")
return None
return revision.decode('utf-8')
return revision.decode("utf-8")


def _linkcode_resolve(domain, info, package, url_fmt, revision):
Expand All @@ -34,17 +34,17 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):

if revision is None:
return
if domain not in ('py', 'pyx'):
if domain not in ("py", "pyx"):
return
if not info.get('module') or not info.get('fullname'):
if not info.get("module") or not info.get("fullname"):
return

class_name = info['fullname'].split('.')[0]
class_name = info["fullname"].split(".")[0]
if type(class_name) != str:
# Python 2 only
class_name = class_name.encode('utf-8')
module = __import__(info['module'], fromlist=[class_name])
obj = attrgetter(info['fullname'])(module)
class_name = class_name.encode("utf-8")
module = __import__(info["module"], fromlist=[class_name])
obj = attrgetter(info["fullname"])(module)

try:
fn = inspect.getsourcefile(obj)
Expand All @@ -58,14 +58,16 @@ def _linkcode_resolve(domain, info, package, url_fmt, revision):
if not fn:
return

fn = os.path.relpath(fn,
start=os.path.dirname(__import__(package).__file__))
fn = os.path.relpath(
fn, start=os.path.dirname(__import__(package).__file__)
)
try:
lineno = inspect.getsourcelines(obj)[1]
except Exception:
lineno = ''
return url_fmt.format(revision=revision, package=package,
path=fn, lineno=lineno)
lineno = ""
return url_fmt.format(
revision=revision, package=package, path=fn, lineno=lineno
)


def make_linkcode_resolve(package, url_fmt):
Expand All @@ -77,5 +79,6 @@ def make_linkcode_resolve(package, url_fmt):
'{path}#L{lineno}')
"""
revision = _get_git_revision()
return partial(_linkcode_resolve, revision=revision, package=package,
url_fmt=url_fmt)
return partial(
_linkcode_resolve, revision=revision, package=package, url_fmt=url_fmt
)
6 changes: 3 additions & 3 deletions examples/01_introductory_examples/plot_pymfe_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#
# Extracting three information theoretical measures.

mfe = MFE(features=["attr_ent", "joint_ent"],
mfe = MFE(groups="all", features=["attr_ent", "joint_ent"],
summary=["median", "min", "max"])
mfe.fit(X, y)
ft = mfe.extract()
Expand All @@ -38,7 +38,7 @@
#
# Extracting two statistical measures.

mfe = MFE(features=["can_cor", "cor", "iq_range"],
mfe = MFE(groups="all", features=["can_cor", "cor", "iq_range"],
summary=["median", "min", "max"])
mfe.fit(X, y)
ft = mfe.extract()
Expand All @@ -51,7 +51,7 @@
#
# Extracting five measures.

mfe = MFE(features=["attr_ent", "joint_ent", "can_cor", "cor", "iq_range"],
mfe = MFE(groups="all", features=["attr_ent", "joint_ent", "can_cor", "cor", "iq_range"],
summary=["median", "min", "max"])
mfe.fit(X, y)
ft = mfe.extract()
Expand Down
Loading

0 comments on commit 9591de2

Please sign in to comment.