7. Linked List
Python doesn't have a built-in linked list, but you can implement one using classes.
8. Heap (Priority Queue)
Python’s heapq module implements a binary heap.
Python doesn't have a built-in linked list, but you can implement one using classes.
# Node class to represent a single node in the linked list
class Node:
def __init__(self, data):
self.data = data # Data held by the node
self.next = None # Pointer to the next node in the list
# LinkedList class to manage the linked list
class LinkedList:
def __init__(self):
self.head = None # Initialize the head of the list as None
# Method to append a new node to the end of the list
def append(self, data):
new_node = Node(data) # Create a new node with the given data
if self.head is None:
self.head = new_node # If the list is empty, set the new node as the head
return
last = self.head
while last.next: # Traverse to the end of the list
last = last.next
last.next = new_node # Set the next of the last node to the new node
# Method to print the linked list
def print_list(self):
current = self.head
while current:
print(current.data, end=" -> ")
current = current.next
print("None")
# Method to delete the first occurrence of a node with the given data
def delete(self, data):
current = self.head
# If the head node holds the data to be deleted
if current and current.data == data:
self.head = current.next # Change the head to the next node
current = None # Free the old head node
return
# Search for the node to be deleted, keeping track of the previous node
prev = None
while current and current.data != data:
prev = current
current = current.next
# If the data was not present in the list
if current is None:
print("Node not found in the list.")
return
# Unlink the node from the list
prev.next = current.next
current = None
# Example usage:
if __name__ == "__main__":
# Create a linked list
linked_list = LinkedList()
# Append some elements to the list
linked_list.append(1)
linked_list.append(2)
linked_list.append(3)
# Print the list
print("Original Linked List:")
linked_list.print_list()
# Delete a node
linked_list.delete(2)
# Print the list after deletion
print("Linked List after deleting 2:")
linked_list.print_list()
8. Heap (Priority Queue)
Python’s heapq module implements a binary heap.
import heapq
heap = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]
heapq.heapify(heap)
smallest = heapq.heappop(heap)
9. Tree (Binary Tree Example)
Python doesn't have built-in tree structures, but you can implement one using classes.
10. Graph (Adjacency List Example)
You can use dictionaries or lists to represent graphs in Python.
Python doesn't have built-in tree structures, but you can implement one using classes.
# Node class for a binary tree
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
# Function to perform an in-order traversal (left, root, right)
def inorder(root):
if root:
inorder(root.left)
print(root.data, end=" ")
inorder(root.right)
# Example usage:
if __name__ == "__main__":
# Create the binary tree
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
# In-order traversal
inorder(root)
10. Graph (Adjacency List Example)
You can use dictionaries or lists to represent graphs in Python.
graph = {
'A': ['B', 'C'],
'B': ['A', 'D', 'E'],
'C': ['A', 'F'],
'D': ['B'],
'E': ['B', 'F'],
'F': ['C', 'E']
}
Synchronizing Numba and NumPy RNG States for Consistent Behavior
The Numba RNG state and NumPy RNG states are entirely separate. Therefore calling np.random.seed() will only impact the NumPy RNG seed and this explains the behaviour in the above. To make Numba's RNG state the same as NumPy's, the np.random.seed() function needs calling from within a JIT compiled region, for example:
The Numba RNG state and NumPy RNG states are entirely separate. Therefore calling np.random.seed() will only impact the NumPy RNG seed and this explains the behaviour in the above. To make Numba's RNG state the same as NumPy's, the np.random.seed() function needs calling from within a JIT compiled region, for example:
pythonThe third should be different, but still repeatable by re-execution of the script.
import numpy as np
from numba import jit
from numba.extending import register_jitable
@register_jitable # This will run in JIT mode only if called from a JIT function
def set_seed_compat(x):
np.random.seed(x)
@jit(nopython=True)
def get_random():
set_seed_compat(42)
print(np.random.rand(3))
def get_radnom2():
print(np.random.rand(3))
get_random()
get_random.py_func()
get_radnom2()
#[0.37454012 0.95071431 0.73199394]
#[0.37454012 0.95071431 0.73199394]
#[0.59865848 0.15601864 0.15599452]
# Introduction to Python Package with C++ Integration
I am sharing a demo Python package that demonstrates the integration of C++ code using SWIG (Simplified Wrapper and Interface Generator). This project allows users to leverage the performance advantages of C++ while utilizing the simplicity of Python.
## Key Features
- C++ Integration: The package includes C++ code wrapped with SWIG, facilitating efficient function calls from Python.
- Easy Installation: I've prepared both
- Cross-Platform Compatibility: Designed for compatibility across different platforms, this package can be installed and run without compatibility issues.
Github
Medium
I am sharing a demo Python package that demonstrates the integration of C++ code using SWIG (Simplified Wrapper and Interface Generator). This project allows users to leverage the performance advantages of C++ while utilizing the simplicity of Python.
## Key Features
- C++ Integration: The package includes C++ code wrapped with SWIG, facilitating efficient function calls from Python.
- Easy Installation: I've prepared both
pyproject.toml
and setup.py
files to enable seamless C++ code compilation during pip installation. The package also automatically detects and compiles any additional C++ modules, eliminating the need for manual configuration changes.- Cross-Platform Compatibility: Designed for compatibility across different platforms, this package can be installed and run without compatibility issues.
Github
Medium
Medium
Introduction to Python Package with C++ Integration
I am sharing a demo Python package that demonstrates the integration of C++ code using #Swig (Simplified Wrapper and Interface Generator)…
NVIDIA CUDA Virtual Connect With Experts Event Information
We are starting a monthly virtual event where CUDA enthusiasts can connect directly with a panel of real-life CUDA developers at NVIDIA. This is a chance to meet some of the people designing and implementing your favorite CUDA drivers, kernels, libraries and tools; and ask questions related to your project or work.
Event Information:
When?
Friday, September 27, 2024 at 10-11:30am PT
What?
This month, we will be discussing the CUDA Python ecosystem. You will have the opportunity to ask questions via chat about topics like CuPy, Numba, and other Python libraries to our LIVE panel of CUDA Python experts.
Who can Attend?
CUDA and Python developers of all levels and backgrounds.
Where?
Join us on NVIDIA’s Microsoft Teams Instance here
We are starting a monthly virtual event where CUDA enthusiasts can connect directly with a panel of real-life CUDA developers at NVIDIA. This is a chance to meet some of the people designing and implementing your favorite CUDA drivers, kernels, libraries and tools; and ask questions related to your project or work.
Event Information:
When?
Friday, September 27, 2024 at 10-11:30am PT
What?
This month, we will be discussing the CUDA Python ecosystem. You will have the opportunity to ask questions via chat about topics like CuPy, Numba, and other Python libraries to our LIVE panel of CUDA Python experts.
Who can Attend?
CUDA and Python developers of all levels and backgrounds.
Where?
Join us on NVIDIA’s Microsoft Teams Instance here
Microsoft Teams
Join conversation
👍1
Less known features of C
https://jorenar.com/blog/less-known-c
https://jorenar.com/blog/less-known-c
Jorenar
Lesser known tricks, quirks and features of C
❤1
How AI is Changing Coding and Education
FREE STANFORD WEBINAR
October 9, 2024 | 11:00-11:45 am PT
Registration
FREE STANFORD WEBINAR
October 9, 2024 | 11:00-11:45 am PT
Registration
Installing Lama locally
Video
https://ollama.com/library/llama3.2
Video
https://ollama.com/library/llama3.2
bash
sudo ufw allow 1143/tcp
curl -fsSL https://ollama.com/install.sh | sh
# v3.1, 8billions parameters
ollama pull llama3.1:8b
ollama run llama3.1
# v3.2, 3 billions parameters
ollama pull llama3.2
ollama run llama3.2
# http://127.0.0.1:11434/ to check ollama is working
Scientific Programming
Installing Lama locally Video https://ollama.com/library/llama3.2 bash sudo ufw allow 1143/tcp curl -fsSL https://ollama.com/install.sh | sh # v3.1, 8billions parameters ollama pull llama3.1:8b ollama run llama3.1 # v3.2, 3 billions parameters ollama…
www.deeplearning.ai
Introducing Multimodal Llama 3.2 - DeepLearning.AI
Try out the features of the new Llama 3.2 models to build AI applications with multimodality.
NotebookLM from Google has new feature to make a podcast from provided resources, it's pretty cool to try.
Video for more information.
Video for more information.
YouTube
NotebookLM: Will Instant Podcasts Transform Learning?
Exploring Google's Notebook LM and Illuminate: A New Era of AI-Powered Learning Tools
In this video, I'll be demonstrating Google's Notebook LM and Illuminate experiment, both of which have gained attention on social media due to their innovative features.…
In this video, I'll be demonstrating Google's Notebook LM and Illuminate experiment, both of which have gained attention on social media due to their innovative features.…
Daily_Dose_Of_Data_Science_Full_Archive.pdf
88.3 MB
Daily dose of data science archive 2024
This media is not supported in your browser
VIEW IN TELEGRAM
How to use open wbui and run LLM models locally:
The cleanest method is to use docker, So if you have installed docker on your local machine and also have installed olama just need to download the image from docker with the following command:
find more options from here.
I uploaded a 360 page book and asked some questions, seems work fine.
Every thing runs locally without need to connect internet after getting the models.
Demo credit: Tarfandoon
The cleanest method is to use docker, So if you have installed docker on your local machine and also have installed olama just need to download the image from docker with the following command:
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main
find more options from here.
I uploaded a 360 page book and asked some questions, seems work fine.
Every thing runs locally without need to connect internet after getting the models.
Demo credit: Tarfandoon
Scientific Programming
How to use open wbui and run LLM models locally: The cleanest method is to use docker, So if you have installed docker on your local machine and also have installed olama just need to download the image from docker with the following command: docker run…
Equivalently or even easier :
https://lmstudio.ai/
I am still trying this one, Got some issue reading articles in PDF. Only read Citation part :| .
https://lmstudio.ai/
I am still trying this one, Got some issue reading articles in PDF. Only read Citation part :| .
LM Studio
LM Studio - Download and run LLMs on your computer
Run gpt-oss, Llama, Gemma, Qwen, and DeepSeek locally and privately.
https://centuri-livingsystems.org/recruitment/
PhD and postdoc Applications Now Open
The deadline for submission is January 27.
CENTURI, Marseille, France
PhD and postdoc Applications Now Open
The deadline for submission is January 27.
CENTURI, Marseille, France
Centuri Living Systems
Careers - Centuri Living Systems
Creating a dense and diversified network of distinguished researchers is at the core of CENTURI’s mission. Since its creation in 2017, CENTURI has been proactive in federating a community of scientists from very different backgrounds. PhD Applications Now…
#j2p: A simple Python package to convert Jupyter notebooks to Python scripts.
If you find yourself needing to convert a notebook to a Python script, you likely turn to nbconvert. However, this often results in a script with annoying cell separators. Consequently, you may try manually removing these extra lines to focus solely on the code itself.
This tiny package provide a cleaner solution
## Installation
## Usage
output name is optional.
P.S:
There is already a package (not by me) for the reverse action
GitHub: https://github.com/Ziaeemehr/j2p
If you find yourself needing to convert a notebook to a Python script, you likely turn to nbconvert. However, this often results in a script with annoying cell separators. Consequently, you may try manually removing these extra lines to focus solely on the code itself.
This tiny package provide a cleaner solution
## Installation
pip install ju2py
## Usage
j2p example.ipynb [output.py]
output name is optional.
P.S:
There is already a package (not by me) for the reverse action
pip install p2j
p2j example.py
GitHub: https://github.com/Ziaeemehr/j2p
GitHub
GitHub - Ziaeemehr/j2p: A Tiny Python package to convert Jupyter notebooks to Python scripts.
A Tiny Python package to convert Jupyter notebooks to Python scripts. - Ziaeemehr/j2p
👍3