Created
April 15, 2019 21:17
-
-
Save tylerjereddy/35936be43743527c16246837295161fe to your computer and use it in GitHub Desktop.
Generate test cases for NumPy gh-10741
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
import numpy as np | |
import pytest | |
import hypothesis | |
from hypothesis import given, settings | |
from hypothesis import strategies as st | |
from hypothesis.extra import numpy as hynp | |
@settings(max_examples=5) | |
@given(st.floats(min_value=0, max_value=1, width=64), | |
st.integers(np.finfo(np.double).minexp, np.finfo(np.double).maxexp - 1) | |
) | |
def test_produce_f_values_double(frac_val, int_val): | |
f = np.ldexp(frac_val, int_val, dtype=np.double) | |
print("cases for double") | |
print("frac_val:", frac_val) | |
print("int_val:", int_val) | |
print("f:", f) | |
@settings(max_examples=5) | |
@given(st.floats(min_value=0, max_value=1, width=64), | |
st.integers(np.finfo(np.longdouble).minexp, np.finfo(np.longdouble).maxexp - 1) | |
) | |
def test_produce_f_values_longdouble(frac_val, int_val): | |
f = np.ldexp(frac_val, int_val, dtype=np.longdouble) | |
print("cases for longdouble") | |
print("frac_val:", frac_val) | |
print("int_val:", int_val) | |
print("f:", f) | |
@settings(max_examples=5) | |
@given(st.floats(min_value=0, max_value=1, width=64), | |
st.integers(np.finfo(np.single).minexp, np.finfo(np.single).maxexp - 1) | |
) | |
def test_produce_f_values_single(frac_val, int_val): | |
f = np.ldexp(frac_val, int_val, dtype=np.single) | |
print("cases for single") | |
print("frac_val:", frac_val) | |
print("int_val:", int_val) | |
print("f:", f) | |
@settings(max_examples=5) | |
@given(st.floats(min_value=0, max_value=1, width=64), | |
st.integers(np.finfo(np.half).minexp, np.finfo(np.half).maxexp - 1) | |
) | |
def test_produce_f_values_half(frac_val, int_val): | |
f = np.ldexp(frac_val, int_val, dtype=np.half) | |
print("cases for half") | |
print("frac_val:", frac_val) | |
print("int_val:", int_val) | |
print("f:", f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment