Package: pyge
Python Gift Exchange PickerMy wife is in charge of our families' annual Secret Santa Gift Exchange. Because she, unfortunately, knows about my background in math and computer science her requirements have become more extreme. A hat containing folded pieces of paper with hand-written names is no longer sufficient. Python Gift Exchange Picker (pyge) is my third and best implementation of my wife's requirements:It must match each person to a different person.The match should not be in the same household.The match should not be the same gender.The match should not be in the same age group.The match must not happen again for at least three years.To accomplish this, pyge imports a list of participants along with their feature sets and transforms each participant's feature set into numerical values. Each value is then vectorized and a pairwise euclidean distance between each participant is computed; this can be represented as either a graph or a matrix - I chose a matrix. The distances are then multiplied by a per-participant "qualifier" coefficient and the results are used to build a weighted distribution. The pairs of participants are then randomly matched using the weighted distribution until either all participants have been matched or no matches can be made. If no matches can be made and there are still participants pyge will backtrack until all participants can be successfully matched or it is discovered that it is impossible to match the given set of participants.If you're interested, you can read a more detailed descriptionhere.InstallationpipinstallpygeBasic UsagePyge has only one required argument: the path to a csv file containing the people who are participating in the gift exchange. An example csv file,jazz.csvhas been provided.$pyge/path/to/jazz.csv
HerbieHancock,BillieHoliday
EllaFitzgerald,HerbieHancock
CharlieParker,NinaSimone
NinaSimone,BillEvans
MilesDavis,DukeEllington
JohnColtrane,SarahVaughan
SarahVaughan,LouisArmstrong
LouisArmstrong,EllaFitzgerald
BillieHoliday,CharlieParker
DukeEllington,JohnColtrane
DizzyGillespie,MilesDavis
BillEvans,DizzyGillespieInput CSV File Formatname, date of birth, sex, "city, state or province or territory"Any column containing a comma should be quoted with double-quotes, for example,"Austin, TX".TheDate of Birthfield is inMM/DD/YYYYformat.Sexcan beM,ForN.Cityby default only includes cities in the United States. SeeUsing Other Country Databasesfor more information on changing the country.Saving HistoryPyge saves a historical list of pairings which is used to ensure participants will not be paired for at a minimum of three exchanges. Saving history can be toggled with the--save-historyand--no-historyflags. The minimum number of exchanges can be modified with the--history-lengthargument.Using Other Country DatabasesYou can pass a different city weight database file by using the--citydbargument. The city weight database is a csv file in the following format:city, state or province or territory, normalized latitude, normalized longitudeWhere normalized latitude and longitude are the values normalized between -1 and +1 (divided by 180).Full Usageusage: pyge [-h] [-s] [-n] [-c citydb] [-l historylength] file

Generates a list of people pairings for a holiday gift exchange.

positional arguments:
  file                  path to the csv containing a list of people who want
                        to be part of the celebration

optional arguments:
  -h, --help            show this help message and exit
  -s, --save-history    save a history file of matches
  -n, --no-history      do not save a history file of matches
  -c citydb, --citydb citydb
                        path to city csv for distance calculations
  -l historylength, --history-length historylength
                        number of cycles before people can be paired againCities database provided byhttps://simplemaps.com/data/us-cities.