Skip to content

Commit

Permalink
Merge tag '3.36.1' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozGodec committed Sep 22, 2023
2 parents 07eadf7 + 8ba3cd6 commit a309db8
Show file tree
Hide file tree
Showing 27 changed files with 731 additions and 345 deletions.
138 changes: 138 additions & 0 deletions .github/workflows/build-wheels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Build

on:
release:
types: [published]
# Enable manual run
workflow_dispatch:

jobs:
generate-wheels-matrix:
# Create a matrix of all architectures & versions to build.
# This enables the next step to run cibuildwheel in parallel.
# From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210
name: Generate wheels matrix
runs-on: ubuntu-latest
outputs:
include: ${{ steps.set-matrix.outputs.include }}
steps:
- uses: actions/checkout@v3
- name: Install cibuildwheel
# Nb. keep cibuildwheel version pin consistent with job below
run: pipx install cibuildwheel==2.14.1
- id: set-matrix
run: |
MATRIX=$(
{
cibuildwheel --print-build-identifiers --platform linux \
| jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \
&& cibuildwheel --print-build-identifiers --platform macos \
| jq -nRc '{"only": inputs, "os": "macos-latest"}' \
&& cibuildwheel --print-build-identifiers --platform windows \
| jq -nRc '{"only": inputs, "os": "windows-latest"}'
} | jq -sc
)
echo "include=$MATRIX" >> $GITHUB_OUTPUT
build_wheels:
name: Build wheels on ${{ matrix.only }}
needs: generate-wheels-matrix
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }}

steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v2
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.15.0
with:
only: ${{ matrix.only }}

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
name: Orange3-wheels

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4

- name: Build sdist (pep517)
run: |
python -m pip install pep517 numpy cython
python -m pep517.build -s .
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: Orange3-source
path: dist/*.tar.gz

upload_release_assets:
name: Upload Release Assets
needs: [ build_wheels ]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags')

steps:
- name: Download bdist files
id: download_artifact
uses: actions/download-artifact@v2
with:
name: Orange3-wheels
path: ~/downloads

- name: List downloaded artifacts
run: ls -la ~/downloads

- name: Upload to release
uses: shogo82148/actions-upload-release-asset@v1.2.3
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.download_artifact.outputs.download-path }}/*.whl

pypi_publish:
name: PyPI Publish
needs: [ build_wheels, build_sdist ]
runs-on: ubuntu-latest
permissions:
id-token: write # this permission is mandatory for trusted publishing
if: startsWith(github.ref, 'refs/tags')

steps:
- name: Download bdist files
uses: actions/download-artifact@v2
with:
name: Orange3-wheels
path: downloads/

- name: Download sdist files
uses: actions/download-artifact@v2
with:
name: Orange3-source
path: downloads/

- name: Display structure of downloaded files
run: ls -R downloads/

- name: Publish packages to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages_dir: downloads/
4 changes: 0 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies on MacOS
run: brew install libomp
if: runner.os == 'macOS'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ Change Log
[next] - TBA
------------

[3.36.1] - 2023-09-22
--------------------
##### Bugfixes
* Distributions: Fix selection output ([#6578](../../pull/6578))
* Datasets: save selected dataset platform independently ([#6575](../../pull/6575))


[3.36.0] - 2023-09-08
--------------------
##### Enhancements
Expand Down Expand Up @@ -1822,7 +1829,8 @@ Change Log
* Initial version based on Python 1.5.2 and Qt 2.3


[next]: https://github.com/biolab/orange3/compare/3.35.0..HEAD
[next]: https://github.com/biolab/orange3/compare/3.36.1..HEAD
[3.36.1]: https://github.com/biolab/orange3/compare/3.36.0...3.36.1
[3.36.0]: https://github.com/biolab/orange3/compare/3.35.0...3.36.0
[3.35.0]: https://github.com/biolab/orange3/compare/3.34.1...3.35.0
[3.34.1]: https://github.com/biolab/orange3/compare/3.34.0...3.34.1
Expand Down
17 changes: 12 additions & 5 deletions Orange/projection/freeviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FreeViz(LinearProjector):
projection = FreeVizModel

def __init__(self, weights=None, center=True, scale=True, dim=2, p=1,
initial=None, maxiter=500, alpha=0.1,
initial=None, maxiter=500, alpha=0.1, gravity=None,
atol=1e-5, preprocessors=None):
super().__init__(preprocessors=preprocessors)
self.weights = weights
Expand All @@ -33,6 +33,7 @@ def __init__(self, weights=None, center=True, scale=True, dim=2, p=1,
self.maxiter = maxiter
self.alpha = alpha
self.atol = atol
self.gravity = gravity
self.is_class_discrete = False
self.components_ = None

Expand All @@ -50,6 +51,7 @@ def get_components(self, X, Y):
X, Y, weights=self.weights, center=self.center, scale=self.scale,
dim=self.dim, p=self.p, initial=self.initial,
maxiter=self.maxiter, alpha=self.alpha, atol=self.atol,
gravity=self.gravity,
is_class_discrete=self.is_class_discrete)[1].T

@classmethod
Expand Down Expand Up @@ -104,7 +106,7 @@ def forces_regression(cls, distances, y, p=1):
return F

@classmethod
def forces_classification(cls, distances, y, p=1):
def forces_classification(cls, distances, y, p=1, gravity=None):
diffclass = scipy.spatial.distance.pdist(y.reshape(-1, 1), "hamming") != 0
# handle attractive force
if p == 1:
Expand All @@ -120,6 +122,8 @@ def forces_classification(cls, distances, y, p=1):
F[mask] = 1 / distances[mask]
else:
F[mask] = 1 / (distances[mask] ** p)
if gravity is not None:
F[mask] *= -np.sum(F[~mask]) / np.sum(F[mask]) / gravity
return F

@classmethod
Expand Down Expand Up @@ -180,7 +184,8 @@ def gradient(cls, X, embeddings, forces, embedding_dist=None, weights=None):
return G

@classmethod
def freeviz_gradient(cls, X, y, embedding, p=1, weights=None, is_class_discrete=False):
def freeviz_gradient(cls, X, y, embedding, p=1, weights=None,
gravity=None, is_class_discrete=False):
"""
Return the gradient for the FreeViz [1]_ projection.
Expand Down Expand Up @@ -214,7 +219,7 @@ def freeviz_gradient(cls, X, y, embedding, p=1, weights=None, is_class_discrete=
assert X.ndim == 2 and X.shape[0] == y.shape[0] == embedding.shape[0]
D = scipy.spatial.distance.pdist(embedding)
if is_class_discrete:
forces = cls.forces_classification(D, y, p=p)
forces = cls.forces_classification(D, y, p=p, gravity=gravity)
else:
forces = cls.forces_regression(D, y, p=p)
G = cls.gradient(X, embedding, forces, embedding_dist=D, weights=weights)
Expand All @@ -234,7 +239,8 @@ def _rotate(cls, A):

@classmethod
def freeviz(cls, X, y, weights=None, center=True, scale=True, dim=2, p=1,
initial=None, maxiter=500, alpha=0.1, atol=1e-5, is_class_discrete=False):
initial=None, maxiter=500, alpha=0.1, atol=1e-5, gravity=None,
is_class_discrete=False):
"""
FreeViz
Expand Down Expand Up @@ -341,6 +347,7 @@ def freeviz(cls, X, y, weights=None, center=True, scale=True, dim=2, p=1,
step_i = 0
while step_i < maxiter:
G = cls.freeviz_gradient(X, y, embeddings, p=p, weights=weights,
gravity=gravity,
is_class_discrete=is_class_discrete)

# Scale the changes (the largest anchor move is alpha * radius)
Expand Down
Binary file removed Orange/tests/datasets/binary-blob.tab
Binary file not shown.

0 comments on commit a309db8

Please sign in to comment.