Skip to content

Commit

Permalink
Moving to New NGLPy API (#30)
Browse files Browse the repository at this point in the history
* Critical Bug fix: Reversing edges on negated Morse complex built for Morse-Smale construction.
* Making things compatible with the uncertain branch of NGLPy
* Adding requirements file with pinned dependencies
* Removing 2.7 build and adding more modern pythons.
* Closes #27 and uses requirements file to generate prerequisite installations
* Bumping version number
* Updating to point to new NGL API and bumping major version of topopy since it will have a breaking API change as well
* Fixing deprecation warning
* Fixing tests
* Adding requirements.txt to the Manifest file
* Cleaning documentation
* Pinning to working version of nglpy installation.
* Documenting all public functions using numpy style docstrings.
* Adding linker arg for MacOS builds
* Disabling 3.5 due to use of f-strings
* Testing staging deploy script.
* Enabling flake and mypy checks on CI
  • Loading branch information
dmaljovec authored Nov 22, 2019
1 parent 21e2e3e commit be208a5
Show file tree
Hide file tree
Showing 24 changed files with 924 additions and 590 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@ topopy.egg-info/*
*.txt
*tar.gz
*.json
.coverage
.coverage

.ipynb_checkpoints
docs/_build

13 changes: 7 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@ language: python
addons:
apt_packages:
- swig
install: make && pip install coveralls
install: make && pip install coveralls mypy flake8 twine
python:
# - "3.2" # see https://github.com/travis-ci/travis-ci/issues/4866
# - "3.3"
# - "3.4"
- "3.5"
# - "3.5"
- "3.6"
- "3.7"
# - "3.8"
# - "nightly"
# PyPy versions commented out since scipy does not play well with pypy
# - "pypy2.7"
# - "pypy3.5"
# command to install dependencies
script: coverage run --source topopy setup.py test
# - "pypy3.6"
# - "pypy3.7"
# - "pypy3.8"
script:
- ". travis.sh"
after_success:
- coveralls
branches:
Expand Down
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ include *.h *.cpp
include *.md
include *.py
include LICENSE
include README.rst
include README.rst
include requirements.txt
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ Example Usage

::

import topopy
import nglpy as ngl
import numpy as np
import topopy

def hill(_x):
_x = np.atleast_2d(_x)
Expand All @@ -93,11 +94,11 @@ Example Usage

X = np.random.rand(100,2)
Y = hill(X)
graph = ngl.EmptyRegionGraph(beta=1.0, relaxed=False, p=2.0)

msc = topopy.MorseSmaleComplex(graph='beta skeleton',
msc = topopy.MorseSmaleComplex(graph=graph,
gradient='steepest',
normalization='feature',
connect=True)
normalization='feature')
msc.build(X, Y)
msc.get_partitions()

Expand Down
31 changes: 31 additions & 0 deletions deploy/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -e
set -x

# Append the version number with this git commit hash, but hashes contain
# letters which are not allowed in pypi versions. We can hack this to replace
# all letters with numbers, this should still be unique enough to not collide
# before the version number increases.
GIT_HASH=$(git rev-parse --short HEAD | tr 'abcdefghijklmnopqrstuvwxyz' '12345678901234567890123456')
awk -v hash=$GIT_HASH '/^__version__ = \"/{ sub(/"$/,".dev"hash"&") }1' topopy/__init__.py > tmp && mv tmp topopy/__init__.py
TEMP_VERSION=$(grep '__version__ = ' topopy/__init__.py | cut -d = -f 2 | sed "s/\"//g" | sed 's/^[ \t]*//;s/[ \t]*$//')
TEMP_VERSION=$(expr $TEMP_VERSION)
echo $TEMP_VERSION

# Build the project
make
python setup.py sdist

# Test the upload# Test the upload, temporarily disable exit on error, since there is a race
# condition for which build will get this out first, also, re-triggered builds
# would never succeed in this step.
set +e
twine upload --repository-url https://test.pypi.org/legacy/ -u __token__ -p ${PYPI_TOKEN} --non-interactive dist/topopy-${TEMP_VERSION}.tar.gz
set -e

#Give it some time to register internally before trying to install it
sleep 60

# Now install and run it
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple topopy==${TEMP_VERSION}
python -c "import topopy"
6 changes: 6 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
================================================================================
API Documentation
================================================================================

.. automodule:: topopy
:members:
25 changes: 21 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@
# 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.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
from mock import Mock
import os
import subprocess
import sys
sys.path.insert(0, os.path.abspath('..'))


# Mock things for readthedoc build
class MyMock(Mock):
@classmethod
def __getattr__(cls, name):
return MyMock()


MOCK_MODULES = ['_topology']
sys.modules.update((mod_name, MyMock()) for mod_name in MOCK_MODULES)

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

# If your documentation needs a minimal Sphinx version, state it here.
Expand All @@ -31,7 +43,9 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down Expand Up @@ -166,3 +180,6 @@
"Miscellaneous",
)
]

os.chdir('..')
subprocess.call('make')
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Welcome to topopy's documentation!

install.rst
usage.rst
api.rst
license.rst

Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ scipy>=1.3.2,<2.0
numpy>=1.17.4,<2.0
scikit-learn>=0.21.2,<1.0
networkx>=2.4,<3.0
nglpy>=0.0.2,<1.0
nglpy>=1.0.6,<2.0
25 changes: 24 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,25 @@
[metadata]
description-file = README.md
description-file = README.md

[flake8]
max-line-length = 120
exclude = topology.py
max-complexity = 15

[mypy-topopy.topology]
ignore_errors = True

[mypy-networkx.*]
ignore_missing_imports = True

[mypy-nglpy.*]
ignore_missing_imports = True

[mypy-numpy.*]
ignore_missing_imports = True

[mypy-scipy.*]
ignore_missing_imports = True

[mypy-sklearn.*]
ignore_missing_imports = True
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
requirements = open('requirements.txt').read().strip().split('\n')

extra_compile_args = ["-O3", "-march=native", ]
extra_link_args = []

if platform.system() == 'Darwin':
extra_compile_args.append('-stdlib=libc++')
extra_link_args.append('-stdlib=libc++')


def get_property(prop, project):
Expand Down Expand Up @@ -80,6 +83,7 @@ def get_property(prop, project):
ext_modules=[
Extension("_topology",
FILES,
extra_compile_args=extra_compile_args)
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args)
],
)
Loading

0 comments on commit be208a5

Please sign in to comment.