Skip to content

Commit

Permalink
Merge branch 'main' into bug/timeseries-lens-settings-icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen Slavetinsky committed Oct 19, 2023
2 parents 4301d92 + 22b30df commit 95f3623
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-poetry/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
python-version: ${{ inputs.python-version }}
- name: Install dependencies
if: inputs.install-dependencies != 'false' && steps.setup-python-with-cache.outputs.cache-hit != 'true'
run: poetry install --sync --without playbook --no-interaction
run: poetry install --sync --all-extras --without playbook --no-interaction
shell: bash
- name: Get Spotlight version
id: get-package-version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ jobs:
run: python -m pip install --upgrade pip setuptools wheel
- name: Install Spotlight
id: setup
run: python -m pip install --find-links build/dist/ renumics-spotlight==${{ needs.prepare-python.outputs.version }}
run: python -m pip install --find-links build/dist/ renumics-spotlight[all]==${{ needs.prepare-python.outputs.version }}
- name: Test Spotlight start (Windows)
if: runner.os == 'Windows' && (success() || steps.setup.outcome == 'success')
run: ./scripts/Test-SpotlightStart.ps1
Expand Down
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contribute to Spotlight

Everyone is welcome to contribute, and we value everybody's contribution. Code
contributions are not the only way to help the community.
Reported bugs, suggested features, contributing design ideas,
or offering feedback are alse extremely valuable to us.

Technical details on how to contribute can be found in our [documentation](https://renumics.com/docs/development).

## Ways to contribute

There are several ways you can contribute to Spotlight:

* Fix outstanding issues.
* Implement new features.
* Submit issues related to bugs or desired new features.
* Share your use case

If you don't know where to start, you might want to have a look at [hacktoberfest issues](https://github.com/Renumics/spotlight/issues?q=is%3Aissue+is%3Aopen+label%3Ahacktoberfest)
and our guide on how to create a [new Lens](https://renumics.com/docs/development/lenses).
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ help: ## Print this help message

.PHONY: init
init: ## Locally install all dev dependencies
poetry install --without playbook
poetry install --all-extras --without playbook
pnpm install

.PHONY: init-playbook
init-playbook: ## Locally install all playbook dev dependencies
poetry install
poetry install --all-extras

.PHONY: clean
clean: ## clean project
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,11 @@ We have added crash report and perfomance collection. We do NOT collect user dat
- 🤗 [Huggingface](https://huggingface.co/renumics) example spaces and datasets
- 🏀 [Playbook](https://renumics.com/docs/playbook/) for data-centric AI workflows
- 🍰 [Sliceguard](https://github.com/Renumics/sliceguard) library for automatic slice detection

## Contribute

We are currently participating in the running [Hacktoberfest 2023](https://hacktoberfest.com/).

If you would like to contribute to Spotlight, the easiest way is to have a look at our [Contribution Docs](https://renumics.com/docs/development) and the [CONTRIBUTING.md](./CONTRIBUTING.md).

We are also equally happy about non-code contributions -- whether it's reporting bugs, suggesting features, contributing design ideas, or offering feedback, every non-code contribution is highly valued and helps make our project better for everyone.
85 changes: 82 additions & 3 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ imagecodecs = [
av = "*"
validators = "*"
ipywidgets = "*"
pycatch22 = "*"
jinja2 = "*"
toml = "*"
cleanlab = "*"
Expand All @@ -89,6 +88,12 @@ pillow = "^10.0.0"
httpx = "^0.23.0"
datasets = {extras = ["audio"], version = "^2.12.0"}

pycatch22 = {version = "!=0.4.4", optional = true}

[tool.poetry.extras]
descriptors = ["pycatch22"]
all = ["pycatch22"]

[tool.poetry.group.dev.dependencies]
mypy = "*"
types-setuptools = "^57.4.14"
Expand Down
20 changes: 9 additions & 11 deletions renumics/spotlight/dataset/descriptors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""make descriptor methods more available
"""
from typing import List, Optional, Tuple
from typing import Optional, Tuple

import numpy as np
import pycatch22
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
from renumics.spotlight import dtypes
Expand Down Expand Up @@ -53,14 +52,6 @@ def pca(
return embeddings, mask


def get_catch22_feature_names(catch24: bool = False) -> List[str]:
"""
Get Catch22 feature names in the same order as returned by :func:`catch22`.
"""
# Run Catch22 with dummy data to get feature names.
return pycatch22.catch22_all([0], catch24)["names"]


def catch22(
dataset: Dataset,
column: str,
Expand All @@ -74,6 +65,12 @@ def catch22(
Generate Catch22 embeddings for the given column of a dataset and
optionally write them back into dataset.
"""
try:
import pycatch22
except ModuleNotFoundError as e:
raise RuntimeError(
"Install Spotlight with 'descriptors' extras in order to use `catch22`."
) from e

if suffix is None:
suffix = "catch24" if catch24 else "catch22"
Expand All @@ -86,7 +83,8 @@ def catch22(

column_names = []
if as_float_columns:
for name in get_catch22_feature_names(catch24):
feature_names = pycatch22.catch22_all([0], catch24)["names"]
for name in feature_names:
column_names.append("-".join((column, suffix, name)))
else:
column_names.append(f"{column}-{suffix}")
Expand Down
5 changes: 1 addition & 4 deletions tests/integration/dataset/test_descriptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from renumics.spotlight import Dataset
from renumics.spotlight.dataset.descriptors import pca
from renumics.spotlight.dataset.descriptors import catch22, get_catch22_feature_names
from renumics.spotlight.dataset.descriptors import catch22


class TestPCA:
Expand Down Expand Up @@ -293,9 +293,6 @@ def test_sequence_float_columns(self, descriptors_dataset: Dataset) -> None:
as_float_columns=True,
inplace=True,
)
for prename in get_catch22_feature_names():
name = "sequence_1d_extended-catch22-" + prename
assert name in descriptors_dataset.keys()

def test_sequence_nan(self, descriptors_dataset: Dataset) -> None:
"""
Expand Down

0 comments on commit 95f3623

Please sign in to comment.