logo Netzschleuder network catalog, repository, and centrifuge

History of us_rollcall

The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.

[entries] Add the date when each entry was added, and remove icon_hash by Tiago de Paula Peixoto beff7c9
The dates are those of the commits that first added the entries' files
(2020-08-11 for the entries of the initial commit); renamed entries keep
the date of their first name.

Changed: none
diff --git a/entries/us_rollcall/__init__.py b/entries/us_rollcall/__init__.py
index 34cbad9..adcf861 100644
--- a/entries/us_rollcall/__init__.py
+++ b/entries/us_rollcall/__init__.py
@@ -42,7 +42,7 @@ url = 'https://doi.org/10.6084/m9.figshare.1590036.v1'
 citation = [('A. S. Waugh, L. Pei, J. H. Fowler, P. J. Mucha, M. A. Porter, "Party Polarization in Congress: A Network Science Approach." arXiv:0907.3509 (2009)', 'https://arxiv.org/abs/0907.3509'),
             ('M. Porter, "Roll Call Votes: United States House and Senate." figshare (2015)', 'https://doi.org/10.6084/m9.figshare.1590036.v1'),
             ('K. Poole, H. Rosenthal, et al., "Voteview: Congressional Roll-Call Votes Database."', 'https://voteview.com/')]
-icon_hash = ['5727b9f2461efe0c7a675f07', '572b96d9461efe0c7a677568']
+date_added = '2026-10-25'
 upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
 upstream_prefix = 'https://ndownloader.figshare.com/files'
 archive = '2391156:zip:roll call votes/'
