08 August 2015

Merge upstream into your fork in GitHub

[Update: 12 August 2015: it is now possible to do this much more easily in the Beta version of GitHub Desktop]

For years I’ve been trying to get student assistants to use GitHub more effectively to work on larger projects.  One of the main problems though has been that the process of using forks + pull requests to submit their code to the main project has always required going back to the terminal for one key step: pulling and merging others’ changes from the upstream branches.  Today even for many seasoned programmers, the terminal/command prompt is a bit of a mystery to students.  Thus it would be great if the GitHub graphical client made this simple or at least possible.

The most recent versions of the GitHub client (at least on Mac; untested on Windows; I’m on v. 208) don’t exactly make the process simple, but at least they make it possible.

Open the GitHub client and if you haven’t worked on the project in a while, hit Sync. You should see your own fork; I’ll assume that you are working on the “master” branch and want to merge changes from the upstream (main project) master branch into your own branch.

Your screen should look something like this.  (I’ll be demoing on the amazing Latin dictionary program “whitakers-words”[*] which I do not have commit access on, so it’s like what my contributors to my projects would see).  All I’ve done is created a little demo text file.
Screen Shot 2015 08 08 at 16 18 50
Next I’ll pull down the tab on “master” and switch to the main developer’s master, “mk270/master” (third from bottom).
Screen Shot 2015 08 08 at 16 19 13
Screen Shot 2015 08 08 at 16 19 21
Click “Sync” in the upper left hand corner to copy it down.  The sync button will turn into a progress bar:
Screen Shot 2015 08 08 at 16 19 38
This actually creates a temporary branch confusingly called mscuthbert/mk270/master (or YOURNAME/THEIRNAME/BRANCH) but will just be displayed as mk270/master on the GitHub client.  No matter.  Now click the button next to the progress bar to create a pull request.  You will want to pull from this branch to your master branch (the one marked default branch):
Screen Shot 2015 08 08 at 16 20 07
Screen Shot 2015 08 08 at 16 20 18
You can leave the description blank since you’re just making a pull request to yourself. Go ahead and click “Send Pull Request”.
Screen Shot 2015 08 08 at 16 20 22
Click the link below the “Good work!” button to open up GitHub in your browser.  You should see something like this:
Screen Shot 2015 08 08 at 16 20 42
Scroll down to the bottom and you’ll see this.  Go ahead and click “Merge pull request” then “Confirm merge”.
Screen Shot 2015 08 08 at 16 20 50
Screen Shot 2015 08 08 at 16 20 55
Now you’ll see the option to delete this branch.  Go ahead and do it.  You are actually deleting “mscuthbert/mk270/master” not “mk270/master” — I hope it won’t let you delete the upstream master!
Screen Shot 2015 08 08 at 16 20 59
After doing so you’ll see this confirmation.
Screen Shot 2015 08 08 at 16 21 01
Now return to the GitHub client and switch back to “master” if it hasn’t already put you back there.
Screen Shot 2015 08 08 at 16 21 27
Go ahead and click “Sync” again for good measure.  Then you can check your History and see that you have all the most recent upstream commits:
Screen Shot 2015 08 08 at 16 21 53
Ta-da! Well, assuming that there aren’t any conflicts or anything of that sort.  In a case like that you’ll probably still need to get out the ol’ command-line tools, so you will still need to be a bit familiar with them (or have a friend who can help you out). Hopefully the next version of GitHub for Mac/Windows will make this much easier. But for day-to-day work, it’s now possible to stay in sync with the main repository on a more regular basis for people who use the graphic interface tools almost exclusively.

[*] edit August 10: EEK! Autocorrect originally changed “Whitaker’s Words” to “Whiskers-Words” — Fixed!  That app only does Cat-latin (catin?): "maumo, maumare, maumavi, maumatus  V (1st)     1 1 [GXXEK]   — meow;” not what we want!

06 August 2015

NL vs. AL leadoff hitters


Often while marveling at Ricky Henderson’s amazing stats, I wondered how much greater a leadoff hitter he would have been if he had spent his whole career in the National League.  He had 11,180 plate appearances in the AL but only 2,166 in the NL. In both leagues, the leadoff hitter leads off the first inning, but is not guaranteed to bat leadoff in any following inning. However, I figured that in the National League, batting after the pitcher, it’d be substantially more common that the person batting first in the order would get to lead off. The pitcher almost always makes an out, so I figured it’d be pretty common for him to make the third out (and because of situations where the eighth batter is walked to get to the pitcher, probably more common than one in three).  The eighth batter isn’t that strong in the AL, but a lot stronger than almost any NL pitcher.

I’ve been working off and on over the past two years (more off before getting tenure, more on after getting tenure) on an extremely flexible python toolkit for examining baseball games and it finally got to the state of development where I could test my findings.  I’m not ready to release the toolkit yet (it needs to be polished enough that I’m proud of it), but here’s the code I used to work:

  gc = games.GameCollection()

  gc.yearStart = 2000

  gc.yearEnd = 2014

  gc.usesDH = True

  allGames = gc.parse()

  totalPAs = 0

  totalLeadOffs = 0

  for g in allGames:

      for halfInning in g.halfInnings:

          for p in halfInning.plateAppearances:

              if p.battingOrder == 1:

                  totalPAs += 1

                  if p.plateAppearanceInInning == 1:

                      totalLeadOffs += 1

  print(totalPAs, totalLeadOffs, totalLeadOffs*100/totalPAs)


