Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
fix: pre-commit errors
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Nov 13, 2023
1 parent 34580d5 commit 2a9430e
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 37 deletions.
6 changes: 3 additions & 3 deletions examples/data/JSON/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
### peacetreaties
This file was created by [Lena Jaskov](https://github.com/yaslena). It is is based on data that is available online in a database focused on European peace treaties from 1450 to 1789 (https://www.ieg-friedensvertraege.de/vertraege).

The database was created as part of a project that was funded by the DFG (German Research Foundation)
The database was created as part of a project that was funded by the DFG (German Research Foundation)
and contains a selection of some 1800 treaties. One extra treaty between Tsarist Russia and the Qing Empire (1689) was manually added by Lena Jaskov.

The data sample here only shows a selection of that data, i.e. filterd on treaties that involve Russia.
The data sample here only shows a selection of that data, i.e. filterd on treaties that involve Russia.
There are only edges between treaties and countries. If a country was involved in a treaty, there will be an edge between that country and the respective treaty.

The data was first scraped into a table in a first step. The original scraped table (CSV) can be found in this [repository](https://github.com/DHARPA-Project/kiara_plugin.network_analysis/blob/develop/examples/data/treaties). The scraping code can be found [here](https://github.com/yaslena/WebScraping).
The data was first scraped into a table in a first step. The original scraped table (CSV) can be found in this [repository](https://github.com/DHARPA-Project/kiara_plugin.network_analysis/blob/develop/examples/data/treaties). The scraping code can be found [here](https://github.com/yaslena/WebScraping).
In a second step the data from the scraping process was restructured to fit the requirements of creating a dynamic bipartite graph with networkX.
Code for restructuring the table data and for generating a bipartite graph with python networkX can be found [here](https://github.com/yaslena/NetworkAnalysis).
The restructured data was converted into JSON with networkX for visualization in JavaScript on [Observable](https://observablehq.com/@yaslena/dynamic-network-graph).
Expand Down
10 changes: 5 additions & 5 deletions examples/data/gexf/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ Most datasets come from here https://github.com/gephi/gephi/wiki/Datasets if not
### lesmis

#### gexf file version: 1.3
The lesmis gephi file represents the same data as the one in gml format found in
The lesmis gephi file represents the same data as the one in gml format found in
Marc Newmans GML dataset collection: http://www-personal.umich.edu/~mejn/netdata/
It also has some additional graph data, like node positions, node colors (by modularity group), node size etc because the gexf format can also store that kind of data.

This gefx file is included as sample data with the installation of the Gephi software.
It seems to be a converted version of Marc Newmans GML file. The reference is the same as for the GML file:

"Les Miserables: coappearance weighted network of characters in the novel Les Miserables.
"Les Miserables: coappearance weighted network of characters in the novel Les Miserables.
D. E. Knuth, The Stanford GraphBase: A Platform for Combinatorial Computing, Addison-Wesley, Reading, MA (1993)."

As the title reveals this data represents a coappearance network. This makes it an **undirected** network.
It is furthermore a **weighted** network, edge weights are named "value" in the gml file.
As the title reveals this data represents a coappearance network. This makes it an **undirected** network.
It is furthermore a **weighted** network, edge weights are named "value" in the gml file.
This is a **one-mode** network because there is only one type of nodes (book characters).
- 77 nodes
- 254 edges (undirected)

### ChineseBuddhism_SNA

#### gexf file version:1.2draft
This gexf file is located in another [repository](https://github.com/DHARPA-Project/kiara.examples/blob/main/examples/data/network_analysis/gexf),
This gexf file is located in another [repository](https://github.com/DHARPA-Project/kiara.examples/blob/main/examples/data/network_analysis/gexf),
because it is too large (20,4 MB).

It comes from this website:
Expand Down
2 changes: 1 addition & 1 deletion examples/data/gexf/lesmis.gexf
Original file line number Diff line number Diff line change
Expand Up @@ -884,4 +884,4 @@
<edge id="249" source="76" target="66"/>
</edges>
</graph>
</gexf>
</gexf>
16 changes: 8 additions & 8 deletions examples/data/gml/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Anthropological Research 33, 452-473 (1977)."

See also: https://en.wikipedia.org/wiki/Zachary%27s_karate_club#cite_note-Data-3

This is a **one-mode** network where nodes represent friends. It is **undirected** and **unweighted**.
This is a **one-mode** network where nodes represent friends. It is **undirected** and **unweighted**.
- 34 nodes
- 78 edges (undirected)

Expand Down Expand Up @@ -62,7 +62,7 @@ adjacencies for the novel "David Copperfield" by Charles Dickens, as
described by M. Newman. Nodes represent the most commonly occurring
adjectives and nouns in the book. Node values are 0 for adjectives and 1
for nouns. Edges connect any pair of words that occur in adjacent position
in the text of the book.
in the text of the book.

Please cite M. E. J. Newman, Finding community
structure in networks using the eigenvectors of matrices, Preprint
Expand Down Expand Up @@ -91,14 +91,14 @@ Additional information on the network can be found in

D. Lusseau, Evidence for social role in a dolphin social network,
Preprint q-bio/0607048 (http://arxiv.org/abs/q-bio.PE/0607048)"

This data represents a **one-mode**, **undirected**, **unweighted** network.

- nodes 62
- edges 159 (undirected)

### football

"The file football.gml contains the network of American football games
between Division IA colleges during regular season Fall 2000, as compiled
by M. Girvan and M. Newman. The nodes have values that indicate to which
Expand Down Expand Up @@ -168,8 +168,8 @@ These data can be cited (as an updated version of)

M. E. J. Newman, The structure of scientific collaboration networks,
Proc. Natl. Acad. Sci. USA 98, 404-409 (2001)."

This dataset represents a **one-mode** (scientists), **undirected**, **weighted** network.

- nodes 40421
- edges 175692 (undirected)
2 changes: 1 addition & 1 deletion examples/data/quakers/Readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This data comes from a programming historian tutorial on network analysis with python.
This data comes from a programming historian tutorial on network analysis with python.
For more context see the Readme file under quakers [here](https://github.com/DHARPA-Project/kiara_plugin.network_analysis/tree/develop/examples/data/gexf).
2 changes: 1 addition & 1 deletion examples/data/treaties/Readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
This data was created by [Lena Jaskov](https://github.com/yaslena).
This data was created by [Lena Jaskov](https://github.com/yaslena).
For more context see under *peacetreaties* [here](https://github.com/DHARPA-Project/kiara_plugin.network_analysis/blob/develop/examples/data/JSON/Readme.md).
8 changes: 4 additions & 4 deletions examples/data/treaties/peace_treaties_rus.csv
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Präliminarvertrag von Krakau," Polen, Russland",1523 II 22
Waffenstillstand von Nowgorod," Russland, Schweden",1524 IV 3
Waffenstillstand von Nowgorod," Russland, Schweden",1537 III 25_IV 4
"Waffenstillstands-, Grenz- und Handelsvertrag von Nowgorod"," Russland, Schweden",1561 VIII
Waffenstillstand von Dorpat," Russland, Schweden",1564 IX
Waffenstillstand von Dorpat," Russland, Schweden",1564 IX
Waffenstillstand von Narva," Russland, Schweden",1583 VIII 10
Ewiger Friede von Tjawzin," Russland, Schweden",1595 V 18
Friedensvertrag von Teusina," Polen, Russland, Schweden",1595 V 18
Expand All @@ -15,7 +15,7 @@ Waffenstillstand von Dederino," Russland, Schweden",1616 II 22
Friedensvertrag von Stolbovo (Beta-Version)," Russland, Schweden",1617 II 27_III 9
Freundschaftsvertrag von Livny," Russland, Siebenbürgen",1623 VI 28_VII 8
Friedensvertrag von Moskau," Russland, Siebenbürgen",1627 XII 18_28
Freundschaftsvertrag von Walujki," Russland, Siebenbürgen",1629 IX
Freundschaftsvertrag von Walujki," Russland, Siebenbürgen",1629 IX
Friedensvertrag von Poljanovka," Polen, Russland",1634 V 17_27
Friedensvertrag (Ewiger Friede) von Poljanovka (Polanów)," Polen, Russland",1634 VI 14
Friedensvertrag von Ilančik," Russland, Siebenbürgen",1638 IX
Expand All @@ -25,10 +25,10 @@ Präliminarvertrag von Moskau," Russland, Schweden",1658 V 25
Stillstandsvertrag von Valiesar," Russland, Schweden",1658 XII 20
Friedensvertrag von Kardis," Russland, Schweden",1661 VI 21
Friedensvertrag von Andrusovo," Polen, Russland",1667 I 20_30
"Bestätigung des Vertrags von Andrusovo (1667 I 20), Radzin"," Polen, Russland",1670 III 7_17
"Bestätigung des Vertrags von Andrusovo (1667 I 20), Radzin"," Polen, Russland",1670 III 7_17
Vertrag über eine Verlängerung von Andrusovo (1667 I 20)," Polen, Russland",1672 IV 9
Waffenstillstand von Moskau," Polen, Russland",1678 VIII 13
Ewiger Friede von Moskau," Polen, Russland",1686 IV 26 / V 6
Ewiger Friede von Moskau," Polen, Russland",1686 IV 26 / V 6
Angriffsbündnis von Wien," Kaiser, Russland, Venedig",1697 I 29
Waffenstillstand von Karlowitz (Beta-Version)," Osmanisches Reich, Russland",1698 XII 25
Allianzvertrag von Moskau," Russland, Sachsen / Polen",1699 XI 11_21
Expand Down
2 changes: 1 addition & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ channels = ["conda-forge", "dharpa"]
platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[tasks]
install-dev-env = "pip install -e '.[dev_utils]'
install-dev-env = "pip install -e '.[dev_utils]'"
pre-commit-check = ".pixi/env/bin/pre-commit run --all-files"
kiara = ".pixi/env/bin/kiara"
show-versions = ".pixi/env/bin/kiara --version"
Expand Down
4 changes: 2 additions & 2 deletions src/kiara_plugin/network_analysis/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""This module contains the value type classes that are used in the ``kiara_plugin.network_analysis`` package.
"""
from typing import Any, List, Mapping, Type, Union, ClassVar
from typing import Any, ClassVar, List, Mapping, Type, Union

from rich.console import Group

Expand Down Expand Up @@ -34,7 +34,7 @@ class NetworkDataType(TablesType):

@classmethod
def python_class(cls) -> Type:
return NetworkData
return NetworkData # type: ignore

def parse_python_obj(self, data: Any) -> NetworkData:

Expand Down
9 changes: 5 additions & 4 deletions src/kiara_plugin/network_analysis/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
"""
from typing import (
TYPE_CHECKING,
ClassVar,
Dict,
Iterable,
List,
Literal,
Protocol,
Type,
TypeVar,
Union, ClassVar,
Union,
)

from pydantic import BaseModel, Field
Expand Down Expand Up @@ -132,7 +133,7 @@ def create_network_data(
nodes_table, edges_table
)

network_data = cls.create_tables(
network_data: NetworkData = cls.create_tables(
{NODES_TABLE_NAME: nodes_table, EDGES_TABLE_NAME: edges_table}
)

Expand Down Expand Up @@ -356,7 +357,7 @@ def query_edges(
import duckdb

con = duckdb.connect()
edges = self.edges.arrow_table # noqak
edges = self.edges.arrow_table # noqa: F841
if relation_name != EDGES_TABLE_NAME:
sql_query = sql_query.replace(relation_name, EDGES_TABLE_NAME)

Expand Down Expand Up @@ -514,7 +515,7 @@ def as_networkx_graph(
"""

graph = graph_type()
graph: NETWORKX_GRAPH_TYPE = graph_type()

def add_node(_node_id: int, **attrs):
graph.add_node(_node_id, **attrs)
Expand Down
4 changes: 2 additions & 2 deletions src/kiara_plugin/network_analysis/models/inputs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from typing import Any, Dict, Union, ClassVar
from typing import Any, ClassVar, Dict, Union

from pydantic import model_validator, Field
from pydantic import Field, model_validator

from kiara.models import KiaraModel
from kiara_plugin.core_types.defaults import DEFAULT_MODEL_KEY
Expand Down
2 changes: 1 addition & 1 deletion src/kiara_plugin/network_analysis/models/metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from typing import ClassVar

from pydantic import field_validator, Field
from pydantic import Field, field_validator

from kiara.models import KiaraModel
from kiara.models.documentation import DocumentationMetadataModel
Expand Down
5 changes: 3 additions & 2 deletions src/kiara_plugin/network_analysis/modules/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def create_outputs_schema(self):
}
}

def process(self, inputs, outputs):
def process(self, inputs, outputs) -> None:

import pyarrow as pa
import rustworkx as rx
Expand All @@ -199,7 +199,8 @@ def process(self, inputs, outputs):
if not cut_points:
raise NotImplementedError()
cut_points_column = [
x in translated_cut_points for x in range(0, network_data.num_nodes)
x in translated_cut_points
for x in range(0, network_data.num_nodes) # noqa: PIE808
]

nodes = network_data.nodes.arrow_table
Expand Down
4 changes: 2 additions & 2 deletions src/kiara_plugin/network_analysis/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def process(self, inputs: ValueMap, outputs: ValueMap, job_log: JobLog) -> None:
)

if nodes_arrow_dataframe is None:
new_node_ids = range(0, len(unique_node_ids_old))
new_node_ids = range(0, len(unique_node_ids_old)) # noqa: PIE808
node_id_map = dict(zip(unique_node_ids_old, new_node_ids))
# node_id_map = {
# node_id: new_node_id
Expand All @@ -421,7 +421,7 @@ def process(self, inputs: ValueMap, outputs: ValueMap, job_log: JobLog) -> None:
~(unique_node_ids_old.is_in(unique_node_ids_nodes_table))
raise NotImplementedError("MISSING NODE IDS NOT IMPLEMENTED YET")
else:
new_node_ids = range(0, len(id_column_old))
new_node_ids = range(0, len(id_column_old)) # noqa: PIE808
node_id_map = dict(zip(id_column_old, new_node_ids))
# node_id_map = {
# node_id: new_node_id
Expand Down

0 comments on commit 2a9430e

Please sign in to comment.