Main Utilities
This module provides utilities for processing and visualizing data related to sea creatures, insects, fossils, gyroids, artwork, and fish in the game Animal Crossing: New Horizons. It includes functions for plotting spawning calendars, filtering data, and finding the closest matches for user input.
Functions:
| Name | Description |
|---|---|
plot_spawning_calendar |
pd.DataFrame, title: str, filename: str) -> None: Creates a plot for the fish in a calendar style and saves it as an image. |
get_caught_fish |
list[str]) -> list[str]: Returns a list of caught fish names based on the input list of fish names. |
process_fish_data |
list[str] = None) -> tuple: Processes the fish data to separate caught and uncaught fish and returns relevant dataframes. |
filter_data |
list[str], filter_by: list[str]) -> list[str]: Filters the input list by removing items that match the filter list. |
get_closest_match |
str, threshold: int = 80) -> list[str]: Finds and returns the closest matches for the user input from the list of all fish names. |
get_problems |
list[str]) -> set[str]: Identifies and returns a set of fish names that are not present in the list of all fish names. |
plot_spawning_calendar(dataframe, title, filename)
Creates a plot for the fish in a calendar style and saves it as image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
The dataframe with the data for the plot. |
required |
title
|
str
|
The title of the plot. |
required |
filename
|
str
|
The filename of the saved image. |
required |
Returns:
| Type | Description |
|---|---|
None
|
This just creates the image files given the fish data. |
Source code in src/main.py
update_calendars(nh_df=NH_df, sh_df=SH_df)
Updates the calendar images based on the fish dataframes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nh_df
|
DataFrame
|
Northern hemisphere fish data. |
NH_df
|
sh_df
|
DataFrame
|
Southern hemisphere fish data. |
SH_df
|
Returns:
| Type | Description |
|---|---|
None
|
This just calls plot_spawning_calendar() for both hemispheres. |
Source code in src/main.py
get_caught_fish(fishes_caught)
Given a list of caught fish names, returns a list of valid fish names that have been caught, after filtering for other common items.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fishes_caught
|
list[str]
|
A list of strings representing the names of caught fish. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Valid fish names that have been caught. If the input list is empty or the first element is empty, returns an empty list. |
Source code in src/main.py
process_fish_data(input_fish_list=None)
Processes fish data to determine caught and uncaught fish, and returns dataframes for uncaught fish in the Northern Hemisphere (NH) and Southern Hemisphere (SH).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_fish_list
|
list
|
A list of fish names that have been caught. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
tuple(list, list, Dataframe, Dataframe)
|
|
Source code in src/main.py
filter_data(arr, filter_by)
Filters out elements from the input list arr that are present in the
filter_by list, ignoring case sensitivity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arr
|
list[str]
|
The list of strings to be filtered. |
required |
filter_by
|
list[str]
|
The list of strings to filter out from |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
A new list with elements from |
Source code in src/main.py
get_closest_match(user_in, threshold=80)
Finds the closest matching fish names to the user input. This function searches for fish names that closely match the provided user input string. It uses two methods to find matches: 1. Direct substring matching. 2. Fuzzy matching with a specified threshold.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
user_in
|
str
|
The input string provided by the user to search for matching fish names. |
required |
threshold
|
int
|
The minimum score for fuzzy matching to consider a match. Defaults to 80. |
80
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Fish names that closely match the user input. The list is determined based on the highest matching scores from either direct substring matching or fuzzy matching. |
Source code in src/main.py
get_problems(input_fish)
Identifies fish names in the input list that are not present in the predefined list of all fishes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_fish
|
list[str]
|
A list of fish names to be checked. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
Fish names that are not found in the predefined list of all fishes. |