[entries] Prefix the properties in the descriptions with (Node), (Edge) or (Graph) by Tiago de Paula Peixoto bc3dbbd
The lists of properties at the end of the descriptions marked edge
properties with "Edge" but left node properties unmarked, or grouped
them in "Nodes: `a`, ...; `b`, ..." items, so the kind of a property
was often unclear. Every item now starts with (Node), (Edge) or (Graph),
followed by the property names, a colon and the explanation, one item
per property or group of properties; qualifications (kinds of nodes,
networks) follow the names in parentheses. Properties that were only
named got a short explanation, and a few items that named the wrong
kind of property were corrected.
diff --git a/entries/us_rollcall/__init__.py b/entries/us_rollcall/__init__.py
index ea4a939..34cbad9 100644
--- a/entries/us_rollcall/__init__.py
+++ b/entries/us_rollcall/__init__.py
@@ -27,8 +27,16 @@ description = """Networks of the roll-call votes of the United States Congress,
 
 The networks have the following properties:
 
-- Bipartite networks: `is_legislator`, whether the node is a legislator (otherwise it is a roll call, numbered in chronological order); `name`, the surname of the legislator (as in the source, truncated to 11 characters); `party`, the party of the legislator (`D` Democrat, `R` Republican, `I` other); edge `vote`, +1 for yea and -1 for nay.
-- Weighted networks: `icpsr`, the ICPSR identifier of the legislator; `name`, the surname of the legislator (as in the source, truncated to 11 characters); `state`, the name of the state (abbreviated to 7 characters); `state_code`, the ICPSR state code; `district`, the congressional district (0 for senators; 98 or 99 for at-large and other special districts); `party_code`, the Voteview party code (e.g. 100 Democrat, 200 Republican, 328 Independent, 5000 Pro-Administration, 4000 Anti-Administration); edge `weight`, the fraction of agreeing votes."""
+- (Node) `is_legislator` (bipartite networks): whether the node is a legislator (otherwise it is a roll call, numbered in chronological order).
+- (Node) `name`: the surname of the legislator (as in the source, truncated to 11 characters).
+- (Node) `party` (bipartite networks): the party of the legislator (`D` Democrat, `R` Republican, `I` other).
+- (Edge) `vote` (bipartite networks): +1 for yea and -1 for nay.
+- (Node) `icpsr` (weighted networks): the ICPSR identifier of the legislator.
+- (Node) `state` (weighted networks): the name of the state (abbreviated to 7 characters).
+- (Node) `state_code` (weighted networks): the ICPSR state code.
+- (Node) `district` (weighted networks): the congressional district (0 for senators; 98 or 99 for at-large and other special districts).
+- (Node) `party_code` (weighted networks): the Voteview party code (e.g. 100 Democrat, 200 Republican, 328 Independent, 5000 Pro-Administration, 4000 Anti-Administration).
+- (Edge) `weight` (weighted networks): the fraction of agreeing votes."""
 tags = ['Social', 'Political', 'Offline', 'Signed', 'Weighted', 'Projection', 'Metadata', 'Temporal']
 url = 'https://doi.org/10.6084/m9.figshare.1590036.v1'
 citation = [('A. S. Waugh, L. Pei, J. H. Fowler, P. J. Mucha, M. A. Porter, "Party Polarization in Congress: A Network Science Approach." arXiv:0907.3509 (2009)', 'https://arxiv.org/abs/0907.3509'),
[entries] Remove unneeded code from the entries by Tiago de Paula Peixoto 2c69f19
Unneeded "global files" statements, unused imports and variables,
f-strings without placeholders, duplicate keys in foodweb_little_rock
(keeping the order and the values used), and the second definition of
get_lines() in twitter_higgs. Nothing changes in the networks or
descriptions.

Changed: none
diff --git a/entries/us_rollcall/__init__.py b/entries/us_rollcall/__init__.py
index 3ff58c9..ea4a939 100644
--- a/entries/us_rollcall/__init__.py
+++ b/entries/us_rollcall/__init__.py
@@ -118,7 +118,6 @@ def parse_projection(name, fname, alt):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fname, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] New entry: us_rollcall by Tiago de Paula Peixoto 68a97d9
diff --git a/entries/us_rollcall/__init__.py b/entries/us_rollcall/__init__.py
new file mode 100644
index 0000000..3ff58c9
--- /dev/null
+++ b/entries/us_rollcall/__init__.py
@@ -0,0 +1,130 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020-2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+import tarfile
+from .. import *
+
+title = "US Congress roll-call votes (1789-2009)"
+description = """Networks of the roll-call votes of the United States Congress, from the Voteview data of K. Poole and H. Rosenthal, as processed and distributed by M. A. Porter and collaborators.
+
+1. Bipartite networks of legislators and roll calls, for the House of Representatives (`house<C>`) and the Senate (`senate<C>`) of the 102nd to the 107th Congresses (1991-2003), prepared by M. E. J. Newman. Each legislator is connected to each roll call in which they voted yea or nay, and the edge is annotated with the vote. Paired and announced votes, abstentions and absences are not included. Legislators who served only part of a term appear as separate nodes, and are included even if they never voted.
+2. Weighted networks of legislators for the House (`H<C>`) and the Senate (`S<C>`) of every Congress from the 1st to the 110th (1789-2009), used by Waugh, Pei, Fowler, Mucha and Porter in their study of party polarization. Two legislators are connected by an edge weighted by the fraction of the roll calls in which both voted where they voted the same way (both yea or both nay). Here, yea includes paired and announced yeas, and nay includes paired and announced nays. Legislators who never voted are excluded. Pairs of legislators who never agreed, or never voted in the same roll call, have weight zero in the source and are not connected. Legislators are identified by their ICPSR number (which, in a few cases, changes when a legislator switches party).
+
+The networks have the following properties:
+
+- Bipartite networks: `is_legislator`, whether the node is a legislator (otherwise it is a roll call, numbered in chronological order); `name`, the surname of the legislator (as in the source, truncated to 11 characters); `party`, the party of the legislator (`D` Democrat, `R` Republican, `I` other); edge `vote`, +1 for yea and -1 for nay.
+- Weighted networks: `icpsr`, the ICPSR identifier of the legislator; `name`, the surname of the legislator (as in the source, truncated to 11 characters); `state`, the name of the state (abbreviated to 7 characters); `state_code`, the ICPSR state code; `district`, the congressional district (0 for senators; 98 or 99 for at-large and other special districts); `party_code`, the Voteview party code (e.g. 100 Democrat, 200 Republican, 328 Independent, 5000 Pro-Administration, 4000 Anti-Administration); edge `weight`, the fraction of agreeing votes."""
+tags = ['Social', 'Political', 'Offline', 'Signed', 'Weighted', 'Projection', 'Metadata', 'Temporal']
+url = 'https://doi.org/10.6084/m9.figshare.1590036.v1'
+citation = [('A. S. Waugh, L. Pei, J. H. Fowler, P. J. Mucha, M. A. Porter, "Party Polarization in Congress: A Network Science Approach." arXiv:0907.3509 (2009)', 'https://arxiv.org/abs/0907.3509'),
+            ('M. Porter, "Roll Call Votes: United States House and Senate." figshare (2015)', 'https://doi.org/10.6084/m9.figshare.1590036.v1'),
+            ('K. Poole, H. Rosenthal, et al., "Voteview: Congressional Roll-Call Votes Database."', 'https://voteview.com/')]
+icon_hash = ['5727b9f2461efe0c7a675f07', '572b96d9461efe0c7a677568']
+upstream_license = ("CC BY 4.0", "https://creativecommons.org/licenses/by/4.0/")
+upstream_prefix = 'https://ndownloader.figshare.com/files'
+archive = '2391156:zip:roll call votes/'
+files = [(archive + f'{ch}101-107.tar', f'{ch}{c}', 'bipartite')
+         for ch in ['house', 'senate'] for c in range(102, 108)] + \
+        [(archive + 'rollcall-processed.mat', f'{ch}{c}', 'projection')
+         for ch in ['H', 'S'] for c in range(1, 111)]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+def parse_bipartite(name, fname, alt):
+    members = {}
+    with open_upstream_file(name, fname, "rb") as f:
+        with tarfile.open(fileobj=f, mode="r|") as tf:
+            for m in tf:
+                if m.name in (f"{alt}.nam", f"{alt}.vot"):
+                    members[m.name] = tf.extractfile(m).read().decode("ascii")
+    names = []
+    for line in members[f"{alt}.nam"].splitlines():
+        if not line.strip():
+            continue
+        i, code, rest = line.split(" ", 2)
+        lname, party = rest.rsplit(" ", 1)
+        names.append((lname.strip().strip('"').strip(), party.strip("()")))
+    votes = numpy.array([[int(x) for x in line.split()]
+                         for line in members[f"{alt}.vot"].splitlines() if line.strip()])
+    n, m = votes.shape
+    assert n == len(names)
+    g = Graph(directed=False)
+    g.add_vertex(n + m)
+    g.vp.is_legislator = g.new_vp("bool")
+    g.vp.is_legislator.a[:n] = True
+    g.vp.name = g.new_vp("string")
+    g.vp.party = g.new_vp("string")
+    for i, (lname, party) in enumerate(names):
+        g.vp.name[i] = lname
+        g.vp.party[i] = party
+    i, j = numpy.nonzero(votes)
+    g.ep.vote = g.new_ep("int")
+    g.add_edge_list(numpy.array([i, j + n, votes[i, j]]).T, eprops=[g.ep.vote])
+    return g
+
+_rollcall = None
+
+def parse_projection(name, fname, alt):
+    global _rollcall
+    import scipy.io
+    if _rollcall is None:
+        with open_upstream_file(name, fname, "rb", seekable=True) as f:
+            _rollcall = scipy.io.loadmat(f, squeeze_me=True,
+                                         struct_as_record=False)["RollCall"]
+    ch, c = alt[0], int(alt[1:]) - 1
+    A = getattr(_rollcall, f"{ch}A")[c]
+    ids = getattr(_rollcall, f"{ch}ID")[c]
+    strs = getattr(_rollcall, f"{ch}string")[c]
+    g = Graph(directed=False)
+    g.add_vertex(A.shape[0])
+    g.vp.icpsr = g.new_vp("int", vals=[int(x) for x in ids])
+    for k, vt in [("name", "string"), ("state", "string"),
+                  ("state_code", "int"), ("district", "int"),
+                  ("party_code", "int")]:
+        g.vp[k] = g.new_vp(vt)
+    for v, s in enumerate(strs):
+        # fixed-width Voteview record, read from the right:
+        # icpsr(5) state_code(2) district(2) state(7) party(4) occupancy(1)
+        # means(1) name(11)
+        assert int(s[-33:-28]) == g.vp.icpsr[v]
+        g.vp.name[v] = s[-11:].strip()
+        g.vp.party_code[v] = int(s[-17:-13])
+        g.vp.state[v] = s[-24:-17].strip()
+        g.vp.district[v] = int(s[-26:-24])
+        g.vp.state_code[v] = int(s[-28:-26])
+    i, j = numpy.nonzero(numpy.triu(A, 1))
+    g.ep.weight = g.new_ep("double")
+    g.add_edge_list(numpy.array([i, j, A[i, j]]).T, eprops=[g.ep.weight])
+    return g
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fname, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        if fmt == "bipartite":
+            g = parse_bipartite(name, fname, alt)
+        else:
+            g = parse_projection(name, fname, alt)
+        yield alt, g