Skip to content

Commit

Permalink
Tidy/ingestor (#1714)
Browse files Browse the repository at this point in the history
* fix dfview

* fix more tests

* fmt

* fix time, src, dst order

* const_prop rename

* replace layer, layer_in_df with layer_name and layer_col

* replace node_type_in_df with node_type_col

* fix notebook

* Attemted merge

* fmt

* missed a const

* forgot const

* fixed tests, added node types

* Fix test

* Added extra tests for node_type and layer - changed function name

* update stubs + black

* fixed after merge

---------

Co-authored-by: Shivam Kapoor <[email protected]>
Co-authored-by: miratepuffin <[email protected]>
  • Loading branch information
3 people authored Aug 21, 2024
1 parent c655ee6 commit caa8927
Show file tree
Hide file tree
Showing 24 changed files with 2,755 additions and 2,323 deletions.
66 changes: 33 additions & 33 deletions examples/python/socio-patterns/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "16de15732c834eafb018c88c0b052c00",
"model_id": "ec2b2e5c92b54503940f06b3c30f184a",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -120,7 +120,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Graph(number_of_nodes=22, number_of_edges=290, number_of_temporal_edges=3196, earliest_time=1560419400000, latest_time=1562756700000)\n"
"Graph(number_of_nodes=22, number_of_edges=290, number_of_temporal_edges=6392, earliest_time=1560419400000, latest_time=1562756700000)\n"
]
}
],
Expand All @@ -130,7 +130,7 @@
" src=\"Actor\",\n",
" dst=\"Recipient\",\n",
" time=\"DateTime\",\n",
" layer=\"Behavior\",\n",
" layer_col=\"Behavior\",\n",
" properties=[\"Weight\"],\n",
")\n",
"print(g)"
Expand All @@ -149,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
Expand All @@ -159,8 +159,8 @@
"Stats on the graph structure:\n",
"Number of nodes (Baboons): 22\n",
"Number of unique edges (src,dst,layer): 290\n",
"Total interactions (edge updates): 3196\n",
"Unique layers: ['_default', 'Grooming', 'Resting', 'Presenting', 'Playing with', 'Grunting-Lipsmacking', 'Supplanting', 'Threatening', 'Submission', 'Touching', 'Avoiding', 'Attacking', 'Carrying', 'Embracing', 'Mounting', 'Copulating', 'Chasing'] \n",
"Total interactions (edge updates): 6392\n",
"Unique layers: ['_default', 'Behavior', 'Grooming', 'Resting', 'Presenting', 'Playing with', 'Grunting-Lipsmacking', 'Supplanting', 'Threatening', 'Submission', 'Touching', 'Avoiding', 'Attacking', 'Carrying', 'Embracing', 'Mounting', 'Copulating', 'Chasing'] \n",
"\n",
"Stats on the graphs time range:\n",
"Earliest datetime: 2019-06-13 09:50:00+00:00\n",
Expand Down Expand Up @@ -213,7 +213,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -226,11 +226,11 @@
"\n",
"Getting individual nodes and edges:\n",
"Node(name=LOME, earliest_time=1560419520000, latest_time=1562756100000)\n",
"Edge(source=LOME, target=NEKKE, earliest_time=1560421080000, latest_time=1562755980000, properties={Weight: 1}) \n",
"Edge(source=LOME, target=NEKKE, earliest_time=1560421080000, latest_time=1562755980000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1}) \n",
"\n",
"Getting iterators over all nodes and edges:\n",
"[Node(name=ANGELE, earliest_time=1560419400000, latest_time=1562754600000), Node(name=FELIPE, earliest_time=1560419400000, latest_time=1562756700000), Node(name=LIPS, earliest_time=1560419460000, latest_time=1562756700000), Node(name=NEKKE, earliest_time=1560419520000, latest_time=1562756700000), Node(name=LOME, earliest_time=1560419520000, latest_time=1562756100000)]\n",
"[Edge(source=ANGELE, target=FELIPE, earliest_time=1560419400000, latest_time=1562753640000, properties={Weight: 1}), Edge(source=LOME, target=FEYA, earliest_time=1560421260000, latest_time=1562328420000, properties={Weight: 1}), Edge(source=VIOLETTE, target=LIPS, earliest_time=1560423600000, latest_time=1560423600000, properties={Weight: -1})]\n"
"[Edge(source=ANGELE, target=FELIPE, earliest_time=1560419400000, latest_time=1562753640000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1}), Edge(source=FELIPE, target=ANGELE, earliest_time=1560419460000, latest_time=1562754600000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1}), Edge(source=FELIPE, target=LIPS, earliest_time=1560419460000, latest_time=1562251080000, properties={Weight: 1, Weight: 1, Weight: 1})]\n"
]
}
],
Expand Down Expand Up @@ -263,7 +263,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -307,7 +307,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"metadata": {
"scrolled": true
},
Expand All @@ -318,7 +318,7 @@
"text": [
"FELIPE has 17 incoming interactions and 18 outgoing interactions.\n",
"\n",
"[Edge(source=ANGELE, target=FELIPE, earliest_time=1560419400000, latest_time=1562753640000, properties={Weight: 1}), Edge(source=LIPS, target=FELIPE, earliest_time=1560423600000, latest_time=1562756700000, properties={Weight: 1}), Edge(source=NEKKE, target=FELIPE, earliest_time=1560443040000, latest_time=1562596380000, properties={Weight: 1})]\n",
"[Edge(source=ANGELE, target=FELIPE, earliest_time=1560419400000, latest_time=1562753640000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1}), Edge(source=LIPS, target=FELIPE, earliest_time=1560423600000, latest_time=1562756700000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1}), Edge(source=NEKKE, target=FELIPE, earliest_time=1560443040000, latest_time=1562596380000, properties={Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1, Weight: 1})]\n",
"[Node(name=ANGELE, earliest_time=1560419400000, latest_time=1562754600000), Node(name=LIPS, earliest_time=1560419460000, latest_time=1562756700000), Node(name=NEKKE, earliest_time=1560419520000, latest_time=1562756700000)] \n",
"\n",
"FELIPE interacted with the following baboons ['ANGELE', 'LIPS', 'NEKKE', 'LOME', 'BOBO', 'ATMOSPHERE', 'FEYA', 'FANA', 'PIPO', 'MUSE', 'MAKO', 'MALI', 'PETOULETTE', 'ARIELLE', 'HARLEM', 'VIOLETTE', 'EWINE', 'SELF']\n"
Expand Down Expand Up @@ -361,7 +361,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 11,
"metadata": {
"scrolled": true
},
Expand All @@ -371,18 +371,18 @@
"output_type": "stream",
"text": [
"Update history per layer:\n",
"FELIPE interacted with MAKO with the following behaviour 'Behavior' at this times: [1560437400000, 1560437640000, 1560935460000, 1561043280000, 1561043280000, 1561043340000, 1561117620000, 1561373880000, 1561373880000, 1561373940000, 1561373940000, 1561373940000, 1561373940000, 1561373940000, 1561390860000, 1561390860000, 1561390860000, 1561390920000, 1561643580000, 1561717080000, 1561717140000, 1561970760000, 1562148960000, 1562148960000, 1562149020000, 1562149020000, 1562149080000, 1562671020000]\n",
"FELIPE interacted with MAKO with the following behaviour 'Grooming' at this times: [1561043280000, 1561043340000]\n",
"FELIPE interacted with MAKO with the following behaviour 'Resting' at this times: [1560437400000, 1560437640000, 1560935460000, 1561117620000, 1561373880000, 1561390860000, 1561390860000, 1561390860000, 1561643580000, 1561970760000, 1562149020000, 1562671020000]\n",
"FELIPE interacted with MAKO with the following behaviour 'Playing with' at this times: [1561373880000, 1561373940000, 1561373940000, 1561390920000, 1562148960000, 1562148960000, 1562149080000]\n",
"FELIPE interacted with MAKO with the following behaviour 'Grunting-Lipsmacking' at this times: [1561373940000, 1561717080000, 1561717140000]\n",
"FELIPE interacted with MAKO with the following behaviour 'Touching' at this times: [1562149020000]\n",
"\n",
"Individual updates as edges:\n",
"At 2019-06-13 14:50:00+00:00 FELIPE interacted with MAKO in the following manner: 'Behavior'\n",
"At 2019-06-13 14:50:00+00:00 FELIPE interacted with MAKO in the following manner: 'Resting'\n",
"At 2019-06-13 14:54:00+00:00 FELIPE interacted with MAKO in the following manner: 'Behavior'\n",
"At 2019-06-13 14:54:00+00:00 FELIPE interacted with MAKO in the following manner: 'Resting'\n",
"At 2019-06-19 09:11:00+00:00 FELIPE interacted with MAKO in the following manner: 'Resting'\n",
"At 2019-06-20 15:08:00+00:00 FELIPE interacted with MAKO in the following manner: 'Carrying'\n",
"At 2019-06-20 15:08:00+00:00 FELIPE interacted with MAKO in the following manner: 'Grooming'\n",
"At 2019-06-19 09:11:00+00:00 FELIPE interacted with MAKO in the following manner: 'Behavior'\n",
"...\n",
"\n",
"Individual updates for 'Touching' and 'Carrying:\n",
Expand Down Expand Up @@ -435,7 +435,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 12,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -485,15 +485,15 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Felipe's favourite baboons in descending order are [('NEKKE', 41), ('ANGELE', 31), ('MAKO', 26), ('LOME', 23), ('LIPS', 11), ('HARLEM', 10), ('FANA', 8), ('MALI', 6), ('FEYA', 5), ('ARIELLE', 5), ('EWINE', 5), ('PIPO', 3), ('SELF', 2), ('BOBO', 1), ('ATMOSPHERE', 1), ('PETOULETTE', 1), ('VIOLETTE', 1), ('MUSE', -1)]\n",
"EXTERNE is the most annoying monkey with an average score of -2.0\n"
"Felipe's favourite baboons in descending order are [('NEKKE', 82), ('ANGELE', 62), ('MAKO', 52), ('LOME', 46), ('LIPS', 22), ('HARLEM', 20), ('FANA', 16), ('MALI', 12), ('FEYA', 10), ('ARIELLE', 10), ('EWINE', 10), ('PIPO', 6), ('SELF', 4), ('BOBO', 2), ('ATMOSPHERE', 2), ('PETOULETTE', 2), ('VIOLETTE', 2), ('MUSE', -2)]\n",
"EXTERNE is the most annoying monkey with an average score of -4.0\n"
]
}
],
Expand Down Expand Up @@ -547,16 +547,16 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Across the full dataset LOME interacted with NEKKE 41 times\n",
"Between None and 2019-06-13 12:17:19+00:00, LOME interacted with NEKKE 8 times\n",
"Window start: 2019-06-13 00:00:00+00:00, First update: 2019-06-13 10:18:00+00:00, Last update: 2019-06-13 15:05:00+00:00, Window End: 2019-06-14 00:00:00+00:00\n"
"Across the full dataset LOME interacted with NEKKE 82 times\n",
"Between None and 2019-06-13 12:17:19+00:00, LOME interacted with NEKKE 16 times\n",
"Window start: 2019-06-12 23:00:00+00:00, First update: 2019-06-13 10:18:00+00:00, Last update: 2019-06-13 15:05:00+00:00, Window End: 2019-06-13 23:00:00+00:00\n"
]
}
],
Expand Down Expand Up @@ -601,7 +601,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -646,14 +646,14 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total weight across all edges is 2948.\n",
"Total weight across all edges is 5896.\n",
"Total weight across Grooming and Resting is 1685.\n",
"Total weight across Grooming and Resting between 2019-06-13 00:00:00 and 2019-06-20 00:00:00 is 403.\n"
]
Expand Down Expand Up @@ -701,7 +701,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -759,7 +759,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 18,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -801,7 +801,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 19,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -848,7 +848,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 20,
"metadata": {},
"outputs": [
{
Expand Down
Loading

0 comments on commit caa8927

Please sign in to comment.