logo Netzschleuder network catalog, repository, and centrifuge

History of sp_primary_school

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/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index b5b9978..d6d2da5 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -37,7 +37,7 @@ The networks have the following properties:
 tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
 url = 'https://sociopatterns.org/datasets/primary-school-temporal-network-data/'
 citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'https://doi.org/10.1371/journal.pone.0023176')]
-icon_hash = '56a85c8e26855e083a2f78db'
+date_added = '2020-08-11'
 upstream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
                    "http://creativecommons.org/licenses/by-nc-sa/3.0/")
 upstream_prefix = 'https://sociopatterns.org/assets/data'
[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/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index 72aa99c..b5b9978 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -28,12 +28,12 @@ description = r"""Networks of face-to-face proximity contacts among the children
 
 The networks have the following properties:
 
-- `id`: the anonymous identifier of the person (the same in all networks).
-- `class`: the class of the child (`1A` to `5B`, where the digit is the grade), or `Teachers`.
-- `gender`: the gender (`M`, `F` or `Unknown`).
-- `time` (`contacts`): the end of the 20-second interval $[t - 20\,\text{s}, t]$ during which the contact was active, in seconds from an unspecified reference time.
-- `duration` (`day_1`, `day_2`): the cumulative time the two persons spent in contact during the day, in seconds (a multiple of 20 seconds).
-- `count` (`day_1`, `day_2`): the number of times the contact between the two persons was established during the day."""
+- (Node) `id`: the anonymous identifier of the person (the same in all networks).
+- (Node) `class`: the class of the child (`1A` to `5B`, where the digit is the grade), or `Teachers`.
+- (Node) `gender`: the gender (`M`, `F` or `Unknown`).
+- (Edge) `time` (`contacts`): the end of the 20-second interval $[t - 20\,\text{s}, t]$ during which the contact was active, in seconds from an unspecified reference time.
+- (Edge) `duration` (`day_1`, `day_2`): the cumulative time the two persons spent in contact during the day, in seconds (a multiple of 20 seconds).
+- (Edge) `count` (`day_1`, `day_2`): the number of times the contact between the two persons was established during the day."""
 tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
 url = 'https://sociopatterns.org/datasets/primary-school-temporal-network-data/'
 citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'https://doi.org/10.1371/journal.pone.0023176')]
[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/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index 2c3173b..72aa99c 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -53,7 +53,6 @@ def fetch_upstream(force=False):
 @coerce_props()
 @annotate()
 def parse(alts=None):
-    global files
     name = __name__.split(".")[-1]
     for fnames, alt, fmt in files:
         if alts is not None and alt not in alts:
[entries] Fix parse bugs and improve descriptions and metadata by Tiago de Paula Peixoto 6bb6851
- parse fixes from the review of the descriptions, e.g. us_patents
  (directed), celegans_2019 (synapse direction), ecoli_transcription and
  yeast_transcription (regulator to target), bitcoin (direction, phantom
  node), ego_social (Google+ features and circles), scotus_majority,
  arxiv_authors and social_location (as in SNAP), caida_as, dnc, dom,
  mist, reuters and bibsonomy (names on the right nodes), uci_zoo
- every description now states explicitly what the nodes and edges
  represent; corrected titles, years, tags, citations and licences
- the "Hypergraph" tag is removed; very large entries are marked
  `huge = True` (see --skip-huge)
- ICON ids of partial duplicates added (hiv_transmission, congress_bills,
  openflights, dutch_school)
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index 5672a2e..2c3173b 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -18,17 +18,32 @@
 
 from .. import *
 
+import xml.etree.ElementTree as ET
+
 title = "Primary school dynamic contacts (2009)"
-description = """Two temporal networks of contacts among students and teachers at a primary school in Lyon, France, on consecutive days of in October 2009. Each network accumulates all contacts over the course of a single day; contacts were sampled at 20-second intervals[^icon]
-[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
+description = r"""Networks of face-to-face proximity contacts among the children and teachers of a primary school in Lyon, France, measured by the SocioPatterns collaboration with wearable sensors during two days (Thursday 1 and Friday 2 October 2009). The school has five grades, each divided in two classes, and the study included 232 children and 10 teachers. The following networks are provided:
+
+- `contacts`: temporal network of all contacts. Nodes are persons, and each edge is a contact between two persons active during a 20-second interval of the data collection, so that a pair of persons is connected by one edge per interval in which they were in contact.
+- `day_1`, `day_2`: the cumulative contact networks of the first and second day, published separately upstream. Nodes are the persons present on that day, and an edge connects two persons that were in contact at least once during the day.
+
+The networks have the following properties:
+
+- `id`: the anonymous identifier of the person (the same in all networks).
+- `class`: the class of the child (`1A` to `5B`, where the digit is the grade), or `Teachers`.
+- `gender`: the gender (`M`, `F` or `Unknown`).
+- `time` (`contacts`): the end of the 20-second interval $[t - 20\,\text{s}, t]$ during which the contact was active, in seconds from an unspecified reference time.
+- `duration` (`day_1`, `day_2`): the cumulative time the two persons spent in contact during the day, in seconds (a multiple of 20 seconds).
+- `count` (`day_1`, `day_2`): the number of times the contact between the two persons was established during the day."""
 tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
-url = 'http://www.sociopatterns.org/datasets/primary-school-cumulative-networks/'
+url = 'https://sociopatterns.org/datasets/primary-school-temporal-network-data/'
 citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'https://doi.org/10.1371/journal.pone.0023176')]
 icon_hash = '56a85c8e26855e083a2f78db'
