### Installing DvG_RingBuffer Python Library Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This snippet shows the standard method for installing the DvG_RingBuffer library using pip, the Python package installer. It's a prerequisite for using the library's functionalities. ```python pip install dvg-ringbuffer ``` -------------------------------- ### Indexing and Slicing DvG_RingBuffer in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This example demonstrates various ways to access elements within the `DvG_RingBuffer` using standard Python indexing and slicing. It covers positive and negative indexing, basic slicing, and advanced indexing with NumPy arrays, showing how the buffer behaves after extending beyond its capacity. ```python from dvg_ringbuffer import RingBuffer import numpy as np rb = RingBuffer(4, dtype=np.int) rb.extend([1, 2, 3, 4, 5]) x = rb[0] x = rb[-1] x = rb[:3] x = rb[np.array([0, 2, -1])] ``` -------------------------------- ### Appending Single Values to DvG_RingBuffer in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This example demonstrates how to use the `append` method to add single values to the right side of the ring buffer. It illustrates the buffer's behavior when it reaches full capacity and overwrites older elements. ```python rb = RingBuffer(3, dtype=np.int) rb.append(1) rb.append(2) rb.append(3) rb.append(4) ``` -------------------------------- ### Extending DvG_RingBuffer with Multiple Values in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This example illustrates the `extend` method, used to add multiple values from an iterable to the right side of the ring buffer. It shows how the buffer handles extending with lists of varying lengths, including cases where the buffer overflows and older elements are discarded. ```python rb = RingBuffer(3, dtype=np.int) rb.extend([1]) rb.extend([2, 3]) rb.extend([4, 5, 6, 7]) ``` -------------------------------- ### Cloning a Fork Locally - Shell Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/CONTRIBUTING.rst This command clones your forked repository from GitHub to your local machine, allowing you to begin local development. It establishes a local copy of the project files. ```Shell git clone git@github.com:Dennis-van-Gils/python-dvg-ringbuffer.git ``` -------------------------------- ### Creating a New Development Branch - Shell Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/CONTRIBUTING.rst This Git command creates and switches to a new branch for your local development work. It's crucial for isolating your changes and preparing them for a pull request. ```Shell git checkout -b name-of-your-bugfix-or-feature ``` -------------------------------- ### Committing and Pushing Changes to GitHub - Shell Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/CONTRIBUTING.rst These Git commands stage all modified files, commit them with a descriptive message, and then push the changes from your local branch to your remote fork on GitHub. This prepares your work for a pull request. ```Shell git add . git commit -m "Your detailed description of your changes." git push origin name-of-your-bugfix-or-feature ``` -------------------------------- ### Running Project Tests with Coverage - Shell Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/CONTRIBUTING.rst This command executes the project's tests using pytest, including coverage reporting to identify missing test coverage. It ensures that your changes do not introduce regressions and are adequately tested. ```Shell pytest --cov-report term-missing --cov=src -vv ``` -------------------------------- ### Multi-dimensional Indexing and Slicing DvG_RingBuffer in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This snippet illustrates how to handle multi-dimensional data within the `DvG_RingBuffer` using indexing and slicing. It shows the creation of a buffer with a specified shape (`(capacity, 2)`) and demonstrates accessing full rows, specific elements, and columns using NumPy-style indexing. ```python import numpy as np rb = RingBuffer(5, dtype=(np.int, 2)) rb.append([1, 2]) rb.append([3, 4]) rb.append([5, 6]) x = rb[0] x = rb[0, :] x = rb[:, 0] ``` -------------------------------- ### Initializing and Manipulating RingBuffer in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/wieser/README.md This snippet demonstrates how to initialize a `RingBuffer` with a specified capacity and data type (e.g., boolean). It then shows basic operations like appending elements to the right (`append`) and to the left (`appendleft`), and finally converts the ring buffer to a NumPy array for inspection. This requires the `numpy` and `numpy_ringbuffer` libraries. ```Python import numpy as np from numpy_ringbuffer import RingBuffer r = RingBuffer(capacity=4, dtype=np.bool) r.append(True) r.appendleft(False) print(np.array(r)) # array([False, True]) ``` -------------------------------- ### Appending Single Values from Left to DvG_RingBuffer in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This snippet shows the `appendleft` method, which adds single values to the left side of the ring buffer. It demonstrates how new elements push existing ones to the right, eventually overwriting the oldest elements when the buffer is full. ```python rb = RingBuffer(3, dtype=np.int) rb.appendleft(1) rb.appendleft(2) rb.appendleft(3) rb.appendleft(4) ``` -------------------------------- ### Extending DvG_RingBuffer from Left with Multiple Values in Python Source: https://github.com/dennis-van-gils/python-dvg-ringbuffer/blob/master/README.rst This snippet demonstrates the `extendleft` method, which adds multiple values from an iterable to the left side of the ring buffer. It highlights how elements are added in reverse order of the input iterable and how the buffer manages overflow by removing elements from the right. ```python rb = RingBuffer(3, dtype=np.int) rb.extendleft([1]) rb.extendleft([3, 2]) rb.extendleft([7, 6, 5, 4]) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.