Skip to content

Commit

Permalink
Update packages and pipeline (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
matt035343 authored Sep 9, 2022
1 parent a417a37 commit bad54ac
Show file tree
Hide file tree
Showing 10 changed files with 347 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prepare_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: SneaksAndData/github-actions/[email protected].2
- uses: SneaksAndData/github-actions/[email protected].8
with:
major_v: 0
minor_v: 2
14 changes: 10 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9.x'
architecture: 'x64'
- name: Install Poetry and prepare version
- name: Install Poetry
uses: SneaksAndData/github-actions/[email protected]
with:
pypi_repo_url: ${{ secrets.AZOPS_PYPI_REPO_URL }}
pypi_token_username: ${{ secrets.AZOPS_PAT_USER }}
pypi_token: ${{ secrets.AZOPS_PAT }}
install_extras: "all"
skip_dependencies: true
- name: Prepare version
run: |
set -e
curl -sSL https://install.python-poetry.org | python3 - --preview
version=$(git describe --tags --abbrev=7)
sed -i "s/version = \"0.0.0\"/version = \"${version:1}\"/" pyproject.toml
echo "__version__ = '${version:1}'" > ./anti_clustering/_version.py
Expand Down
23 changes: 10 additions & 13 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,17 @@ jobs:
if: ${{ github.ref != 'refs/heads/main' }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.9.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
- name: Install Poetry
run: |
set -e
curl -sSL https://install.python-poetry.org | python3 - --preview
- name: Install Dependencies
run: |
set -e
poetry install
python-version: '3.9.x'
architecture: 'x64'
- name: Install Poetry and dependencies
uses: SneaksAndData/github-actions/[email protected]
with:
pypi_repo_url: ${{ secrets.AZOPS_PYPI_REPO_URL }}
pypi_token_username: ${{ secrets.AZOPS_PAT_USER }}
pypi_token: ${{ secrets.AZOPS_PAT }}
install_extras: "all"
- name: Lint
run: |
set -e
Expand Down
4 changes: 1 addition & 3 deletions anti_clustering/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def _solve(self, distance_matrix: npt.NDArray[float], num_groups: int) -> npt.ND
"""

def _prepare_data(self, df: pd.DataFrame, numerical_columns: List[str], categorical_columns: List[str]) -> pd.DataFrame:
# pylint: disable = R0201
"""
Prepare data for solving.
:param df: The input dataframe.
Expand Down Expand Up @@ -109,7 +108,7 @@ def _post_process(
destination_column: str,
cluster_assignment_matrix: npt.NDArray[bool]
) -> pd.DataFrame:
# pylint: disable = R0201, R0913
# pylint: disable = R0913
"""
Postprocess results and prepare for returning to caller.
:param df: The input dataframe.
Expand Down Expand Up @@ -144,7 +143,6 @@ def _get_distance_matrix(
numerical_columns: List[str],
categorical_columns: List[str]
) -> npt.NDArray[float]:
# pylint: disable = R0201
"""
Calculate distance matrix between each pair of elements. Numeric columns default to Euclidean distance and
categorical columns default to Hamming distance.
Expand Down
2 changes: 0 additions & 2 deletions anti_clustering/_cluster_swap_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __init__(self, verbose: bool = False, random_seed: int = None):
self.rnd = random.Random(random_seed)

def _get_exchanges(self, cluster_assignment: npt.NDArray[bool], i: int) -> npt.NDArray[int]:
# pylint: disable = R0201
"""
Given a cluster assignment matrix and element index, will return possible indexes to swap anti-clusters with.
:param cluster_assignment: Cluster assignment matrix.
Expand All @@ -38,7 +37,6 @@ def _get_exchanges(self, cluster_assignment: npt.NDArray[bool], i: int) -> npt.N
return np.nonzero(np.invert(cluster_assignment[i]))[0]

def _swap(self, cluster_assignment: npt.NDArray[bool], i: int, j: int) -> npt.NDArray[bool]:
# pylint: disable = R0201
"""
Swap anti-clusters of elements i and j.
:param cluster_assignment: Current cluster assignment.
Expand Down
2 changes: 1 addition & 1 deletion anti_clustering/exact_cluster_editing.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _add_constraint(
coeffs: List[float],
vars_: List[pywraplp.Variable]
) -> pywraplp.Constraint:
# pylint: disable = R0201, R0913
# pylint: disable = R0913
"""
Utility for adding constraints in the Google OR-Tools framework. Adds single constraint on the form:
lb <= c_1x_1 + c_2x_2 + ... <= ub
Expand Down
1 change: 0 additions & 1 deletion anti_clustering/exchange_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def _solve(self, distance_matrix: npt.NDArray[float], num_groups: int) -> npt.ND
return cluster_assignment

def _calculate_objective(self, cluster_assignment: npt.NDArray[bool], distance_matrix: npt.NDArray[float]) -> float:
# pylint: disable = R0201
"""
Calculate objective value
:param cluster_assignment: Cluster assignment matrix
Expand Down
1 change: 0 additions & 1 deletion anti_clustering/simulated_annealing_heuristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def _solve(self, distance_matrix: npt.NDArray[float], num_groups: int) -> npt.ND
return cluster_assignment

def _calculate_objective(self, cluster_assignment: npt.NDArray[bool], distance_matrix: npt.NDArray[float]) -> float:
# pylint: disable = R0201
"""
Calculate objective value
:param cluster_assignment: Cluster assignment
Expand Down
Loading

0 comments on commit bad54ac

Please sign in to comment.