Browse Source

Remove rand_pow_array(), it's not used anymore

master
Kristaps Kaupe 5 years ago
parent
commit
392f51b38b
No known key found for this signature in database
GPG Key ID: 33E472FE870C7E5D
  1. 2
      jmclient/jmclient/__init__.py
  2. 8
      jmclient/jmclient/support.py
  3. 7
      jmclient/test/test_support.py

2
jmclient/jmclient/__init__.py

@ -3,7 +3,7 @@ import logging
from .support import (calc_cj_fee, choose_sweep_orders, choose_orders,
cheapest_order_choose, weighted_order_choose,
rand_norm_array, rand_pow_array, rand_exp_array,
rand_norm_array, rand_exp_array,
rand_weighted_choice, select,
select_gradual, select_greedy, select_greediest,
get_random_bytes, random_under_max_order_choose,

8
jmclient/jmclient/support.py

@ -44,14 +44,6 @@ def rand_exp_array(lamda, n):
return [random.expovariate(1.0 / lamda) for _ in range(n)]
def rand_pow_array(power, n):
# rather crude in that uses a uniform sample which is a multiple of 1e-4
# for basis of formula, see: http://mathworld.wolfram.com/RandomNumber.html
return [y**(1.0 / power)
for y in [x * 0.0001 for x in random.sample(
range(10000), n)]]
def rand_weighted_choice(n, p_arr):
"""
Choose a value in 0..n-1

7
jmclient/test/test_support.py

@ -4,7 +4,7 @@
import pytest
from jmclient import (select, select_gradual, select_greedy, select_greediest,
choose_orders, choose_sweep_orders, weighted_order_choose)
from jmclient.support import (calc_cj_fee, rand_exp_array, rand_pow_array,
from jmclient.support import (calc_cj_fee, rand_exp_array,
rand_norm_array, rand_weighted_choice,
cheapest_order_choose)
from taker_test_data import t_orderbook
@ -37,11 +37,6 @@ def test_random_funcs():
assert len(x2) == 10
for x in x2:
assert x > 0
x3 = rand_pow_array(100, 10)
assert len(x3) == 10
for x in x3:
assert x > 0
assert x < 1
x4 = rand_weighted_choice(5, [0.2, 0.1, 0.3, 0.15, 0.25])
assert x4 in range(5)
#test weighted choice fails with invalid inputs

Loading…
Cancel
Save