{"id":28281525,"url":"https://github.com/zehanort/rvg","last_synced_at":"2025-10-08T18:21:05.228Z","repository":{"id":57463354,"uuid":"249161869","full_name":"zehanort/rvg","owner":"zehanort","description":"A random values generator for any data type in Python 3","archived":false,"fork":false,"pushed_at":"2020-03-27T08:46:35.000Z","size":80,"stargazers_count":3,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-21T12:13:14.225Z","etag":null,"topics":["numpy","numpy-arrays","python","python-3","python3","random","random-generation","random-number-generators","randomizer","types","typesafe","typesafety"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zehanort.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-22T10:42:52.000Z","updated_at":"2022-11-20T18:30:50.000Z","dependencies_parsed_at":"2022-09-14T16:40:19.836Z","dependency_job_id":null,"html_url":"https://github.com/zehanort/rvg","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/zehanort/rvg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zehanort%2Frvg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zehanort%2Frvg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zehanort%2Frvg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zehanort%2Frvg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zehanort","download_url":"https://codeload.github.com/zehanort/rvg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zehanort%2Frvg/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260260799,"owners_count":22982592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["numpy","numpy-arrays","python","python-3","python3","random","random-generation","random-number-generators","randomizer","types","typesafe","typesafety"],"created_at":"2025-05-21T12:13:11.592Z","updated_at":"2025-10-08T18:21:05.117Z","avatar_url":"https://github.com/zehanort.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u0026#127922; rvg \u0026#127922; - Random Values Generator\n![Testing](https://github.com/zehanort/rvg/workflows/Testing/badge.svg)\n[![codecov](https://codecov.io/gh/zehanort/rvg/branch/dev/graph/badge.svg)](https://codecov.io/gh/zehanort/rvg)\n[![CodeFactor](https://www.codefactor.io/repository/github/zehanort/rvg/badge)](https://www.codefactor.io/repository/github/zehanort/rvg)\n![PyPI release](https://img.shields.io/pypi/v/rvg?label=PyPI%20release)\n\n## Description\n\n`rvg` is a Python 3 package utility to create random values of any Python 3 data type.\n\nIts main purpose is to help in applications where reliable -in terms of type safety- random values are needed (e.g. statistics, machine learning, general testing etc), and in specific layouts (e.g. \"I want a `numpy` structured array of random pairs of ints and floats and I want it now\").\n\n## Authors\n[Sotiris Niarchos](https://github.com/zehanort) and [George Papadopoulos](https://github.com/gepapado)\n\n## Installation\n\nYou can either:\n- download the source code from the [releases page](https://github.com/zehanort/rvg/releases) or clone the repo (the `master` branch will always mirror the latest release)\n- use `pip`:\n```\npip install rvg\n```\n\n## Current Status\n\n### Alpha release\n\nFor the time being, only `numpy` types are supported. More specifically:\n- `numpy` scalar data types\n- `numpy` arrays of scalar data types\n- `numpy` arrays of structured data types\n\nAfter the alpha release, more features will be implemented, focusing mainly on Python 3 native types.\n\n## Usage\n\nRight now, `rvg` provides 2 interafaces for random values generation through the `NumPyRVG` class:\n1. Create a generator of a *certain data type*\n2. Create a generator with *specific numerical limits*\nA demonstration follows:\n\n```Python\nfrom rvg import NumPyRVG\nimport numpy as np\n\n# Interface 1\nranduint = NumPyRVG(dtype=np.uint16)\n\n# Interface 2\nrandsmall = NumPyRVG(limit=10) # same as limits=(-10, 10)\nrandbig = NumPyRVG(limits=(1e10, 1e100))\n```\n\nThe functionalities of `NumPyRVG` include the generation of:\n\n- `numpy` scalar data types:\n\n```Python console\n\u003e\u003e\u003e randsmall(np.uint8)\n8\n\u003e\u003e\u003e randbig(np.double)\n1.9296971162995923e+99\n\u003e\u003e\u003e res = [randsmall(t) for t in [np.int8, np.uint16, np.float32, np.double]]\n\u003e\u003e\u003e res\n[7, 1, 3.0503626, 3.759943941132951]\n\u003e\u003e\u003e list(map(type, res))\n[\u003cclass 'numpy.int8'\u003e, \u003cclass 'numpy.uint16'\u003e, \u003cclass 'numpy.float32'\u003e, \u003cclass 'numpy.float64'\u003e]\n```\n\n- `numpy` array data types from scalar types:\n\n```Python console\n\u003e\u003e\u003e randuint((50, 100), shape=3)\narray([79, 81, 85], dtype=uint16)\n\u003e\u003e\u003e randsmall(np.float16, shape=(4, 2))\narray([[-7.23 , -9.31 ],\n       [-4.97 , -6.06 ],\n       [-5.19 , -3.344],\n       [-6.586, -3.133]], dtype=float16)\n```\n\n- `numpy` structured array data types (structured datatypes can be nested). Limits and shapes can be given in the form of a dictionary, describing all limits and/or shapes of each field of each level of the structured data type. An example follows:\n\n```Python\n#  Consider the struct definition below, in C:\n##############################################\n#  typedef struct knode {\n#      int location;\n#      int indices [3];\n#      int  keys [3];\n#      bool is_leaf;\n#      int num_keys;\n#  } knode;\n##############################################\n\nimport numpy as np\nfrom rvg import NumPyRVG\n\nknode = np.dtype([\n    ('location', int),\n    ('indices', (int, 3)),\n    ('keys', (int, 3)),\n    ('is_leaf', int),\n    ('num_keys', int)\n])\n\nknode_params = {\n    'location'  : (0, 10),\n    'indices'   : 42,\n    'keys'      : 117,\n    'is_leaf'   : (0, 2),\n    'num_keys'  : (0, 256)\n}\n\nrandom_knode = NumPyRVG(dtype=knode)\nknodes_array = random_knode(knode_params, 5)\nprint(knodes_array)\n\n```\nThe output of the above script is a nested structured `numpy` array consisting of 5 `knode` structs, randomly initialized!\n\n```\n[(0, [-18, -11,  34], [  89,   35,  -57], 1, 189)\n (6, [-35,   0,   4], [ -56,  -65,   26], 1, 217)\n (4, [-29,  40,  37], [  93, -116,   91], 0,  38)\n (2, [-28, -42, -36], [-101,    0,  -43], 0,  82)\n (0, [-14, -19, -13], [ -98,  -46,  -78], 1, 238)]\n```\nIf the script was run in an interpreter, you could inspect its type as well:\n\n```Python console\n\u003e\u003e\u003e knodes_array\narray([(0, [-18, -11,  34], [  89,   35,  -57], 1, 189),\n       (6, [-35,   0,   4], [ -56,  -65,   26], 1, 217),\n       (4, [-29,  40,  37], [  93, -116,   91], 0,  38),\n       (2, [-28, -42, -36], [-101,    0,  -43], 0,  82),\n       (0, [-14, -19, -13], [ -98,  -46,  -78], 1, 238)],\n      dtype=[('location', '\u003ci8'), ('indices', '\u003ci8', (3,)), ('keys', '\u003ci8', (3,)), ('is_leaf', '\u003ci8'), ('num_keys', '\u003ci8')])\n```\nThe feature of nesting is not limited in arrays; you can create data types that are as complex as you want and/or need! See the relative [test](https://github.com/zehanort/rvg/blob/master/tests/test_NumPyRVG_class_with_types.py) as an example of struct nesting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzehanort%2Frvg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzehanort%2Frvg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzehanort%2Frvg/lists"}