Coverage for src/courtpy/references/judges/__init__.py: 100%
7 statements
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-22 15:51 +0000
« prev ^ index » next coverage.py v7.16.2, created at 2026-11-22 15:51 +0000
1"""Identifies the judges in parsed cases and adds what is known about them.
3The federal rules find the names of the judges on each case as the opinion
4writes them, such as "LYNCH" and "R THOMPSON" (the "panel_judges", "authors",
5"concurring", and "dissenting" columns, with "; " between the names). To
6study the judges, each name has to be matched to a person. A `Roster` is a
7table of judges, with one row for each court that a judge has served on,
8which finds the judge that a name refers to from the court and year of the
9case.
11`build_roster` makes that table with the fjc-biographies package
12(https://github.com/WithPrecedent/fjc_biographies), from three files of the
13Federal Judicial Center's Biographical Directory of Article III Federal
14Judges (which `download` gets with it): the judges' service on each court,
15their demographics, and their careers before the bench. The rules in its
16"judges" rulebook code the careers, and another rulebook can be named, so
17they can be changed without changing courtpy. fjc-biographies also adds
18scores of the judges' ideology, which it gets from the judicial-common-space
19package (https://github.com/WithPrecedent/judicial_common_space): each
20appointment's Judicial Common Space score ("jcs") and the justices'
21Martin-Quinn scores ("mq_first", "mq_last", "mq_mean", and "mq_terms"):
23```python
24import courtpy
26roster = courtpy.judges.Roster.from_fjc(jcs = True, martin_quinn = True)
27roster.save()
28```
30A saved roster is kept outside of projects (in "judges" in
31`courtpy.utilities.data_folder()`), where the techniques look for it when no
32roster is named. It is a CSV file, so judges and columns (such as a score of
33each judge's ideology) can be added to it in a spreadsheet. Every column of
34numbers or booleans that does not identify or date a judge's service is an
35attribute of the judge, which the techniques use.
37These techniques use a roster or the tables that it makes. They are added
38to the `amos` library as soon as courtpy is imported, so they can be named
39in settings. Cases and judges are different things, so the techniques are
40built from the mergers and shapers of `amos`, which join tables whose rows
41are not the same:
43* `add_biography` (an `amos.Merger`) adds what the roster says about each
44 judge that each row names. Each row of `Votes` gets "judge_party",
45 "judge_woman", and so on, and each row of `Cases` gets them for each seat
46 of its panel: "judge_name1", "judge_party1", "judge_woman1", and so on
47 for the first judge, "judge_name2" and the rest for the second.
48* `add_jcs` (an `amos.Merger`) is `add_biography` for each judge's Judicial
49 Common Space score alone ("judge_jcs", or "judge_jcs1" and so on).
50* `add_circuit` (an `amos.Merger`) adds the median and total of the parties
51 of the appointing presidents, and of the Judicial Common Space scores, of
52 the active (not senior) judges of each case's circuit on the day it was
53 decided.
54* `code_panels` (an `amos.Munger`) adds the composition of each case's
55 panel: the share of its judges who are women, the mean party of the
56 presidents who appointed them, and so on. It makes a row for each judge on
57 each case (with `lists_to_rows`), finds the judges (with
58 `add_biography`), and adds summaries of each case's judges to the case
59 (with `merge_summary`).
60* `cases_to_votes` (an `amos.Shaper`) makes `Votes`: a table with one row
61 for each judge on each case, with the judge's attributes, those of the
62 other judges on the panel, and how the judge voted.
63* `dockets_to_votes` (an `amos.Shaper`) is `cases_to_votes` for `Dockets`:
64 a row for each judge on each docket.
65* `votes_to_cases` (an `amos.Shaper`) undoes `cases_to_votes`: it makes
66 `Votes` `Cases` again.
67* `cases_to_judges` (an `amos.Shaper`) makes `Judges`: a table with one row
68 for each judge, which summarizes the judge's votes (with `group_rows`).
69* `load_roster` and `download_biographies` (reference loaders, see
70 `courtpy.loaders.ReferenceLoader`) start a study of the judges themselves
71 with a saved roster or one made from the Federal Judicial Center's files.
73The parts are in private modules: `_names` (how names are compared),
74`_roster` (the roster and its loaders), `_biographies` (`AddBiography` and
75`AddJcs`), `_circuits` (`AddCircuit`), and `_panels` (the techniques for
76panels and votes).
78Contents:
79 AddBiography: adds what a roster says about each judge that each row
80 names.
81 AddCircuit: adds the ideology of the active judges of each case's
82 circuit when the case was decided.
83 AddJcs: adds the Judicial Common Space score of each judge that each row
84 names.
85 CasesToJudges: makes a table with one row for each judge.
86 CasesToVotes: makes a table with one row for each judge on each case.
87 CodePanels: adds the judges and the composition of each case's panel.
88 DocketsToVotes: makes a table with one row for each judge on each
89 docket.
90 DownloadBiographies: downloads the Federal Judicial Center's files about
91 judges and loads the roster that they make.
92 LoadRoster: loads the table of a roster of judges.
93 Roster: a table of judges that finds the judge a name refers to.
94 VotesToCases: makes a table of votes a table of cases again.
95 build_roster: makes the table of a roster from the Federal Judicial
96 Center's files with fjc-biographies.
97 clean_name: returns a name the way that names are compared.
98 download: downloads the Federal Judicial Center's files about judges
99 with fjc-biographies.
100 edit_distance: returns how many edits turn one name into another.
101 name_forms: returns the ways that an opinion may write a judge's name,
102 grouped by how much of the name they give.
103 panel_compositions: returns the composition of each case's panel by
104 the parties of the presidents who appointed its judges, such as
105 "DDR".
106 shorter_names: returns shorter ways of writing a name that an opinion
107 gives, to try when the name itself fits no judge.
108 repaired_names: returns a name with the damage that some opinions' text
109 does undone.
110 republican_appointees: returns how many judges of each case's panel a
111 Republican president appointed.
112 vote_table: returns a table with one row for each judge on each case.
114"""
116from __future__ import annotations
118from ._biographies import AddBiography, AddJcs
119from ._circuits import AddCircuit
120from ._names import (
121 clean_name,
122 edit_distance,
123 name_forms,
124 repaired_names,
125 shorter_names,
126)
127from ._panels import (
128 CasesToJudges,
129 CasesToVotes,
130 CodePanels,
131 DocketsToVotes,
132 VotesToCases,
133 panel_compositions,
134 republican_appointees,
135 vote_table,
136)
137from ._roster import (
138 DownloadBiographies,
139 LoadRoster,
140 Roster,
141 build_roster,
142 download,
143)
145__all__ = [
146 'AddBiography',
147 'AddCircuit',
148 'AddJcs',
149 'CasesToJudges',
150 'CasesToVotes',
151 'CodePanels',
152 'DocketsToVotes',
153 'DownloadBiographies',
154 'LoadRoster',
155 'Roster',
156 'VotesToCases',
157 'build_roster',
158 'clean_name',
159 'download',
160 'edit_distance',
161 'name_forms',
162 'panel_compositions',
163 'repaired_names',
164 'republican_appointees',
165 'shorter_names',
166 'vote_table']