Skip to content

Commit

Permalink
version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thenithinbalaji committed Mar 8, 2022
1 parent c6b1923 commit 8ac5d06
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 48 deletions.
94 changes: 84 additions & 10 deletions build/lib/pyrandtoys/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import random as rop
from typing import Tuple


def dice(count=1):
def dice(count: int = 1) -> Tuple[int, ...]:
"""
Rolls N dice
Parameters:
count (int) : The number of dice to roll, default = 1
Returns:
tuple: The values of dice rolls
Each tuple element is a number between 1 and 6
"""

res = ()

for _ in range(int(count)):
Expand All @@ -10,7 +22,18 @@ def dice(count=1):
return res


def coin(count=1):
def coin(count: int = 1) -> Tuple[str, ...]:
"""
Rolls N coins
Parameters:
count (int) : The number of coins to roll, default = 1
Returns:
tuple: The values of coin rolls
A tuple element can be either HEADS or TAILS
"""

res = ()
sample_space = ["HEADS", "TAILS"]

Expand All @@ -20,7 +43,18 @@ def coin(count=1):
return res


def dreidel(count=1):
def dreidel(count: int = 1) -> Tuple[str, ...]:
"""
Spin a dreidel N times
Parameters:
count (int) : The number times to spin, default = 1
Returns:
tuple: The values of dreidel spins
A tuple element is one of these values: NUN, GIMEL, HE, SHIN
"""

res = ()
sample_space = ["NUN", "GIMEL", "HE", "SHIN"]

Expand All @@ -30,7 +64,17 @@ def dreidel(count=1):
return res


def cat(count=1):
def cat(count: int = 1) -> Tuple[str, ...]:
"""
Perform Schrödinger's cat experiment N times
Parameters:
count (int) : The number of times to perform the experiment, default = 1
Returns:
tuple: The status of cats
A Cat can be ALIVE or DEAD
"""
res = ()
sample_space = ["ALIVE", "DEAD"]

Expand All @@ -40,7 +84,17 @@ def cat(count=1):
return res


def switch(count=1):
def switch(count: int = 1) -> Tuple[str, ...]:
"""
Flip a switch N times
Parameters:
count (int) : The number times to flip a switch, default = 1
Returns:
tuple: The status of switches
A Switch can be either ON or OFF
"""
res = ()
sample_space = ["ON", "OFF"]

Expand All @@ -50,22 +104,42 @@ def switch(count=1):
return res


def spinner(lower, upper=0):
def spinner(lower: int, upper: int = 0) -> int:
"""
Spin a spinner with numbers from lower to upper value
Parameters:
lower (int) : lowest number on the spinner
upper (int) : highest number on the spinner
Returns:
int: The value at which the spinner has stopped spinning
int is a number between lower and upper
"""
if lower > upper:
lower, upper = upper, lower

return rop.randint(int(lower), int(upper))


def combi(list=[]):
res = ()
def combi(list: list = []) -> Tuple[str, ...]:
"""
Randomise combinations between other functions
if str(type(list)) == "<class 'str'>":
Parameters:
list (list) : The list of functions to randomise
Returns:
tuple: The values of the randomised functions
"""
res = ()

if isinstance(list, str):
temp = []
temp.append(list)
list = temp

elif str(type(list)) == "<class 'int'>":
elif isinstance(list, int):
temp = []
sample_space = ["coin", "dice", "switch"]

Expand Down
Binary file removed dist/pyrandtoys-0.0.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/pyrandtoys-0.0.1.tar.gz
Binary file not shown.
Binary file added dist/pyrandtoys-0.0.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/pyrandtoys-0.0.2.tar.gz
Binary file not shown.
34 changes: 19 additions & 15 deletions pyrandtoys.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Metadata-Version: 2.1
Name: pyrandtoys
Version: 0.0.1
Version: 0.0.2
Summary: Python Module for generating the result of probability based toys.
Home-page: https://github.com/thenithinbalaji/pyrandtoys
Author: thenithinbalaji
Author-email: [email protected]
License: UNKNOWN
Keywords: python,random,probability
Keywords: python,random,probability,experiment
Platform: UNKNOWN
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Developers
Expand All @@ -21,7 +21,7 @@ License-File: LICENSE.md
Rand Toys
=========

``pyrandtoys`` is a python module containing probability-based toys’
``pyrandtoys`` is a python module containing probability-based toys
functions. It works offline and is compatible with both Python 2 and 3.

Installation
Expand All @@ -41,9 +41,9 @@ Usage
Dice:
^^^^^

**Optional:** Number of Dice ``<int>``
**Default:** Number of Dice = 1
**Return Type:** ``<tuple>``
+ **Optional:** Number of Dice ``<int>``
+ **Default:** Number of Dice = 1
+ **Return Type:** ``<tuple>``

::

Expand All @@ -52,8 +52,9 @@ Dice:
Coin:
^^^^^

**Optional:** Number of Coins ``<int>`` **Default:** Number of Coins = 1
**Return Type:** ``<tuple>``
+ **Optional:** Number of Coins ``<int>``
+ **Default:** Number of Coins = 1
+ **Return Type:** ``<tuple>``

::

Expand All @@ -62,8 +63,9 @@ Coin:
Similar Toys:
^^^^^^^^^^^^^

**Optional:** Number of Items ``<int>`` **Default:** Number of Items = 1
**Return Type:** ``<tuple>``
+ **Optional:** Number of Items ``<int>``
+ **Default:** Number of Items = 1
+ **Return Type:** ``<tuple>``

::

Expand All @@ -74,8 +76,9 @@ Similar Toys:
Spinner:
^^^^^^^^

**Required:** Lower & Upper Limits ``<int>`` **Default:** Lower Limit =
0 **Return Type:** ``<tuple>``
+ **Required:** Lower & Upper Limits ``<int>``
+ **Default:** Lower Limit = 0
+ **Return Type:** ``<tuple>``

::

Expand All @@ -84,10 +87,11 @@ Spinner:
Toy Combinations:
^^^^^^^^^^^^^^^^^

**Return Type:** ``<tuple>`` **Default:** Number of Toys = 0
+ **Default:** Number of Toys = 0
+ **Return Type:** ``<tuple>``

**If you want to use a combination of toys then,** **Required:** List of
toys as ``<list>``,\ ``<tuple>``
**If you want to use a combination of toys then,**
**Required:** List of toys as ``<list>``,\ ``<tuple>``

::

Expand Down
42 changes: 21 additions & 21 deletions pyrandtoys/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

def dice(count: int = 1) -> Tuple[int, ...]:
"""
Rolls N dices and returns the values as a tuple
Rolls N dice
Parameters:
count (int) : The number of dices to roll
count (int) : The number of dice to roll, default = 1
Returns:
tuple: The values of dice rolls
The tuple values is a number between 1 and 6
Each tuple element is a number between 1 and 6
"""

res = ()
Expand All @@ -24,14 +24,14 @@ def dice(count: int = 1) -> Tuple[int, ...]:

def coin(count: int = 1) -> Tuple[str, ...]:
"""
Rolls N coins and returns the values as a tuple
Rolls N coins
Parameters:
count (int) : The number of coins to roll
count (int) : The number of coins to roll, default = 1
Returns:
tuple: The values of coin rolls
tuple can be HEADS or TAILS
A tuple element can be either HEADS or TAILS
"""

res = ()
Expand All @@ -45,14 +45,14 @@ def coin(count: int = 1) -> Tuple[str, ...]:

def dreidel(count: int = 1) -> Tuple[str, ...]:
"""
Spin a dreidel N times and return the values as a tuple
Spin a dreidel N times
Parameters:
count (int) : The number times to spin
count (int) : The number times to spin, default = 1
Returns:
tuple: The values of dreidel spins
Tuple contains one of the values between ["NUN", "GIMEL", "HE", "SHIN"]
A tuple element is one of these values: NUN, GIMEL, HE, SHIN
"""

res = ()
Expand All @@ -66,14 +66,14 @@ def dreidel(count: int = 1) -> Tuple[str, ...]:

def cat(count: int = 1) -> Tuple[str, ...]:
"""
Ask if the cat is alive or dead
Perform Schrödinger's cat experiment N times
Parameters:
count (int) : The number of times to ask
count (int) : The number of times to perform the experiment, default = 1
Returns:
tuple: The dead or alive values of the cats
Cat can be ALIVE or DEAD
tuple: The status of cats
A Cat can be ALIVE or DEAD
"""
res = ()
sample_space = ["ALIVE", "DEAD"]
Expand All @@ -86,14 +86,14 @@ def cat(count: int = 1) -> Tuple[str, ...]:

def switch(count: int = 1) -> Tuple[str, ...]:
"""
Flip a switch N times and return the values as a tuple
Flip a switch N times
Parameters:
count (int) : The number times to spin
count (int) : The number times to flip a switch, default = 1
Returns:
tuple: The values of dreidel spins
Switch can be ON or OFF
tuple: The status of switches
A Switch can be either ON or OFF
"""
res = ()
sample_space = ["ON", "OFF"]
Expand All @@ -106,14 +106,14 @@ def switch(count: int = 1) -> Tuple[str, ...]:

def spinner(lower: int, upper: int = 0) -> int:
"""
Spin a spinner between a lower and upper value
Spin a spinner with numbers from lower to upper value
Parameters:
lower (int) : The lower value of the spinner
upper (int) : The upper value of the spinner
lower (int) : lowest number on the spinner
upper (int) : highest number on the spinner
Returns:
int: The value of the spinner
int: The value at which the spinner has stopped spinning
int is a number between lower and upper
"""
if lower > upper:
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = "0.0.1"
VERSION = "0.0.2"
DESCRIPTION = "Python Module for generating the result of probability based toys."
LONG_DESC = open("README.rst").read()

Expand All @@ -14,7 +14,7 @@
long_description=LONG_DESC,
packages=find_packages(),
install_requires=[],
keywords=["python", "random", "probability"],
keywords=["python", "random", "probability", "experiment"],
classifiers=[
"Intended Audience :: Education",
"Intended Audience :: Developers",
Expand Down

0 comments on commit 8ac5d06

Please sign in to comment.