-ustream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
+upstream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
                    "http://creativecommons.org/licenses/by-nc-sa/3.0/")
-upstream_prefix = 'http://www.sociopatterns.org/wp-content/uploads/2015/09'
-files = [(('primaryschool.csv.gz', 'metadata_primaryschool.txt'), None, None)]
+upstream_prefix = 'https://sociopatterns.org/assets/data'
+files = [(('primaryschool.csv.gz', 'primaryschool_metadata.txt'), 'contacts', None),
+         ('sp_school_day1.gexf.gz', 'day_1', 'gexf'),
+         ('sp_school_day2.gexf.gz', 'day_2', 'gexf')]
 
 def fetch_upstream(force=False):
     return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
@@ -43,8 +58,36 @@ def parse(alts=None):
     for fnames, alt, fmt in files:
         if alts is not None and alt not in alts:
             continue
-        if isinstance(fnames, str):
-            fnames = [fnames]
+        if fmt == "gexf":
+            # The node attributes ("classname" and "gender") agree with the
+            # metadata of the contacts network
+            with open_upstream_file(name, fnames, "rb") as f:
+                root = ET.parse(f).getroot()
+            ns = {"g": "http://www.gexf.net/1.1draft"}
+            def get_attrs(x):
+                return {a.get("for"): a.get("value")
+                        for a in x.findall("g:attvalues/g:attvalue", ns)}
+            g = Graph(directed=False)
+            g.vp.id = g.new_vp("int")
+            g.vp["class"] = g.new_vp("string")
+            g.vp["gender"] = g.new_vp("string")
+            vs = {}
+            for n in root.findall("g:graph/g:nodes/g:node", ns):
+                v = g.add_vertex()
+                vs[n.get("id")] = v
+                attrs = get_attrs(n)
+                g.vp.id[v] = int(n.get("id"))
+                g.vp["class"][v] = attrs["0"]
+                g.vp["gender"][v] = attrs["1"]
+            g.ep.duration = g.new_ep("int")
+            g.ep.count = g.new_ep("int")
+            for x in root.findall("g:graph/g:edges/g:edge", ns):
+                e = g.add_edge(vs[x.get("source")], vs[x.get("target")])
+                attrs = get_attrs(x)
+                g.ep.duration[e] = int(attrs["2"])
+                g.ep.count[e] = int(attrs["3"])
+            yield alt, g
+            continue
         with ExitStack() as stack:
             fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
 
Update copyright information by Tiago de Paula Peixoto 73a4f0d
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index ff6cd86..5672a2e 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
+# 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
Update copyright information by Tiago de Paula Peixoto 3d288ea
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index fcdb108..ff6cd86 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2024 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
Update copyright information by Tiago de Paula Peixoto 8d005ae
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index b2db13a..fcdb108 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2023 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
sp_high_school, sp_high_school_new, sp_primary_school: fix node ids by Tiago de Paula Peixoto f5db9a9
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index 31b5213..b2db13a 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -67,6 +67,7 @@ def parse(alts=None):
                 v = int(row[0])
                 if v not in vs:
                     vs[v] = g.add_vertex()
+                    g.vp.id[vs[v]] = v
                 v = vs[v]
                 g.vp["class"][v] = row[1]
                 g.vp["gender"][v] = row[2]
primary_school: switch to dynamical data by Tiago de Paula Peixoto bde6071
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index 368fa36..31b5213 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -27,9 +27,8 @@ citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-F
 icon_hash = '56a85c8e26855e083a2f78db'
 ustream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
                    "http://creativecommons.org/licenses/by-nc-sa/3.0/")
-upstream_prefix = 'http://www.sociopatterns.org/wp-content/uploads/2014/05'
-files = [('sp_data_school_day_1_g.gexf_.gz', 'day_1', 'gexf'),
-         ('sp_data_school_day_2_g.gexf_.gz', 'day_2', 'gexf')]
+upstream_prefix = 'http://www.sociopatterns.org/wp-content/uploads/2015/09'
+files = [(('primaryschool.csv.gz', 'metadata_primaryschool.txt'), None, None)]
 
 def fetch_upstream(force=False):
     return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
@@ -47,6 +46,29 @@ def parse(alts=None):
         if isinstance(fnames, str):
             fnames = [fnames]
         with ExitStack() as stack:
