Skip to content

Commit

Permalink
Merge pull request #45 from founderswap/qa
Browse files Browse the repository at this point in the history
v0.2.0
  • Loading branch information
ggbaro authored Jan 13, 2024
2 parents 42346cd + 36b08b7 commit 70d7b34
Show file tree
Hide file tree
Showing 24 changed files with 612 additions and 545 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,10 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# macOS system files
.DS_Store

# macOS folder metadata
.Spotlight-V100
.Trashes
97 changes: 56 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,38 @@ The simplest way to test this library is to use the `swapanything` python
package to make a simple swapping exercise.

```python
from swapanything.backend import simple as backend
from swapanything.select import select_matches
from swapanything import prep, select
import pandas as pd

availabilities = [
["KungFury", "9:00"],
["KungFury", "10:00"],
["KungFury", "13:00"],
["KungFury", "14:00"],
["Triceracop", "9:00"],
["Triceracop", "11:00"],
["Hackerman", "10:00"],
["Hackerman", "11:00"],
["Katana", "12:00"],
["Barbarianna", "12:00"],
["Thor", "13:00"],
["Thor", "14:00"],
["Thor", "15:00"],
["T-Rex", "15:00"],
["T-Rex", "16:00"],
["Hoff 9000", "16:00"],
]

availabilities_df = pd.DataFrame(
availabilities, columns=["subject", "availability"]
availabilities = pd.DataFrame(
[
["KungFury", "9:00"],
["KungFury", "10:00"],
["KungFury", "13:00"],
["KungFury", "14:00"],
["Triceracop", "9:00"],
["Triceracop", "11:00"],
["Hackerman", "10:00"],
["Hackerman", "11:00"],
["Katana", "12:00"],
["Barbarianna", "12:00"],
["Thor", "13:00"],
["Thor", "14:00"],
["Thor", "15:00"],
["T-Rex", "15:00"],
["T-Rex", "16:00"],
["Hoff 9000", "16:00"],
],
columns=["subject", "availability"]
)

be = backend.SimpleBackend(
availabilities=availabilities_df,
availabilities_column="availability",
availability_subject_column="subject",
all_possible_matches = prep.get_all_matches(
availabilities,
subject_col="subject",
slot_col="availability",
subjects_new_col_name="subjects",
slots_new_col_name="availabilities",
)

all_possible_matches = be.get_all_matches()
# subject availability
# 0 (Barbarianna, Katana) (12:00,)
# 1 (Hackerman, KungFury) (10:00,)
Expand All @@ -71,13 +69,16 @@ all_possible_matches = be.get_all_matches()
# 5 (KungFury, Triceracop) (9:00,)
# 6 (T-Rex, Thor) (15:00,)

select_matches(all_possible_matches, backend=be)
# subject availability
select.select_matches(
all_possible_matches,
subjects_col="subjects",
slots_col="availabilities",
)
# subjects availabilities
# 0 (Barbarianna, Katana) (12:00,)
# 1 (Hackerman, Triceracop) (11:00,)
# 2 (Hoff 9000, T-Rex) (16:00,)
# 3 (KungFury, Thor) (13:00, 14:00)

```

Imagine now that we want to provide a super high importance
Expand All @@ -91,12 +92,16 @@ This way we ensure that high quality matches are selected.
```python
scores = [1, 1, 1, 1, 1, 9001, 1]
# (KungFury, Triceracop)... it's over 9000!
select_matches(all_possible_matches, backend=be, match_scores=scores)
select.select_matches(
all_possible_matches,
match_scores=scores,
subjects_col="subjects",
slots_col="availabilities",
)
# subject availability
# 0 (Barbarianna, Katana) (12:00,)
# 1 (KungFury, Triceracop) (9:00,)
# 2 (T-Rex, Thor) (15:00,)

```

### Advanced Backends
Expand All @@ -115,12 +120,12 @@ pip install swap-anything[airtable]
```

```python
from swapanything.backend import airtable
from swapanything.select import select_matches
from swapanything import prep, select
from swapanything_backend import airtable as backend
import os


airtable_backend = airtable.AirTableBackend(
be = backend.AirTableBackend(
# subject_id is the record id of the subjects table
subject_features=["Interests", "Tags", "Score1", "Score2"],
availability_subject_column="AvailabilitiesSubjectId",
Expand All @@ -135,11 +140,21 @@ airtable_backend = airtable.AirTableBackend(
client_secret=os.environ["AIRTABLE_API_KEY"],
)

subjects = airtable_backend.get_subjects()
availabilities = airtable_backend.get_availabilities()
subjects = be.get_subjects()
availabilities = be.get_availabilities()

all_matches = be.get_all_matches(exclusions=True)
selected = select_matches(matches, backend=airtable_backend)
all_possible_matches = prep.get_all_matches(
availabilities,
subject_col=be.availability_subject_column,
slot_col=be.availabilities_column,
subjects_new_col_name="subjects",
slots_new_col_name="availabilities",
)
select.select_matches(
all_possible_matches,
subjects_col="subjects",
slots_col="availabilities",
)
```

### Using CLI (POC)
Expand Down
3 changes: 0 additions & 3 deletions docs/API-reference/swapanything/backend/airtable.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/API-reference/swapanything/index.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/api-reference/swapanything/select.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# airtable
# swapanything.select

::: swapanything.select
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ hide:
# Swap Anything Docs

<div class="grid" markdown>
<img alt="swap-anything-logo" src="/static/founderswap-logo.jpg">
<img alt="swap-anything-logo" src="./static/founderswap-logo.jpg">
<div markdown>
# Welcome to Swap Anything!

Expand Down
44 changes: 31 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,44 +12,62 @@ dynamic = ["version"]
description = "A mix and match (swap) library to empower swapping-based projects."
authors = [
{ name = "@ggbaro", email = "46573388+ggbaro@users.noreply.github.com" },
{ name = "@CheckSim" },
{ name = "@LFK01" },
]
maintainers = [
{ name = "@ggbaro", email = "46573388+ggbaro@users.noreply.github.com" },
]
readme = "README.md"
requires-python = ">=3.11,<3.13"
requires-python = ">=3.10,<3.13"
keywords = []
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Internet",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Application Frameworks",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development",
"Topic :: Utilities",
"Typing :: Typed",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
]
license = { file = "LICENSE" }

dependencies = [
"pandas>=2,<3",
"pydantic>=2,<3",
"pandas>=1.5,<3",
"networkx>=3.1,<3.2",
"pydantic-settings",
"numpy>=1.21.0,<2",
]

[tool.setuptools_scm]

[project.optional-dependencies]
all = ["pyairtable>=1.5.0,<1.6"]
airtable = ["pyairtable>=1.5.0,<1.6"]
all = [
"pyairtable>=1.5.0,<1.6",
"pydantic>=2,<3",
"pydantic-settings",
]
backend = [
"pydantic>=2,<3",
"pydantic-settings",
]
airtable = [
"pyairtable>=1.5.0,<1.6",
"pydantic>=2,<3",
"pydantic-settings",
]
dev = ["black", "ruff", "pre-commit", "setuptools-scm"]
test = ["requests", "pytest", "pytest-cov", "Faker"]
docs = [
Expand Down
1 change: 0 additions & 1 deletion src/swapanything/backend/__init__.py

This file was deleted.

132 changes: 0 additions & 132 deletions src/swapanything/backend/_base.py

This file was deleted.

Loading

0 comments on commit 70d7b34

Please sign in to comment.