Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #16 from czbiohub/pranathi-gh
Browse files Browse the repository at this point in the history
add github actions
  • Loading branch information
pranathivemuri authored Jul 24, 2021
2 parents cd952b2 + 393149f commit afe5d36
Show file tree
Hide file tree
Showing 14 changed files with 207 additions and 123 deletions.
11 changes: 11 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Many thanks to contributing to czbiohub/xicor!

Please fill in the appropriate checklist below (delete whatever is not relevant). These are the most common things requested on pull requests (PRs).

## PR checklist
- [ ] This comment contains a description of changes (with reason)
- [ ] If you've fixed a bug or added code that should be tested, add tests!
- [ ] Ensure the test suite passes with [pytest](https://docs.pytest.org/en/latest/) . (command to run: `pytest` or `make coverage` if you want to see which lines don't have tests yet)
- [ ] Make sure your code is linted and autoformatted using [black](https://github.com/psf/black) (`black . --check`).
- [ ] Documentation in `usage.md` is updated
- [ ] `README.md` is updated
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Pytest
# This workflow is triggered on pushes and PRs to the repository.
# It runs the pipeline with the minimal test dataset to check that it completes without any syntax errors
on: [push, pull_request]

jobs:
test:
env:
NXF_VER: ${{ matrix.nxf_ver }}
NXF_ANSI_LOG: false
runs-on: ubuntu-latest
strategy:
matrix:
# Nextflow versions: check pipeline minimum and current latest
python-version: ['3.5']
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
steps:
- uses: actions/checkout@v2
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
- name: Install Dependencies with Python ${{ matrix.python-version }}
shell: bash -l {0}
run: |
conda env create -n testenv --file environment.yml
conda activate testenv
pip install .
- name: Run tests with coverage
shell: bash -l {0}
run: |
conda activate testenv
pip install -r requirements.txt
make coverage
- name: Send coverage to codecov.io
shell: bash -l {0}
run: |
pip install codecov
bash <(curl -s https://codecov.io/bash)
21 changes: 21 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# black code formatter github action: https://github.com/marketplace/actions/black-code-formatter

name: Linting

on:
push:
pull_request:
release:
types: [published]

jobs:
check_formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: black
uses: psf/black@stable
with:
args: ". --check"
31 changes: 31 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package to PyPI

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@ channels:
- r
- defaults
dependencies:
- flake8
- pandas
- pytest-cov
- seaborn
- numpy
- scipy
- ipykernel
- pip:
- xicor
prefix: /Users/olgabot/opt/anaconda3/envs/xicor
2 changes: 1 addition & 1 deletion release.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ deactivate
source bin/activate
pip install -U setuptools
# install as much as possible from non-test server!
pip install pytest pytest-cov scipy numpy flake8
pip install pytest pytest-cov scipy numpy
pip install -i https://test.pypi.org/simple --pre xicor
```
5\. Do any final testing:
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.4.1
pytest
pytest-cov
numpy
flake8
black
32 changes: 14 additions & 18 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import setuptools

with open('README.md') as readme_file:
with open("README.md") as readme_file:
readme = readme_file.read()

with open('HISTORY.md') as history_file:
history = history_file.read().replace('.. :changelog:', '')
with open("HISTORY.md") as history_file:
history = history_file.read().replace(".. :changelog:", "")

with open('requirements.txt') as requirements_file:
with open("requirements.txt") as requirements_file:
requirements = requirements_file.read()

test_requirements = [
'pytest', 'coverage', "pytest-cov"
]
test_requirements = ["pytest", "coverage", "pytest-cov"]


setuptools.setup(
Expand All @@ -25,25 +23,23 @@
long_description_content_type="text/markdown",
url="https://github.com/czbiohub/xicor/",
packages=setuptools.find_packages(
exclude=[
"tests",
"*.tests",
"*.tests.*",
"tests.*",
"test_*"]),
exclude=["tests", "*.tests", "*.tests.*", "tests.*", "test_*"]
),
include_package_data=True,
install_requires=requirements,
setup_requires=[
"setuptools>=38.6.0", "setuptools_scm", 'setuptools_scm_git_archive'],
"setuptools>=38.6.0",
"setuptools_scm",
"setuptools_scm_git_archive",
],
license="MIT",
zip_safe=False,
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
use_scm_version={
'write_to': 'xicor/version.py'},
test_suite='tests',
extras_require={'test': test_requirements}
use_scm_version={"write_to": "xicor/version.py"},
test_suite="tests",
extras_require={"test": test_requirements},
)
15 changes: 3 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,10 @@ def anscombes_quartet():
"x_2": [10, 8, 13, 9, 11, 14, 6, 4, 12, 7, 5],
"x_3": [0, 0, 0, 0, 1, 1, 2, 3],
"x_4": [8, 8, 8, 8, 8, 8, 8, 19, 8, 8, 8],
"y_1": [
8.04, 6.95, 7.58, 8.81, 8.33,
9.96, 7.24, 4.26, 10.84, 4.82, 5.68
],
"y_2": [
9.14, 8.14, 8.74, 8.77, 9.26, 8.1,
6.13, 3.1, 9.13, 7.26, 4.74
],
"y_1": [8.04, 6.95, 7.58, 8.81, 8.33, 9.96, 7.24, 4.26, 10.84, 4.82, 5.68],
"y_2": [9.14, 8.14, 8.74, 8.77, 9.26, 8.1, 6.13, 3.1, 9.13, 7.26, 4.74],
"y_3": [0, 1, 2, 3, 4, 5, 6, 7],
"y_4": [
6.58, 5.76, 7.71, 8.84,
8.47, 7.04, 5.25, 12.5, 5.56, 7.91, 6.89
]
"y_4": [6.58, 5.76, 7.71, 8.84, 8.47, 7.04, 5.25, 12.5, 5.56, 7.91, 6.89],
}

return anscombes_quartet
28 changes: 18 additions & 10 deletions tests/xi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from xicor.xicor import Xi

'''
"""
From Wikipedia:
Anscombe's quartet comprises four data sets that have nearly
identical simple descriptive statistics, yet have very different distributions
Expand All @@ -13,7 +13,7 @@
statistician Francis Anscombe to demonstrate both the importance of graphing
data before analyzing it and the effect of outliers and other influential
observations on statistical properties.
'''
"""


@pytest.fixture
Expand Down Expand Up @@ -43,11 +43,19 @@ def test_p_val_asymptotic(anscombes_xis):
random.seed(2020)
np.random.seed(2020)
# values taken from R code
assert anscombes_xis["xi_1"].pval_asymptotic(
ties=False, nperm=1000) == 0.07841556446646347
assert anscombes_xis["xi_2"].pval_asymptotic(
ties=False, nperm=1000) == 0.0010040217037570187
assert anscombes_xis["xi_3"].pval_asymptotic(
ties=False, nperm=1000) == 0.04989192742513937
assert anscombes_xis["xi_4"].pval_asymptotic(
ties=False, nperm=1000) == 0.2599336349448975
assert (
anscombes_xis["xi_1"].pval_asymptotic(ties=False, nperm=1000)
== 0.07841556446646347
)
assert (
anscombes_xis["xi_2"].pval_asymptotic(ties=False, nperm=1000)
== 0.0010040217037570187
)
assert (
anscombes_xis["xi_3"].pval_asymptotic(ties=False, nperm=1000)
== 0.04989192742513937
)
assert (
anscombes_xis["xi_4"].pval_asymptotic(ties=False, nperm=1000)
== 0.2599336349448975
)
18 changes: 9 additions & 9 deletions xicor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from pkg_resources import get_distribution, DistributionNotFound


__version__ = '0.1.0dev0'
__version__ = "0.1.0dev0"


__title__ = 'xicor'
__description__ = 'xi correlation for tied data'
__uri__ = 'https://github.com/czbiohub/xicor'
__doc__ = __description__ + ' <' + __uri__ + '>'
__title__ = "xicor"
__description__ = "xi correlation for tied data"
__uri__ = "https://github.com/czbiohub/xicor"
__doc__ = __description__ + " <" + __uri__ + ">"

__author__ = 'Phoenix Logan'
__email__ = '[email protected]'
__author__ = "Phoenix Logan"
__email__ = "[email protected]"

__license__ = 'MIT License'
__copyright__ = 'Copyright (c) 2020 Chan Zuckerberg Biohub'
__license__ = "MIT License"
__copyright__ = "Copyright (c) 2020 Chan Zuckerberg Biohub"


try:
Expand Down
Loading

0 comments on commit afe5d36

Please sign in to comment.