Skip to content

Commit

Permalink
Support numpy>=1.20.0 (#192)
Browse files Browse the repository at this point in the history
* Support numpy>=1.20.0

* Github actions
---------

Co-authored-by: ekzhu <[email protected]>
  • Loading branch information
joehalliwell and ekzhu authored Feb 19, 2023
1 parent 58b39e6 commit 1f70dac
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 91 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Documentation

on:
workflow_run:
workflows: ["Test", "Test Mongo", "Test Cassandra"]
types:
- completed
branches:
- master

jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
- name: Install package
run: |
# Disable Cassandra optional extensions (faster testing).
export CASS_DRIVER_NO_EXTENSIONS=1
pip install -e .
- name: Compile documentation
run: |
python -m pip install sphinx
cd docs
make html
- name: Deploy to GitHub pages
uses: JamesIves/github-pages-deploy-action@v4
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: docs/_build/html
CLEAN: true
33 changes: 16 additions & 17 deletions .github/workflows/python-publish.yml → .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@ permissions:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
70 changes: 0 additions & 70 deletions .github/workflows/python-package.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/test-cassandra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Test Cassandra

on:
workflow_run:
workflows:
- Test
types:
- completed

jobs:
build:
runs-on: "ubuntu-latest"
strategy:
matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.11"]
services:
cassandra:
image: cassandra
ports:
- 9042:9042
options: --health-cmd "cqlsh --debug" --health-interval 5s --health-retries 10
steps:
- uses: actions/checkout@v3
# - name: Setup Cassandra
# uses: fabasoad/[email protected]
# - name: Install and Start Cassandra
# run: |
# echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
# curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add -
# sudo apt-get update
# sudo apt-get install openjdk-8-jdk
# java -version
# sudo apt-get install cassandra cython3
# bash travis/wait_for_cassandra.sh
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install package
run: |
# Disable Cassandra optional extensions (faster testing).
export CASS_DRIVER_NO_EXTENSIONS=1
pip install -e .[test,experimental_aio]
- name: Test with pytest
run: |
export DO_TEST_CASSANDRA=true
pytest
42 changes: 42 additions & 0 deletions .github/workflows/test-mongo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Mongo

on:
workflow_run:
workflows:
- Test
types:
- completed

jobs:
build:
runs-on: "ubuntu-latest"
strategy:
matrix:
# python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.11"]
# services:
# mongo:
# image: mongo
# ports:
# - 27017:27017
steps:
- uses: actions/checkout@v3
- name: Setup MongoDB
uses: supercharge/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
- name: Install package
run: |
# Disable Cassandra optional extensions (faster testing).
export CASS_DRIVER_NO_EXTENSIONS=1
pip install -e .[test,experimental_aio]
- name: Test with pytest
run: |
export DO_TEST_MONGO=true
pytest
30 changes: 30 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Test

# Triggers the workflow on push or pull request events
on: [push, pull_request]

jobs:
build:
runs-on: "ubuntu-latest"
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install package
run: |
# Disable Cassandra optional extensions (faster testing).
export CASS_DRIVER_NO_EXTENSIONS=1
pip install -e .[test,experimental_aio]
- name: Test with pytest
run: |
pytest
8 changes: 4 additions & 4 deletions datasketch/lshensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class MinHashLSHEnsemble(object):
.. _`the paper`: http://www.vldb.org/pvldb/vol9/p1185-zhu.pdf
'''

def __init__(self, threshold=0.9, num_perm=128, num_part=16, m=8,
def __init__(self, threshold=0.9, num_perm=128, num_part=16, m=8,
weights=(0.5,0.5), storage_config=None, prepickle=None):
if threshold > 1.0 or threshold < 0.0:
raise ValueError("threshold must be in [0.0, 1.0]")
Expand Down Expand Up @@ -142,7 +142,7 @@ def _init_optimal_params(self, weights):
xq,
false_positive_weight,
false_negative_weight)
for xq in self.xqs], dtype=np.int)
for xq in self.xqs], dtype=int)
# Find all unique r
rs = set()
for _, r in self.params:
Expand All @@ -154,7 +154,7 @@ def _get_optimal_param(self, x, q):
if i == len(self.params):
i = i - 1
return self.params[i]

def _get_storage_config(self, basename, base_config, partition, r):
config = dict(base_config)
config["basename"] = b"-".join(
Expand Down Expand Up @@ -200,7 +200,7 @@ def index(self, entries):
curr_part += 1
for r in self.indexes[curr_part]:
self.indexes[curr_part][r].insert(key, minhash)

def query(self, minhash, size):
'''
Giving the MinHash and size of the query set, retrieve
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
'pymongo>=3.9.0',
'nose>=1.3.7',
'nose-exclude>=0.5.0',
'pytest',
],
'experimental_aio': [
"aiounittest ; python_version>='3.6'",
Expand Down

0 comments on commit 1f70dac

Please sign in to comment.