Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate the backend concept #35

Open
5 tasks done
ggbaro opened this issue Dec 24, 2023 · 0 comments
Open
5 tasks done

Eliminate the backend concept #35

ggbaro opened this issue Dec 24, 2023 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ggbaro
Copy link
Contributor

ggbaro commented Dec 24, 2023

The library design is moving away from the original API idea. Therefore, it would make sense to remove the backend entirely and replace it with general functions, something like:

def get_all_matches(
    availabilities: pd.DataFrame,
    subject_col: str,
    slot_col: str,
    subjects_new_col_name: Optional[str] = None,
    slots_new_col_name: Optional[str] = None,
) -> pd.DataFrame:
    ...

def select_matches(
    availabilities: pd.DataFrame,
    subjects_col: str,
    slots_col: str,
    match_scores: Optional[Iterable] = None,
) -> pd.DataFrame:
    ...

This way, we will have:

from swapanything import get_all_matches, select_matches
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"]
)

all_possible_matches = get_all_matches(
    availabilities_df, "subject", "availability", "subjects", "availabilities"
)
#                   subjects  availabilities
# 0    (Barbarianna, Katana)        (12:00,)
# 1    (Hackerman, KungFury)        (10:00,)
# 2  (Hackerman, Triceracop)        (11:00,)
# 3       (Hoff 9000, T-Rex)        (16:00,)
# 4         (KungFury, Thor)  (13:00, 14:00)
# 5   (KungFury, Triceracop)         (9:00,)
# 6            (T-Rex, Thor)        (15:00,)

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

Todo:

  • API
  • Tests
  • API Docs
  • Guide
  • README
@ggbaro ggbaro added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant