Issue 1:
My issue is about the minimize_scalar in scipy. Under an older version of scipy this code did to work (at least 1.3.1), now there is some error occurring.

Reproducing code example:

from scipy.special import j1
from scipy.optimize import minimize_scalar
res = minimize_scalar(j1, bounds=(1e-10, 1e-05), method='bounded')
res.x

Error message:

UnboundLocalError Traceback (most recent call last)
<ipython-input-2-15220d9f4e21> in <module>
2 from scipy.optimize import minimize_scalar
3
----> 4 res = minimize_scalar(j1, bounds=(1e-10, 1e-5), method='bounded')
5 res.x

~/anaconda3/lib/python3.7/site-packages/scipy/optimize/_minimize.py in minimize_scalar(fun, bracket, bounds, args, method, tol, options)
788 if isinstance(disp, bool):
789 options['disp'] = 2 * int(disp)
--> 790 return _minimize_scalar_bounded(fun, bounds, args, **options)
791 elif meth == 'golden':
792 return _minimize_scalar_golden(fun, bracket, args, **options)

~/anaconda3/lib/python3.7/site-packages/scipy/optimize/optimize.py in _minimize_scalar_bounded(func, bounds, args, xatol, maxiter, disp, **unknown_options)
1878 break
1879
-> 1880 if np.isnan(xf) or np.isnan(fx) or np.isnan(fu):
1881 flag = 2
1882

UnboundLocalError: local variable 'fu' referenced before assignment

...

Scipy/Numpy/Python version information:

1.4.1 1.18.1 sys.version_info(major=3, minor=7, micro=4, releaselevel='final', serial=0)

Issue 2:
Hi,

I've recently changed my docker configuration and, while using chaospy package, I came across an error which never occurred before.

It looks like it comes from the fact that fu is not instantiated before the while loop but I'm not sure.

I hope this report will help.

Reproducing code example:

import chaospy as cp

distribution = cp.J(cp.Uniform(0, 1), cp.Uniform(0, 1))
abscissas, weights = cp.generate_quadrature(7, distribution, rule="Leja", sparse=True)

Error message:

This error message occured in a Jupyter notebook:

---------------------------------------------------------------------------
UnboundLocalError Traceback (most recent call last)
<ipython-input-1-b2f64640c4d5> in <module>
1 import chaospy as cp
2 dist=cp.J(cp.Uniform(0, 1), cp.Uniform(0, 1))
----> 3 points = cp.generate_quadrature(2, dist, rule="Leja", sparse=True)

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/frontend.py in generate_quadrature(order, dist, rule, sparse, accuracy, growth, recurrence_algorithm)
134 from . import sparse_grid
135 return sparse_grid.construct_sparse_grid(
--> 136 order, dist, rule=rule, accuracy=accuracy, growth=growth)
137
138 if not isinstance(rule, str):

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/sparse_grid.py in construct_sparse_grid(order, dist, rule, accuracy, growth, recurrence_algorithm)
122
123 x_lookup, w_lookup = _construct_lookup(
--> 124 orders, dist, rule, accuracy, growth, recurrence_algorithm)
125 collection = _construct_collection(
126 order, dist, x_lookup, w_lookup)

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/sparse_grid.py in _construct_lookup(orders, dists, rules, accuracy, growth, recurrence_algorithm)
182 rule=rule,
183 growth=growth,
--> 184 recurrence_algorithm=recurrence_algorithm,
185 )
186 x_lookup[-1].append(abscissas)

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/frontend.py in generate_quadrature(order, dist, rule, sparse, accuracy, growth, recurrence_algorithm)
157
158 quad_function = QUAD_FUNCTIONS[rule]
--> 159 abscissas, weights = quad_function(order, dist, **kwargs)
160
161 assert len(weights) == abscissas.shape[1]

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/leja.py in quad_leja(order, dist, rule, accuracy, recurrence_algorithm)
104 *[fminbound(
105 objective, abscissas[idx], abscissas[idx+1], full_output=1)[:2]
--> 106 for idx in range(len(abscissas)-1)]
107 )
108 index = numpy.argmin(vals)

/usr/local/lib/python3.7/dist-packages/chaospy/quadrature/leja.py in <listcomp>(.0)
104 *[fminbound(
105 objective, abscissas[idx], abscissas[idx+1], full_output=1)[:2]
--> 106 for idx in range(len(abscissas)-1)]
107 )
108 index = numpy.argmin(vals)

/usr/local/lib/python3.7/dist-packages/scipy/optimize/optimize.py in fminbound(func, x1, x2, args, xtol, maxfun, full_output, disp)
1734 'disp': disp}
1735
-> 1736 res = _minimize_scalar_bounded(func, (x1, x2), args, **options)
1737 if full_output:
1738 return res['x'], res['fun'], res['status'], res['nfev']

/usr/local/lib/python3.7/dist-packages/scipy/optimize/optimize.py in _minimize_scalar_bounded(func, bounds, args, xatol, maxiter, disp, **unknown_options)
1868 break
1869
-> 1870 if np.isnan(xf) or np.isnan(fx) or np.isnan(fu):
1871 flag = 2
1872

UnboundLocalError: local variable 'fu' referenced before assignment

Scipy/Numpy/Python version information:

1.3.3 1.17.4 sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)