arachnea


Namearachnea JSON
Version 0.0.5 PyPI version JSON
download
home_pagehttps://github.com/yourusername/arachnea
SummaryA Python library for efficient array operations using a fluent API.
upload_time2024-08-12 09:42:12
maintainerNone
docs_urlNone
authorSuhan
requires_pythonNone
licenseMIT
keywords array operations data processing lightweight python library
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # arachnea

arachnea is a Python library that allows you to perform efficient array operations using a fluent API approach inspired by the agility and efficiency of spiders.

## Features

- **Map**: Transform each element of an array using a provided function.
- **Filter**: Filter elements of an array based on a provided condition.
- **Reduce**: Reduce an array to a single value based on a provided accumulator and transformation function.
- **Find**: Find the first element in the array that meets the given condition.
- **Remove**: Remove the first element in the array that meets the given condition.
- **ForEach**: Execute a provided function once for each array element.

## Installation

You can install arachnea via pip:

```bash
pip install arachnea
```

## Usage

### Basic Usage

```python
from arachnea import arachnea

numbers = [1, 2, 3, 4, 5]

arachnea(numbers).for_each(lambda num: print(num * 2))  # Example of using forEach
```

### API Examples

#### Mapping and Reducing

```python
numbers = [1, 2, 3, 4, 5]

sum_of_squares = (
    arachnea(numbers)
    .map(lambda num: num * num)
    .reduce(lambda acc, num: acc + num, 0)
)

print(sum_of_squares)  # Output: 55
```

#### Filtering and Collecting

```python
numbers = [1, 2, 3, 4, 5]

odd_numbers = (
    arachnea(numbers)
    .filter(lambda num: num % 2 != 0)
    .collect()
)

print(odd_numbers)  # Output: [1, 3, 5]
```

#### Removing Elements

```python
numbers = [1, 2, 3, 4, 5]

remove_4 = (
    arachnea(numbers)
    .map(lambda num: num * num)
    .remove(4)
    .collect()
)

print(remove_4)  # Output: [1, 9, 16, 25]
```

#### Finding Elements

```python
numbers = [1, 2, 3, 4, 5]

greater_than_twenty_four = (
    arachnea(numbers)
    .map(lambda num: num * num)
    .find(lambda num: num > 24)
)

print(greater_than_twenty_four)  # Output: 25
```

#### Chaining Operations

```python
numbers = [1, 2, 3, 4, 5]

result = (
    arachnea(numbers)
    .filter(lambda num: num > 2)
    .map(lambda num: num * 3)
    .reduce(lambda acc, num: acc + num, 0)
)

print(result)  # Output: 39
```

## API

### `map(transformer: (element: T) => K) -> Stream[K]`

Transforms each element of the array using the provided transformer function.

### `filter(condition: (element: T) => bool) -> Stream[T]`

Filters elements of the array based on the provided boolean condition function.

### `reduce(reducer: (accumulator: K, element: T) => K, initial_value: K) -> K`

Reduces the array to a single value using the provided reducer function and initial value.

### `remove(condition: (element: T) => bool | T) -> Stream[T]`

Removes the first element in the array that meets the given condition or is equal to the given parameter.

### `find(condition: (element: T) => bool | T) -> T`

Finds the first element in the array that meets the given condition or is equal to the given parameter.

### `for_each(action: (element: T) => None) -> None`

Executes a provided function once for each array element.

### `collect() -> List[T]`

Collects the elements after applying all transformations and filters, returning them as a list.

## Todo

- Combine successive filter operations into a single operation.
- Document `actionsLoop` for custom terminating operation injection.
- Improve the performance of atomic operations.
- Add sorting, flattening functionality.
- Enhance performance optimizations.
- Implement error handling for edge cases.

## Contributing

