Skip to content

Commit

Permalink
ENH: Refactor code to name the package Pyseldonlib
Browse files Browse the repository at this point in the history
  • Loading branch information
User-DK committed Aug 25, 2024
1 parent 6804cef commit a018d46
Show file tree
Hide file tree
Showing 57 changed files with 458 additions and 553 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
outputs:
message: ${{ steps.commit_message.outputs.message }}
steps:
- name: Checkout pyseldon
- name: Checkout pyseldonlib
uses: actions/checkout@v4
# Gets the correct commit message for pull request
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ repos:
rev: v0.0.241
hooks:
- id: ruff
files: ^tests/|^pyseldon/
files: ^tests/|^pyseldonlib/
12 changes: 6 additions & 6 deletions Project.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PySeldon
![pyseldon](https://raw.githubusercontent.com/User-DK/pyseldon/main/res/logotext.png)
PySeldon is a Python Package for Opinion Dynamics Simulation, an extension of the [`Seldon Framework`](https://github.com/seldon-code/seldon). It provides:
# PySeldonlib
![pyseldonlib](https://raw.githubusercontent.com/User-DK/pyseldon/main/res/logotext.png)
PySeldonlib is a Python Package for Opinion Dynamics Simulation, an extension of the [`Seldon Framework`](https://github.com/seldon-code/seldon). It provides:

- Tools for the simulation of various Opinion Dynamics Models like the classical DeGroot Model, Deffuant Model, Activity Driven Model, etc.
- Tools to create, manipulate, and study complex networks which are either randomly generated or provided by the user.
Expand Down Expand Up @@ -39,15 +39,15 @@ We can conclude that the agents have reached a consensus after the simulation.
### Usage

```python
import pyseldon
import pyseldonlib

pyseldonlib.run_simulation_from_config_file(config_file_path = '/path/to/config/file')
```

```python
import pyseldon
import pyseldonlib

model = pyseldon.DeGroot_Model(max_iterations=1000,
model = pyseldonlib.DeGroot_Model(max_iterations=1000,
convergence_tol=1e-6,
rng_seed=120,
other_settings=other_settings)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyseldon
# pyseldonlib
![](https://raw.githubusercontent.com/User-DK/pyseldon/main/res/logotext.png)

## Python bindings for the Seldon framework
Expand Down
2 changes: 1 addition & 1 deletion bindings_package/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from pyseldon import seldoncore
from pyseldonlib import seldoncore
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import os
import sys

sys.path.insert(0, os.path.abspath('../pyseldon'))
sys.path.insert(0, os.path.abspath('../pyseldonlib'))

project = 'pyseldon'
project = 'pyseldonlib'
copyright = '2024, PySeldon Developers'
author = 'Amrita Goswami, Daivik Karbhari, Moritz Sallermann, Rohit Goswami'
release = '1.0'
Expand Down Expand Up @@ -51,10 +51,10 @@
html_theme_options = {
"show_toc_level": 2,
"icon_links": [
{"name": "Home Page", "url": "https://github.com/seldon-code/pyseldon", "icon": "fas fa-home"},
{"name": "Home Page", "url": "https://github.com/seldon-code/pyseldonlib", "icon": "fas fa-home"},
{
"name": "GitHub",
"url": "https://github.com/seldon-code/pyseldon",
"url": "https://github.com/seldon-code/pyseldonlib",
"icon": "fab fa-github-square",
},
],
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/degrootmodel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"import pyseldon\n",
"import pyseldonlib\n",
"import pathlib\n",
"import shutil"
]
Expand All @@ -38,7 +38,7 @@
"metadata": {},
"outputs": [],
"source": [
"other_settings = pyseldon.Other_Settings(n_output_agents=10,\n",
"other_settings = pyseldonlib.Other_Settings(n_output_agents=10,\n",
" n_output_network= None, \n",
" print_progress= True, \n",
" output_initial=True, \n",
Expand Down Expand Up @@ -106,7 +106,7 @@
}
],
"source": [
"model = pyseldon.DeGroot_Model(max_iterations=1000,\n",
"model = pyseldonlib.DeGroot_Model(max_iterations=1000,\n",
" convergence_tol=1e-6,\n",
" rng_seed=120, \n",
" other_settings=other_settings)\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example Usage of the Network Class from the pyseldon Package"
"# Example Usage of the Network Class from the pyseldonlib Package"
]
},
{
Expand All @@ -14,7 +14,7 @@
"outputs": [],
"source": [
"# Import necessary modules\n",
"import pyseldon"
"import pyseldonlib"
]
},
{
Expand All @@ -24,7 +24,7 @@
"outputs": [],
"source": [
"# Initialize the Network object\n",
"network = pyseldon.Network(\n",
"network = pyseldonlib.Network(\n",
" model_string=\"DeGroot\",\n",
" neighbour_list=[[1, 2], [0, 2], [0, 1], [4], [3]],\n",
" weight_list=[[0.5, 0.5], [0.5, 0.5], [0.5, 0.5], [1], [1]],\n",
Expand Down
8 changes: 4 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.. image:: ../res/PySeldon_1.svg
:align: left
:width: 800px
:alt: PySeldon
:alt: PySeldonlib

PySeldon Documentation
=======================
PySeldonlib Documentation
=========================

Welcome to the **PySeldon** Documentation. PySeldon is a Python Package for Opinion Dynamics Simulation, an extension of the `Seldon Framework <https://github.com/seldon-code/seldon>`_.
Welcome to the **PySeldonlib** Documentation. PySeldonlib is a Python Package for Opinion Dynamics Simulation, an extension of the `Seldon Framework <https://github.com/seldon-code/seldon>`_.
It provides:

- tools for simulation of various Opinion Dynamics Models like the classical DeGroot Model, Deffuant Model, Activity Driven Model, etc.
Expand Down
2 changes: 1 addition & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ You can install the package from PYPI using `pip`:

.. code-block:: bash
$ pip install pyseldon
$ pip install pyseldonlib
From Source
Expand Down
6 changes: 3 additions & 3 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Quick Start Guide
=================

This guide will help you get started with the basics of using the `pyseldon` package.
This guide will help you get started with the basics of using the `pyseldonlib` package.

Installation
------------
Expand All @@ -16,9 +16,9 @@ Usage

.. code-block:: python
import pyseldon
import pyseldonlib
pyseldon.run_simulation_from_config_file(
pyseldonlib.run_simulation_from_config_file(
config_file_path="path/to/config.toml",
agent_file_path="path/to/agent.csv",
network_file_path="path/to/network.csv",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/activitydriven.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Activity Driven Model
=====================

.. automodule:: pyseldon.ActivityDrivenModel
.. automodule:: pyseldonlib.ActivityDrivenModel
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/deffuant.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Deffuant Model
==============

.. automodule:: pyseldon.DeffuantModel
.. automodule:: pyseldonlib.DeffuantModel
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/deffuantvector.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Deffuant Vector Model
======================

.. automodule:: pyseldon.DeffuantVectorModel
.. automodule:: pyseldonlib.DeffuantVectorModel
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/degroot.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DeGroot Model
=============

.. automodule:: pyseldon.DeGrootModel
.. automodule:: pyseldonlib.DeGrootModel
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ This is the class and function reference of PySeldon.
introduction
models
network
util
packagereference
2 changes: 1 addition & 1 deletion docs/source/reference/inertial.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Activity Driven Inertial Model
==============================

.. automodule:: pyseldon.InertialModel
.. automodule:: pyseldonlib.InertialModel
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/models.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Models
======
The following models are available in the `pyseldon` package:
The following models are available in the `pyseldonlib` package:

.. toctree::
:maxdepth: 4
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/network.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
network
=======

.. automodule:: pyseldon.network
.. automodule:: pyseldonlib.network
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
2 changes: 1 addition & 1 deletion docs/source/reference/packagereference.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Complete Api Reference
======================

.. automodule:: pyseldon.__init__
.. automodule:: pyseldonlib.__init__
:members: True
:undoc-members: True
:show-inheritance: True
Expand Down
8 changes: 8 additions & 0 deletions docs/source/reference/util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
util
====

.. automodule:: pyseldonlib.utils
:members: True
:undoc-members: True
:show-inheritance: True
:inherited-members: True
26 changes: 14 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('pyseldon', 'cpp',
project('pyseldonlib', 'cpp',
version: '1.0.0',
default_options: ['cpp_std=c++20', 'warning_level=3'])

Expand Down Expand Up @@ -32,17 +32,19 @@ py.extension_module(

py.install_sources(
[
'pyseldon/__init__.py',
'pyseldon/_basemodel.py',
'pyseldon/DeGrootModel.py',
'pyseldon/DeffuantModel.py',
'pyseldon/DeffuantVectorModel.py',
'pyseldon/ActivityDrivenModel.py',
'pyseldon/InertialModel.py',
'pyseldon/network.py',
'pyseldon/_othersettings.py',
'pyseldon/_run_simulation.py',
'pyseldonlib/__init__.py',
'pyseldonlib/_basemodel.py',
'pyseldonlib/DeGrootModel.py',
'pyseldonlib/DeffuantModel.py',
'pyseldonlib/DeffuantVectorModel.py',
'pyseldonlib/ActivityDrivenModel.py',
'pyseldonlib/InertialModel.py',
'pyseldonlib/network.py',
'pyseldonlib/_othersettings.py',
'pyseldonlib/_run_simulation.py',
'pyseldonlib/utils.py',

],
pure: false, # do not install next to compiled extension
subdir: 'pyseldon'
subdir: 'pyseldonlib'
)
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ classifiers = [
]

[project.urls]
"Source Code" = "https://github.com/seldon-code/pyseldon"
Documentation = "https://seldon-code.github.io/pyseldon"
"Source Code" = "https://github.com/seldon-code/pyseldonlib"
Documentation = "https://seldon-code.github.io/pyseldonlib/"

[build-system]
requires = ["pybind11","meson-python","setuptools>=42", "wheel", "setuptools_scm"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Temporal Dynamics
-----------------
max_iterations:
Limits the total number of simulation steps.
If set to None, the model runs indefinitely, allowing for long-term analysis of opinion evolution.
Expand All @@ -20,7 +19,6 @@
Agent Behavior and Interaction
------------------------------
m:
Determines how many agents an active agent interacts with during each time step.
Influences the rate of opinion spreading; higher values mean more interactions and potentially faster consensus or polarization.
Expand All @@ -47,14 +45,12 @@
Social Context and Controversialness
------------------------------------
alpha:
Controls the degree of controversialness of the issue being simulated.
A higher alpha can lead to more polarized opinions, as agents might have stronger reactions to the issue.
Bots and External Influence
---------------------------
n_bots:
Specifies the number of bots in the simulation, which are fixed in their opinions.
Bots influence the network without being influenced, potentially driving opinion shifts or reinforcing certain views.
Expand All @@ -65,7 +61,6 @@
Reluctance and Activity Correlation
-----------------------------------
use_reluctances:
Activates the feature where agents have a reluctance to change their opinions.
Adds complexity by simulating resistance to change, affecting how quickly or slowly opinions evolve.
Expand All @@ -80,7 +75,7 @@
Example:
---------
>>> from pyseldon import Activity_Driven_Model
>>> from pyseldonlib import Activity_Driven_Model
>>> # Create the Activity Driven Model
>>> model = Activity_Driven_Model(max_iterations=1000, convergence_tol=1e-6)
>>> # Run the simulation
Expand Down
3 changes: 1 addition & 2 deletions pyseldon/DeGrootModel.py → pyseldonlib/DeGrootModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Key features
------------
Opinion Averaging:
Agents update their opinions based on the average opinions of their neighbors, fostering convergence and consensus.
Expand All @@ -21,7 +20,7 @@
Example:
---------
>>> from pyseldon import DeGroot_Model
>>> from pyseldonlib import DeGroot_Model
>>> # Create the DeGroot Model
>>> model = DeGroot_Model(max_iterations=1000, convergence_tol=1e-6)
>>> # Run the simulation
Expand Down
3 changes: 1 addition & 2 deletions pyseldon/DeffuantModel.py → pyseldonlib/DeffuantModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Model Dynamics
--------------
Homophily Threshold:
If the difference in opinions between two interacting agents is less than this threshold, they will update their opinions towards each other. This process leads to opinion convergence or clustering depending on the value of the threshold.
Expand All @@ -15,7 +14,7 @@
Example:
---------
>>> from pyseldon import Deffuant_Model
>>> from pyseldonlib import Deffuant_Model
>>> # Create the Deffuant Model
>>> deffuant = Deffuant_Model(max_iterations=1000, homophily_threshold=0.2, mu=0.5)
>>> # Run the simulation
Expand Down
Loading

0 comments on commit a018d46

Please sign in to comment.