Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨 Introducing Python functionality for PCSR #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

nithinmanoj10
Copy link

Exposing the PCSR API using PyBind11 so that users can use PCSR in Python

Made the first commit by creating a README to pcsr-python-support branch
Exposed the Node structure being used inside the pcsr.cpp module as a Python object. The Node object can be created using the object constructor method in python.
@nithinmanoj10
Copy link
Author

Using the pcsr.Node object in Python

Using the rich.inspect module to view the contents of an object.

import pcsr
from rich import inspect

n = pcsr.Node(2,3,4)
inspect(n)

image

Users can now use the PCSR object. All the functions present in the original PCSR.cpp code is not exposed yet. They will be exposed in upcoming commits. Made necessary changes in the cpp code to be compatible with the python version.

Program to test the PCSR Python version is available in test.py. This program initializes a PCSR object with 10 nodes and adds edges using a for-loop. The resulting graph is outputted using the print_graph() method.
@nithinmanoj10
Copy link
Author

Running test.py

Run test.py as follows

python3 test.py

Output
image

@nithinmanoj10 nithinmanoj10 marked this pull request as draft July 2, 2023 07:38
Added the python PCSR API for the following functions:

1. find_value()
2. get_edges()
3. get_size()
4. sparse_matrix_vector_multiplication()
5. bfs()

Decided not to include half_list() function as it's a utility function not being used anywhere
Added description for the PCSR methods
Updated the README to contain documentation on how to use the PCSR class and it's methods.
@nithinmanoj10 nithinmanoj10 marked this pull request as ready for review July 6, 2023 09:41
@nithinmanoj10
Copy link
Author

Why this new feature

Hey @wheatman 👋🏽

I've made some updates to your PCSR project that will significantly enhance its accessibility for Python users. By leveraging the power of PyBind11, this integration simplifies the usage of PCSR within Python environments and Python developers can effortlessly tap into PCSR's functionalities.

To ensure a smooth onboarding experience, I have created a comprehensive README file. This README provides detailed instructions on how to compile and import the PCSR package, enabling users to quickly and effortlessly dive into utilizing its features.

I'm looking forward to your feedback and the opportunity to collaborate further by adding the following features into the PCSR python implementation

  • Publishing the PCSR Python module on PyPI so that developers need not compile the C++ code to get the .so file that is then imported into the python program. Instead, they can directly install and use it from PyPI using a pip install and import command
  • Creating the PCSR graph from a given edge list
  • Function to delete an edge

Best regards
Nithin Manoj

@nithinmanoj10
Copy link
Author

Hey @wheatman 👋🏽,

I hope you're doing well! I wanted to bring your attention to the pull request I submitted recently regarding the Python functionality for the PCSR project. I understand that pull requests can sometimes get lost in the shuffle, so I wanted to kindly remind you about this contribution.

Regards
Nithin Manoj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant