-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from sbalian/numpy-support
Add numpy support
- Loading branch information
Showing
9 changed files
with
188 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
[tool.poetry] | ||
name = "quantum-random" | ||
version = "1.0.1" | ||
version = "1.1.1" | ||
description = "Quantum random numbers" | ||
authors = ["Seto Balian <[email protected]>"] | ||
packages = [{include = "qrandom.py"}] | ||
packages = [{ include = "qrandom" }] | ||
readme = "README.md" | ||
license = "MIT" | ||
repository = "https://github.com/sbalian/quantum-random" | ||
maintainers = ["Seto Balian <[email protected]>"] | ||
classifiers = [ | ||
"Intended Audience :: Science/Research", | ||
"Intended Audience :: Developers", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Topic :: Software Development", | ||
"Topic :: Scientific/Engineering", | ||
"Typing :: Typed", | ||
"Operating System :: Microsoft :: Windows", | ||
"Operating System :: Unix", | ||
"Operating System :: MacOS", | ||
"License :: OSI Approved :: MIT License", | ||
] | ||
|
||
[tool.poetry.dependencies] | ||
python = ">=3.7,<3.11" | ||
requests = "^2.25.1" | ||
|
||
numpy = { version = "^1.17", optional = true, python = ">=3.7,<3.10" } | ||
randomgen = { version = "^1.21.2", optional = true, python = ">=3.7,<3.10" } | ||
|
||
[tool.poetry.dev-dependencies] | ||
isort = "^5.7.0" | ||
flake8 = "^3.8.4" | ||
|
@@ -25,6 +41,9 @@ black = "^22.3.0" | |
matplotlib = "^3.5.1" | ||
scipy = "<1.8" | ||
|
||
[tool.poetry.extras] | ||
numpy = ["numpy", "randomgen"] | ||
|
||
[tool.isort] | ||
line_length = 79 | ||
known_first_party = "qrandom" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Adds numpy support to qrandom.""" | ||
|
||
import numpy.random | ||
import randomgen # type: ignore | ||
|
||
from . import QuantumRandom | ||
|
||
|
||
class ANUQRNG(QuantumRandom): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def random_raw(self, voidp) -> int: | ||
return self._get_rand_int64() | ||
|
||
|
||
def quantum_rng(): | ||
"""Constructs a new Generator with a quantum BitGenerator (ANUQRNG).""" | ||
qrn = ANUQRNG() | ||
return numpy.random.Generator(randomgen.UserBitGenerator(qrn.random_raw)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.