Contributions are welcome! Please fork the repository and submit a pull request.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yourusername/arachnea",
    "name": "arachnea",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "array operations, data processing, lightweight, Python library",
    "author": "Suhan",
    "author_email": "suhan01.bangera@gamil.com",
    "download_url": "https://files.pythonhosted.org/packages/96/ca/63ebf04386a653d1a9e76bf092d0d01255613f8b24e1d921c0e6303873be/arachnea-0.0.5.tar.gz",
    "platform": null,
    "description": "# arachnea\n\narachnea is a Python library that allows you to perform efficient array operations using a fluent API approach inspired by the agility and efficiency of spiders.\n\n## Features\n\n- **Map**: Transform each element of an array using a provided function.\n- **Filter**: Filter elements of an array based on a provided condition.\n- **Reduce**: Reduce an array to a single value based on a provided accumulator and transformation function.\n- **Find**: Find the first element in the array that meets the given condition.\n- **Remove**: Remove the first element in the array that meets the given condition.\n- **ForEach**: Execute a provided function once for each array element.\n\n## Installation\n\nYou can install arachnea via pip:\n\n```bash\npip install arachnea\n```\n\n## Usage\n\n### Basic Usage\n\n```python\nfrom arachnea import arachnea\n\nnumbers = [1, 2, 3, 4, 5]\n\narachnea(numbers).for_each(lambda num: print(num * 2))  # Example of using forEach\n```\n\n### API Examples\n\n#### Mapping and Reducing\n\n```python\nnumbers = [1, 2, 3, 4, 5]\n\nsum_of_squares = (\n    arachnea(numbers)\n    .map(lambda num: num * num)\n    .reduce(lambda acc, num: acc + num, 0)\n)\n\nprint(sum_of_squares)  # Output: 55\n```\n\n#### Filtering and Collecting\n\n```python\nnumbers = [1, 2, 3, 4, 5]\n\nodd_numbers = (\n    arachnea(numbers)\n    .filter(lambda num: num % 2 != 0)\n    .collect()\n)\n\nprint(odd_numbers)  # Output: [1, 3, 5]\n```\n\n#### Removing Elements\n\n```python\nnumbers = [1, 2, 3, 4, 5]\n\nremove_4 = (\n    arachnea(numbers)\n    .map(lambda num: num * num)\n    .remove(4)\n    .collect()\n)\n\nprint(remove_4)  # Output: [1, 9, 16, 25]\n```\n\n#### Finding Elements\n\n```python\nnumbers = [1, 2, 3, 4, 5]\n\ngreater_than_twenty_four = (\n    arachnea(numbers)\n    .map(lambda num: num * num)\n    .find(lambda num: num > 24)\n)\n\nprint(greater_than_twenty_four)  # Output: 25\n```\n\n#### Chaining Operations\n\n```python\nnumbers = [1, 2, 3, 4, 5]\n\nresult = (\n    arachnea(numbers)\n    .filter(lambda num: num > 2)\n    .map(lambda num: num * 3)\n    .reduce(lambda acc, num: acc + num, 0)\n)\n\nprint(result)  # Output: 39\n```\n\n## API\n\n### `map(transformer: (element: T) => K) -> Stream[K]`\n\nTransforms each element of the array using the provided transformer function.\n\n### `filter(condition: (element: T) => bool) -> Stream[T]`\n\nFilters elements of the array based on the provided boolean condition function.\n\n### `reduce(reducer: (accumulator: K, element: T) => K, initial_value: K) -> K`\n\nReduces the array to a single value using the provided reducer function and initial value.\n\n### `remove(condition: (element: T) => bool | T) -> Stream[T]`\n\nRemoves the first element in the array that meets the given condition or is equal to the given parameter.\n\n### `find(condition: (element: T) => bool | T) -> T`\n\nFinds the first element in the array that meets the given condition or is equal to the given parameter.\n\n### `for_each(action: (element: T) => None) -> None`\n\nExecutes a provided function once for each array element.\n\n### `collect() -> List[T]`\n\nCollects the elements after applying all transformations and filters, returning them as a list.\n\n## Todo\n\n- Combine successive filter operations into a single operation.\n- Document `actionsLoop` for custom terminating operation injection.\n- Improve the performance of atomic operations.\n- Add sorting, flattening functionality.\n- Enhance performance optimizations.\n- Implement error handling for edge cases.\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python library for efficient array operations using a fluent API.",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/yourusername/arachnea",
        "Source": "https://github.com/Spyder01/arachnea-python"
    },
    "split_keywords": [
        "array operations",
        " data processing",
        " lightweight",
        " python library"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0fddf4bf8c3df5d7ff267fb6e58585d2cc58fc3cdde8b441f6bb9ce9c04f953b",
                "md5": "f51e694c18fcd0c82d6bffd3e06cac2d",
                "sha256": "b7191613bbd108f74d0658f870bebdd8ff737289cd1af9fcbfac5756598893fe"
            },
            "downloads": -1,
            "filename": "arachnea-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f51e694c18fcd0c82d6bffd3e06cac2d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 5433,
            "upload_time": "2024-08-12T09:42:11",
            "upload_time_iso_8601": "2024-08-12T09:42:11.278588Z",
            "url": "https://files.pythonhosted.org/packages/0f/dd/f4bf8c3df5d7ff267fb6e58585d2cc58fc3cdde8b441f6bb9ce9c04f953b/arachnea-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "96ca63ebf04386a653d1a9e76bf092d0d01255613f8b24e1d921c0e6303873be",
                "md5": "b10d709b2f3a01a6807e7f808144f5f2",
                "sha256": "d27f23c713c810e458eaa919a4066bab475176b6ecf2b035fac3c59a74c8a655"
            },
            "downloads": -1,
            "filename": "arachnea-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "b10d709b2f3a01a6807e7f808144f5f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5208,
            "upload_time": "2024-08-12T09:42:12",
            "upload_time_iso_8601": "2024-08-12T09:42:12.544431Z",
            "url": "https://files.pythonhosted.org/packages/96/ca/63ebf04386a653d1a9e76bf092d0d01255613f8b24e1d921c0e6303873be/arachnea-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-12 09:42:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "arachnea",
    "github_not_found": true,
    "lcname": "arachnea"
}
        
Elapsed time: 0.32761s