diff --git a/.github/workflows/python-build.yml b/.github/workflows/python-build.yml index c77fd7f..eeb48e0 100644 --- a/.github/workflows/python-build.yml +++ b/.github/workflows/python-build.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ 3.8, 3.9, "3.10", "3.11", "3.12" ] + python-version: [ 3.9, "3.10", "3.11", "3.12", "3.13" ] steps: - uses: actions/checkout@v2 @@ -19,7 +19,6 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install -q pipenv make install - name: Build run: | diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 4118803..186dde3 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -17,7 +17,6 @@ jobs: - name: Install build dependencies run: | python -m pip install --upgrade pip - python -m pip install -q pipenv make install - name: Build run: | diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8152d9b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -dist: xenial -language: python -script: - - 'make $TEST' -install: - - pip3 install -q pipenv - - make install - - make compile -matrix: - fast_finish: true - allow_failures: - - env: TEST='test' - python: 'nightly' - include: - - env: TEST='lint' - python: '3.7' - - env: TEST='coverage' - python: '3.7' - - env: TEST='test' - python: '3.7' - - env: TEST='test' - python: '3.8' - - env: TEST='test' - python: '3.9' - - env: TEST='test' - python: 'nightly' -after_success: coveralls diff --git a/Pipfile b/Pipfile deleted file mode 100644 index 3267331..0000000 --- a/Pipfile +++ /dev/null @@ -1,18 +0,0 @@ -[[source]] -name = "pypi" -url = "https://pypi.org/simple" -verify_ssl = true - -[dev-packages] -pytest = "==7.4.0" -pylint = "==2.17.5" -pytest-cov = "==4.1.0" -twine = "==4.0.2" -setuptools = "==68.0.0" -cython = "==3.0.0" - -[packages] -wheel = ">=0.43.0,<0.44" -pandas = ">=2.0,<3.0" -numpy = ">=1.24,<2.0" -scipy = ">=1.10.0" diff --git a/association_measures/comparisons.py b/association_measures/comparisons.py new file mode 100644 index 0000000..d4760d2 --- /dev/null +++ b/association_measures/comparisons.py @@ -0,0 +1,17 @@ +""" +comparison of ranked lists + +""" + + +# from rbo import RankingSimilarity + + +# def compare_rbo(df1, df2, p): + +# return RankingSimilarity(df1.index, df2.index).rbo(p=p) + + +# def compare_gwets_ac1(df1, df2): + +# pass diff --git a/association_measures/resources/measures.tsv b/association_measures/resources/measures.tsv new file mode 100644 index 0000000..a28812b --- /dev/null +++ b/association_measures/resources/measures.tsv @@ -0,0 +1,18 @@ +association_measures name abbreviation category +O11 observed frequency obs. raw +E11 expected frequency exp. raw +ipm observed instances per million obs. (ipm) raw +ipm_expected expected instances per million exp. (ipm) raw +conservative_log_ratio Conservative Log Ratio LRC conservative estimates +log_likelihood Log-Likelihood Ratio LLR asymptotic hypothesis tests +z_score z-score z-score asymptotic hypothesis tests +t_score t-score t-score asymptotic hypothesis tests +simple_LL simple Log-Likelihood Ratio simple LLR asymptotic hypothesis tests +dice Dice Dice point estimates of association strength +log_ratio Log Ratio LR point estimates of association strength +min_sensitivity Minimum Sensitivity MS point estimates of association strength +liddel Liddell Liddell point estimates of association strength +mutual_information Mutual Information MI information theory +local_mutual_information Local Mutual Information LMI information theory +hypergeometric_likelihood Hypergeometric Likelihood HL likelihood measures +binomial_likelihood Binomial Likelihood BL likelihood measures diff --git a/association_measures/version.py b/association_measures/version.py index bd4c933..598c70c 100644 --- a/association_measures/version.py +++ b/association_measures/version.py @@ -2,5 +2,5 @@ Association measures are mathematical formulae that interpret cooccurrence frequency data. """ -VERSION = (0, 3, 0) +VERSION = (0, 3, 1) __version__ = '.'.join(map(str, VERSION)) diff --git a/makefile b/makefile index 7deb16f..de73d17 100644 --- a/makefile +++ b/makefile @@ -1,18 +1,34 @@ .PHONY: performance test lint coverage build install: - pipenv install --dev -performance: - pipenv run python3 performance.py -test: - pipenv run pytest -v + python3 -m venv venv && \ + . venv/bin/activate && \ + pip3 install -U pip setuptools wheel && \ + pip3 install -r requirements-dev.txt + lint: - pipenv run pylint --rcfile=.pylintrc association_measures/*.py + . venv/bin/activate && \ + pylint --rcfile=.pylintrc association_measures/*.py + +test: + . venv/bin/activate && \ + pytest -s -v + +performance: + . venv/bin/activate && \ + python3 performance.py + coverage: - pipenv run pytest --cov-report term-missing -v --cov=association_measures/ + . venv/bin/activate && \ + pytest --cov-report term-missing -v --cov=association_measures/ + compile: - pipenv run python3 setup.py build_ext --inplace + . venv/bin/activate && \ + python3 setup.py build_ext --inplace + build: - pipenv run python3 setup.py sdist + . venv/bin/activate && \ + python3 setup.py sdist + clean: rm -rf *.egg-info build/ association_measures/*.so association_measures/*.c dist/ diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..d883269 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,8 @@ +-r requirements.txt +pytest==7.4.0 +pylint==2.17.5 +pytest-cov==4.1.0 +wheel==0.45.1 +twine==6.1.0 +setuptools==75.8.2 +cython==3.0.12 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c92b03d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +pandas>=2.2.2,<3.0 +numpy>=2.0,<3.0 +scipy>=1.13.0,<2.0 diff --git a/setup.py b/setup.py index d3e449c..fe7efb7 100644 --- a/setup.py +++ b/setup.py @@ -11,11 +11,13 @@ EMAIL = 'philipp.heinrich@fau.de' AUTHOR = 'Philipp Heinrich & Markus Opolka' -REQUIRES_PYTHON = '>=3.8' +REQUIRES_PYTHON = '>=3.9' REQUIRED = [ 'wheel', - 'pandas', - 'scipy' + 'pandas>=2.2.2,<3.0', + 'numpy>=2.0,<3.0', + 'scipy>=1.13.0,<2.0', + # 'rbo>=0.1.3,<0.2' ] here = os.path.abspath(os.path.dirname(__file__)) @@ -97,11 +99,11 @@ def run(self): 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Cython', ], ) diff --git a/tests/test_nas.py b/tests/test_nas.py new file mode 100644 index 0000000..787784b --- /dev/null +++ b/tests/test_nas.py @@ -0,0 +1,13 @@ +import association_measures.measures as am +from pandas import DataFrame + + +def test_nas(): + + d = DataFrame(data={'O11': 0, 'O12': 10, 'O21': 10, 'O22': 100}, index=['test']) + scores = am.score(d) + print(scores[['mutual_information', 'local_mutual_information']]) + + d = DataFrame(data={'O11': 0, 'O12': 10, 'O21': 0, 'O22': 100}, index=['test']) + scores = am.score(d) + print(scores[['ipm', 'ipm_expected']])