-            fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
-            g = parse_graph(fs, fmt, directed=False)
+            fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+
+            reader = csv.reader(fs[0], delimiter="\t")
+            def get_edges():
+                for rows in reader:
+                    t, u, v = [int(x) for x in rows[:3]]
+                    yield u, v, t
+            g = Graph(directed=False)
+            g.ep.time = g.new_ep("int")
+            g.vp.id = g.add_edge_list(get_edges(), hashed=True,
+                                      hash_type="int", eprops=[g.ep.time])
+
+            vs = {g.vp.id[v] : v for v in g.vertices()}
+
+            g.vp["class"] = g.new_vp("string")
+            g.vp["gender"] = g.new_vp("string")
+            reader = csv.reader(fs[1], delimiter="\t")
+            for row in reader:
+                v = int(row[0])
+                if v not in vs:
+                    vs[v] = g.add_vertex()
+                v = vs[v]
+                g.vp["class"][v] = row[1]
+                g.vp["gender"][v] = row[2]
+
         yield alt, g
Update copyright info by Tiago de Paula Peixoto db2efcc
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index e9698ba..368fa36 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -1,7 +1,7 @@
 #! /usr/bin/env python
 # -*- coding: utf-8 -*-
 #
-# Copyright (C) 2020 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2021 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
Update citations to use DOIs by Tiago de Paula Peixoto e878874
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index c886f39..e9698ba 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -23,7 +23,7 @@ description = """Two temporal networks of contacts among students and teachers a
 [^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
 tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
 url = 'http://www.sociopatterns.org/datasets/primary-school-cumulative-networks/'
-citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0023176')]
+citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'https://doi.org/10.1371/journal.pone.0023176')]
 icon_hash = '56a85c8e26855e083a2f78db'
 ustream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
                    "http://creativecommons.org/licenses/by-nc-sa/3.0/")
Change license from GPLv3 to AGPLv3 by Tiago de Paula Peixoto d754be5
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index c7d345e..c886f39 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -3,18 +3,18 @@
 #
 # Copyright (C) 2020 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 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 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 General Public License for more details.
+# 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 General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# 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/>.
 
 from .. import *
 
Add explicit attribution to descriptions obtained from ICON by Tiago de Paula Peixoto 1645314
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
index ae539d4..c7d345e 100644
--- a/entries/sp_primary_school/__init__.py
+++ b/entries/sp_primary_school/__init__.py
@@ -19,7 +19,8 @@
 from .. import *
 
 title = "Primary school dynamic contacts (2009)"
-description = "Two temporal networks of contacts among students and teachers at a primary school in Lyon, France, on consecutive days of in October 2009. Each network accumulates all contacts over the course of a single day; contacts were sampled at 20-second intervals"
+description = """Two temporal networks of contacts among students and teachers at a primary school in Lyon, France, on consecutive days of in October 2009. Each network accumulates all contacts over the course of a single day; contacts were sampled at 20-second intervals[^icon]
+[^icon]: Description obtained from the [ICON](https://icon.colorado.edu) project."""
 tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
 url = 'http://www.sociopatterns.org/datasets/primary-school-cumulative-networks/'
 citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0023176')]
Initial commit by Tiago de Paula Peixoto cc85872
diff --git a/entries/sp_primary_school/__init__.py b/entries/sp_primary_school/__init__.py
new file mode 100644
index 0000000..ae539d4
--- /dev/null
+++ b/entries/sp_primary_school/__init__.py
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 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 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .. import *
+
+title = "Primary school dynamic contacts (2009)"
+description = "Two temporal networks of contacts among students and teachers at a primary school in Lyon, France, on consecutive days of in October 2009. Each network accumulates all contacts over the course of a single day; contacts were sampled at 20-second intervals"
+tags = ['Social', 'Offline', 'Weighted', 'Temporal', 'Metadata']
+url = 'http://www.sociopatterns.org/datasets/primary-school-cumulative-networks/'
+citation = [('Juliette Stehle et al., "High-Resolution Measurements of Face-to-Face Contact Patterns in a Primary School." PLoS ONE 6(8), e23176 (2011).', 'http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0023176')]
+icon_hash = '56a85c8e26855e083a2f78db'
+ustream_license = ("Creative Commons Attribution-NonCommercial-ShareAlike",
+                   "http://creativecommons.org/licenses/by-nc-sa/3.0/")
+upstream_prefix = 'http://www.sociopatterns.org/wp-content/uploads/2014/05'
+files = [('sp_data_school_day_1_g.gexf_.gz', 'day_1', 'gexf'),
+         ('sp_data_school_day_2_g.gexf_.gz', 'day_2', 'gexf')]
+
+def fetch_upstream(force=False):
+    return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+                                force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+    global files
+    name = __name__.split(".")[-1]
+    for fnames, alt, fmt in files:
+        if alts is not None and alt not in alts:
+            continue
+        if isinstance(fnames, str):
+            fnames = [fnames]
+        with ExitStack() as stack:
+            fs = [stack.enter_context(open_upstream_file(name, fn, "rb")) for fn in fnames]
+            g = parse_graph(fs, fmt, directed=False)
+        yield alt, g