shapeless


Nameshapeless JSON
Version 0.0.9 PyPI version JSON
download
home_pagehttps://github.com/kyegomez/Poly
SummaryPoly - Pytorch
upload_time2023-09-18 20:31:14
maintainer
docs_urlNone
authorKye Gomez
requires_python>=3.6,<4.0
licenseMIT
keywords artificial intelligence deep learning optimizers prompt engineering
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Multi-Modality](agorabanner.png)](https://discord.gg/qUtxnK2NMf)

# Poly 💧
<!-- ![Poly banner](shapeless.png) -->

A Fluid, PolyMorphic,and shapeless Types Package that activates radically flexiblity and simplicity in your programs

[Shapeless Announcement 💧](https://medium.com/@kyeg/embrace-shapelessness-the-design-philosophy-of-the-future-1d530c075789)

-----

## Installation

You can install the package using pip

```bash
pip install shapeless
```
----

# Usage

Here's a simple example of how to use the `Poly` class:

```python
from shapeless import Poly

# Create a Poly object with an integer
p = Poly(10)

# Determine the type of the data
print(p.determine())  # <class 'int'>

# Shift the data to a string
print(p.shift(str))  # '10'

# Validate that the data is a string
print(p.validate(str))  # True
```

You can also use `Poly` as a type hint in your functions:

```python
from shapeless import Poly

def my_func(a: Poly):
    print(type(a))

# Create a Poly object with a string
p = Poly('10')

# Pass the Poly object to my_func
my_func(p)  # <class '__main__.Poly'>
```
------

# `shapeless` Decorator
With the shapeless decorator you can wrap entire classes and transform all their variables into the `Poly` type!

```python
from shapeless import shapeless

@shapeless
class SimpleClass:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def add(self):
        return self.x + self.y
    
sc = SimpleClass(1, 2)
print(sc.add())  # prints 3

```

-----


# `fluid` Decorator
Fluid is like the `shapeless` decorator but for classes, just wrap it around your function to transform all the variables to the `Poly` shapeless type.

```python
from shapeless import fluid

@fluid
def add(a, b):
    return a.data + b.data

print(add(1, 2))
print(add("hello", 'world'))

```

----

# `liquid` Decorator
- The `liquid` decorator acts like `dataclass` but makes all the types the `Poly` type!

```python
from shapeless import liquid

#define the liquid decorator
@liquid
class MyClass:
    x = 1
    y = "hello"

    def run(self):
        print(type(self.x))

obj = MyClass()
print(type(obj.x))
print(type(obj.y))

obj.run()
```

# Why use Shapeless?

Shapeless is a powerful tool for creating fluid programs because it allows developers to handle data types dynamically and polymorphically. This means that the same class or function can handle different types of data, making the program more flexible and versatile.

Shapeless also provides thread safety, which is crucial for multi-threaded applications. This ensures that the data remains consistent and prevents race conditions.

Furthermore, Shapeless provides logging, type aliasing, type annotation, type extension, and serialization and deserialization features. These features make it easier to write, debug, and understand the code, and they allow developers to create more complex and flexible data structures.

In conclusion, Shapeless is a powerful tool for creating fluid programs that can handle a wide range of data types and that are safe, flexible, and easy to understand.

## Benefits

1.  Dynamic Type Handling 🔄: Poly and Shapeless allow developers to handle data types dynamically. This means that the type of data can be determined, selected, shifted, validated, aliased, annotated, extended, serialized, and deserialized on the fly.

2.  Thread Safety 🔒: Both Poly and Shapeless provide thread safety, which is crucial for multi-threaded applications. This ensures that the data remains consistent and prevents race conditions.

3.  Logging 📝: With the verbose option, all operations can be logged. This is useful for debugging and understanding the flow of data and operations in the program.

4.  Polymorphism 🐾: Poly and Shapeless make it easy to create polymorphic classes and functions. This means that the same class or function can handle different types of data, making the program more flexible and versatile.

5.  Type Aliasing 🏷️: Poly allows developers to add aliases for types. This can make the code more readable and easier to understand.

6.  Type Annotation 🖊️: Poly provides a method to annotate the data with a type. This can be useful for static type checking and for making the code more self-explanatory.

7.  Type Extension 🧩: With Poly, the type of the data can be extended with a new type. This allows developers to create more complex and flexible data structures.

8.  Serialization and Deserialization 💾: Poly provides methods to serialize and deserialize the data. This is useful for saving and loading data, and for sending and receiving data over a network.


------

# Documentation
* [Check out shapeless.apac.ai for documentation](https://shapeless.apac.ai)


-----

# Vision
In today's world, programming languages are often divided into statically-typed and dynamically-typed. While statically-typed languages provide type safety and performance benefits, they often lack the flexibility and simplicity that dynamically-typed languages offer. This has led to a growing demand for tools that can bring the benefits of both worlds together.

We believe the future of programming lies in the ability to handle types in a fluid and flexible manner, without sacrificing the benefits of static typing. However, achieving this is not easy. It requires a deep understanding of both static and dynamic typing, as well as the ability to create a tool that is easy to use, performant, and thread-safe.

Many have tried to solve this problem, but none have succeeded. The challenge lies in creating a tool that is both powerful and simple to use. It requires a radical new approach, one that is not constrained by the traditional boundaries of static and dynamic typing.

That's where Poly comes in. Our secret is our deep understanding of the problems with static types. As creators of multi-modality and fluid intelligences with no defined shape, we have the unique insight and expertise needed to solve this problem. We have created a tool that allows you to handle dynamic types in a flexible and thread-safe manner, without sacrificing the benefits of static typing.

We are confident that Poly is the best solution to this problem. With our unique approach and deep expertise, we are perfectly positioned to bring this vision to life. Join us on this journey and experience the future of programming today.



-----


# License
MIT


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kyegomez/Poly",
    "name": "shapeless",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "artificial intelligence,deep learning,optimizers,Prompt Engineering",
    "author": "Kye Gomez",
    "author_email": "kye@apac.ai",
    "download_url": "https://files.pythonhosted.org/packages/68/cd/9dddd75b0870f3e88dd197244e0860e42c864ff9280a8141e93485150e36/shapeless-0.0.9.tar.gz",
    "platform": null,
    "description": "[![Multi-Modality](agorabanner.png)](https://discord.gg/qUtxnK2NMf)\n\n# Poly \ud83d\udca7\n<!-- ![Poly banner](shapeless.png) -->\n\nA Fluid, PolyMorphic,and shapeless Types Package that activates radically flexiblity and simplicity in your programs\n\n[Shapeless Announcement \ud83d\udca7](https://medium.com/@kyeg/embrace-shapelessness-the-design-philosophy-of-the-future-1d530c075789)\n\n-----\n\n## Installation\n\nYou can install the package using pip\n\n```bash\npip install shapeless\n```\n----\n\n# Usage\n\nHere's a simple example of how to use the\u00a0`Poly`\u00a0class:\n\n```python\nfrom shapeless import Poly\n\n# Create a Poly object with an integer\np = Poly(10)\n\n# Determine the type of the data\nprint(p.determine())  # <class 'int'>\n\n# Shift the data to a string\nprint(p.shift(str))  # '10'\n\n# Validate that the data is a string\nprint(p.validate(str))  # True\n```\n\nYou can also use\u00a0`Poly`\u00a0as a type hint in your functions:\n\n```python\nfrom shapeless import Poly\n\ndef my_func(a: Poly):\n    print(type(a))\n\n# Create a Poly object with a string\np = Poly('10')\n\n# Pass the Poly object to my_func\nmy_func(p)  # <class '__main__.Poly'>\n```\n------\n\n# `shapeless` Decorator\nWith the shapeless decorator you can wrap entire classes and transform all their variables into the `Poly` type!\n\n```python\nfrom shapeless import shapeless\n\n@shapeless\nclass SimpleClass:\n    def __init__(self, x, y):\n        self.x = x\n        self.y = y\n\n    def add(self):\n        return self.x + self.y\n    \nsc = SimpleClass(1, 2)\nprint(sc.add())  # prints 3\n\n```\n\n-----\n\n\n# `fluid` Decorator\nFluid is like the `shapeless` decorator but for classes, just wrap it around your function to transform all the variables to the `Poly`\u00a0shapeless type.\n\n```python\nfrom shapeless import fluid\n\n@fluid\ndef add(a, b):\n    return a.data + b.data\n\nprint(add(1, 2))\nprint(add(\"hello\", 'world'))\n\n```\n\n----\n\n# `liquid` Decorator\n- The `liquid` decorator acts like `dataclass` but makes all the types the `Poly` type!\n\n```python\nfrom shapeless import liquid\n\n#define the liquid decorator\n@liquid\nclass MyClass:\n    x = 1\n    y = \"hello\"\n\n    def run(self):\n        print(type(self.x))\n\nobj = MyClass()\nprint(type(obj.x))\nprint(type(obj.y))\n\nobj.run()\n```\n\n# Why use Shapeless?\n\nShapeless is a powerful tool for creating fluid programs because it allows developers to handle data types dynamically and polymorphically. This means that the same class or function can handle different types of data, making the program more flexible and versatile.\n\nShapeless also provides thread safety, which is crucial for multi-threaded applications. This ensures that the data remains consistent and prevents race conditions.\n\nFurthermore, Shapeless provides logging, type aliasing, type annotation, type extension, and serialization and deserialization features. These features make it easier to write, debug, and understand the code, and they allow developers to create more complex and flexible data structures.\n\nIn conclusion, Shapeless is a powerful tool for creating fluid programs that can handle a wide range of data types and that are safe, flexible, and easy to understand.\n\n## Benefits\n\n1.  Dynamic Type Handling\u00a0\ud83d\udd04: Poly and Shapeless allow developers to handle data types dynamically. This means that the type of data can be determined, selected, shifted, validated, aliased, annotated, extended, serialized, and deserialized on the fly.\n\n2.  Thread Safety\u00a0\ud83d\udd12: Both Poly and Shapeless provide thread safety, which is crucial for multi-threaded applications. This ensures that the data remains consistent and prevents race conditions.\n\n3.  Logging\u00a0\ud83d\udcdd: With the verbose option, all operations can be logged. This is useful for debugging and understanding the flow of data and operations in the program.\n\n4.  Polymorphism\u00a0\ud83d\udc3e: Poly and Shapeless make it easy to create polymorphic classes and functions. This means that the same class or function can handle different types of data, making the program more flexible and versatile.\n\n5.  Type Aliasing\u00a0\ud83c\udff7\ufe0f: Poly allows developers to add aliases for types. This can make the code more readable and easier to understand.\n\n6.  Type Annotation\u00a0\ud83d\udd8a\ufe0f: Poly provides a method to annotate the data with a type. This can be useful for static type checking and for making the code more self-explanatory.\n\n7.  Type Extension\u00a0\ud83e\udde9: With Poly, the type of the data can be extended with a new type. This allows developers to create more complex and flexible data structures.\n\n8.  Serialization and Deserialization\u00a0\ud83d\udcbe: Poly provides methods to serialize and deserialize the data. This is useful for saving and loading data, and for sending and receiving data over a network.\n\n\n------\n\n# Documentation\n* [Check out shapeless.apac.ai for documentation](https://shapeless.apac.ai)\n\n\n-----\n\n# Vision\nIn today's world, programming languages are often divided into statically-typed and dynamically-typed. While statically-typed languages provide type safety and performance benefits, they often lack the flexibility and simplicity that dynamically-typed languages offer. This has led to a growing demand for tools that can bring the benefits of both worlds together.\n\nWe believe the future of programming lies in the ability to handle types in a fluid and flexible manner, without sacrificing the benefits of static typing. However, achieving this is not easy. It requires a deep understanding of both static and dynamic typing, as well as the ability to create a tool that is easy to use, performant, and thread-safe.\n\nMany have tried to solve this problem, but none have succeeded. The challenge lies in creating a tool that is both powerful and simple to use. It requires a radical new approach, one that is not constrained by the traditional boundaries of static and dynamic typing.\n\nThat's where Poly comes in. Our secret is our deep understanding of the problems with static types. As creators of multi-modality and fluid intelligences with no defined shape, we have the unique insight and expertise needed to solve this problem. We have created a tool that allows you to handle dynamic types in a flexible and thread-safe manner, without sacrificing the benefits of static typing.\n\nWe are confident that Poly is the best solution to this problem. With our unique approach and deep expertise, we are perfectly positioned to bring this vision to life. Join us on this journey and experience the future of programming today.\n\n\n\n-----\n\n\n# License\nMIT\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Poly - Pytorch",
    "version": "0.0.9",
    "project_urls": {
        "Homepage": "https://github.com/kyegomez/Poly",
        "Repository": "https://github.com/kyegomez/Poly"
    },
    "split_keywords": [
        "artificial intelligence",
        "deep learning",
        "optimizers",
        "prompt engineering"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd90cf1678ca630a6bd89f35a2eeb5af7446eb50c6720641ed8ddc169a79c1ad",
                "md5": "2fe6f02136bca73782df5d250d7c3c4c",
                "sha256": "1f675310181ff7c68377d4eb7e08b3a540393b610addc5d6d01e1d246a6de3ee"
            },
            "downloads": -1,
            "filename": "shapeless-0.0.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2fe6f02136bca73782df5d250d7c3c4c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 28112,
            "upload_time": "2023-09-18T20:31:12",
            "upload_time_iso_8601": "2023-09-18T20:31:12.602088Z",
            "url": "https://files.pythonhosted.org/packages/cd/90/cf1678ca630a6bd89f35a2eeb5af7446eb50c6720641ed8ddc169a79c1ad/shapeless-0.0.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "68cd9dddd75b0870f3e88dd197244e0860e42c864ff9280a8141e93485150e36",
                "md5": "bbc18ff3654740d073b3c9f738dabe4a",
                "sha256": "578ef26f94fe4d16d682e3abef4910e7594c7bcb7c8dff050c89dd83812d2ef5"
            },
            "downloads": -1,
            "filename": "shapeless-0.0.9.tar.gz",
            "has_sig": false,
            "md5_digest": "bbc18ff3654740d073b3c9f738dabe4a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 29307,
            "upload_time": "2023-09-18T20:31:14",
            "upload_time_iso_8601": "2023-09-18T20:31:14.604403Z",
            "url": "https://files.pythonhosted.org/packages/68/cd/9dddd75b0870f3e88dd197244e0860e42c864ff9280a8141e93485150e36/shapeless-0.0.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-18 20:31:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kyegomez",
    "github_project": "Poly",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "shapeless"
}
        
Elapsed time: 0.14854s