It gets a collection of games where the DH is used or not used, looks at each game, then at each half inning, then at each plate appearance. If the batter is #1, then it checks whether it’s the first appearance in the inning, then prints out the percentage of all batter #1 plate appearances which are leadoffs.  The results were surprising to me. 

       PAs  Leadoff    %
No DH 183,033 75,364 41.175
With DH 163,1781 63,451 38.885

The average difference in the percentage of leadoff plate appearances between the two leagues (accounting for interleague games) is only about 2.5%. This works out to about 15 PAs a year different for Ricky in his prime. So one hypothesis down, but many more to be investigated soon.

18 September 2014

Recent Research

A few recent articles and software of interest and some older articles that might have been missed:

11 June 2014

The (other) Tournai Mass

[This is a draft “Working Paper” of research in progress; comments are welcome, but it should not be considered published work and may be removed before this is submitted for publication and replaced with a link to the published version.] 

The Tournai Mass is one of the oldest, if not the oldest, complete polyphonic Masses. It has been dated to around 1330 (though I'm inclined to find it a bit younger, perhaps 1350? but just on a hunch). It is contained in a magnificently interesting manuscript of chant from the fourteenth century now in the Belgium city of Tournai (Bibliothèque capitulaire, MS 476).

Like some other early Masses, such as the Machaut Mass, this is a six-section Mass with a concluding Ite Missa Est set as a motet.  There are two other polyphonic works in the manuscript, placed within the Mass, a largely monophonic Sanctus with three-part "In excelsis" settings (PMFC 23, no. 72), directly after the first Sanctus, and a second Kyrie, placed after the Agnus Dei. The image from the bottom of folio 33r is below: 

(image reproduced under the assumption of limited copyright of works over 100 years old and under the Fair Use principle of a small excerpt. I will happily remove this and the following excerpt under a request from the Tournai BC)

In Reaney's notes for RISM B/IV-2, he states that this work (#7) is, like the Sanctus (#5), an independent, polyphonic Mass section and transcribes the incipit as such:

Cattin and Facchin in their monumental edition of French (& Spanish, Polish, Dutch, ... everything but Italian and English) Mass movements transcribed it as monophonic and noted that:
The well known melody...occurs in the T[enor] range in the Tournai MS; the question therefore remains whether one or more voices would have accompanied it. For this reason we decided to include this purely monodic piece in the present edition.
The opening of their transcription is shown below:

There are a few errors in this section of the transcription: the second Kyrie has three missing notes, and an incorrectly transcribed C instead of D. Together these errors account for the different lengths and incompatible harmony of the first Kyrie if the work were to be transcribed polyphonically, as I will propose below.  There are a few length errors in the third Kyrie which also could have made a polyphonic transcription difficult. However it is the Christe section that I am sure made great editors who had 130+ mass movements give up on making a polyphonic 3-fold Kyrie and instead make a monophonic 9-fold Kyrie.  The three Christe sections seem to begin on the notes A, G, and A and end on A, E, B; even if the first part is started after a breve rest (which may be interpreted as a sectional divider instead), the lengths and sonorities of this section just do not add up.

The solution comes from believing that the scribe himself did not realize where the different voices began and chose to ligate the final note of the first voice with the first note of the second voice. 

Beginning the second part on the second note of the ligature and ending the first voice on the first part gives a fully satisfying polyphonic version of the whole Kyrie:

A mediocre, generated .mp3 giving some sense of the piece is given below.

With these adjustments, the piece is almost entirely consonant, with the following breakdown of sonorities (discounting triplets in the middle of a semibreve):

36%  Perfect fifth
18   Major triad
12   Major third
12   Minor triad
 9   Minor third
 8   Minor triad as 6-3
 3   Major sixth
 2   Minor sixth
 0.5 Perfect fourth

(Numbers do not add up to 100% because of rounding)

Cattin and Facchin note that piece seems to be on the chant cantus firmus of no. 58 of Margaretha Landwehr-Melnicki's catalogue. The first Kyrie is indeed similar to this chant, but as a look at Paris, BNF lat. 14819, f. 34v. or Paris, BNF lat. 17309, f. 27v will show, the rest of the work is unrelated to this chant.

Otherwise the style of the work is similar to many French works from around 1350 (and also Spanish and Italian works from this time or slightly later). Facchin's description of these pieces, largely homophonic but with decorations, as part of a Wandering Style, or Stile Vaganti! seems quite appropriate for this work that wandered around the foot of a more famous Mass, waiting to be rediscovered.

More about the Sanctus and a fuller realization of it to come soon, thanks to an idea from Jan Janovčik. Here's a preview of his great recording with his Cantores Sancti Gregorii

Thanks to Jan Janovčik, Rob C. Wegman, and Dominique Gatté for aid and suggesting the Tournai manuscript as a source worth returning to. And to Anna Grau and Jeremy Jennings for their work on the EMMSAP project that made this work quickly possible.