Hello community, here is the log from the commit of package python-pyDOE2 for openSUSE:Factory checked in at 2020-02-03 11:13:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-pyDOE2 (Old) and /work/SRC/openSUSE:Factory/.python-pyDOE2.new.26092 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pyDOE2" Mon Feb 3 11:13:13 2020 rev:5 rq:768811 version:1.3.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-pyDOE2/python-pyDOE2.changes 2019-07-28 10:22:13.108568496 +0200 +++ /work/SRC/openSUSE:Factory/.python-pyDOE2.new.26092/python-pyDOE2.changes 2020-02-03 11:13:18.445844602 +0100 @@ -1,0 +2,6 @@ +Thu Jan 30 15:21:37 UTC 2020 - Todd R <[email protected]> + +- Update to version 1.3.0 + * Added latin hypercude with enforced correlation + +------------------------------------------------------------------- Old: ---- pyDOE2-1.2.1.tar.gz New: ---- pyDOE2-1.3.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-pyDOE2.spec ++++++ --- /var/tmp/diff_new_pack.rtAkPL/_old 2020-02-03 11:13:19.749845261 +0100 +++ /var/tmp/diff_new_pack.rtAkPL/_new 2020-02-03 11:13:19.753845263 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-pyDOE2 # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,12 +18,12 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-pyDOE2 -Version: 1.2.1 +Version: 1.3.0 Release: 0 Summary: Design of experiments for Python License: BSD-3-Clause Group: Development/Languages/Python -Url: https://github.com/clicumu/pyDOE2 +URL: https://github.com/clicumu/pyDOE2 Source: https://files.pythonhosted.org/packages/source/p/pyDOE2/pyDOE2-%{version}.tar.gz BuildRequires: %{python_module setuptools} BuildRequires: fdupes ++++++ pyDOE2-1.2.1.tar.gz -> pyDOE2-1.3.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyDOE2-1.2.1/PKG-INFO new/pyDOE2-1.3.0/PKG-INFO --- old/pyDOE2-1.2.1/PKG-INFO 2019-07-24 13:30:26.000000000 +0200 +++ new/pyDOE2-1.3.0/PKG-INFO 2020-01-27 12:37:40.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pyDOE2 -Version: 1.2.1 +Version: 1.3.0 Summary: Design of experiments for Python Home-page: https://github.com/clicumu/pyDOE2 Author: Rickard Sjoegren diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyDOE2-1.2.1/pyDOE2/doe_lhs.py new/pyDOE2-1.3.0/pyDOE2/doe_lhs.py --- old/pyDOE2-1.2.1/pyDOE2/doe_lhs.py 2019-04-01 09:30:06.000000000 +0200 +++ new/pyDOE2-1.3.0/pyDOE2/doe_lhs.py 2020-01-27 12:36:47.000000000 +0100 @@ -15,11 +15,14 @@ import numpy as np from scipy import spatial +from scipy import stats +from scipy import linalg +from numpy import ma __all__ = ['lhs'] -def lhs(n, samples=None, criterion=None, iterations=None, random_state=None): +def lhs(n, samples=None, criterion=None, iterations=None, random_state=None, correlation_matrix = None): """ Generate a latin-hypercube design @@ -41,6 +44,8 @@ (Default: 5). randomstate : np.random.RandomState, int Random state (or seed-number) which controls the seed and random draws + correlation_matrix : ndarray + Enforce correlation between factors (only used in lhsmu) Returns ------- @@ -109,7 +114,7 @@ if criterion is not None: if not criterion.lower() in ('center', 'c', 'maximin', 'm', 'centermaximin', 'cm', 'correlation', - 'corr'): + 'corr','lhsmu'): raise ValueError('Invalid value for "criterion": {}'.format(criterion)) else: @@ -129,6 +134,9 @@ H = _lhsmaximin(n, samples, iterations, 'centermaximin', random_state) elif criterion.lower() in ('correlation', 'corr'): H = _lhscorrelate(n, samples, iterations, random_state) + elif criterion.lower() in ('lhsmu'): + # as specified by the paper. M is set to 5 + H = _lhsmu(n, samples, correlation_matrix, random_state, M=5) return H @@ -207,3 +215,63 @@ H = Hcandidate.copy() return H + + ################################################################################ + +def _lhsmu(N, samples=None, corr=None, random_state=None, M=5): + + if random_state is None: + random_state = np.random.RandomState() + elif not isinstance(random_state, np.random.RandomState): + random_state = np.random.RandomState(random_state) + + if samples is None: + samples = N + + I = M*samples + + rdpoints = random_state.uniform(size=(I, N)) + + dist = spatial.distance.cdist(rdpoints, rdpoints, metric='euclidean') + D_ij = ma.masked_array(dist, mask=np.identity(I)) + + index_rm = np.zeros(I-samples, dtype=int) + i = 0 + while i < I-samples: + order = ma.sort(D_ij, axis=1) + + avg_dist = ma.mean(order[:, 0:2], axis=1) + min_l = ma.argmin(avg_dist) + + D_ij[min_l, :] = ma.masked + D_ij[:, min_l] = ma.masked + + index_rm[i] = min_l + i += 1 + + rdpoints = np.delete(rdpoints, index_rm, axis=0) + + if(corr is not None): + #check if covariance matrix is valid + assert type(corr) == np.ndarray + assert corr.ndim == 2 + assert corr.shape[0] == corr.shape[1] + assert corr.shape[0] == N + + norm_u = stats.norm().ppf(rdpoints) + L = linalg.cholesky(corr, lower=True) + + norm_u = np.matmul(norm_u, L) + + H = stats.norm().cdf(norm_u) + else: + H = np.zeros_like(rdpoints, dtype=float) + rank = np.argsort(rdpoints, axis=0) + + for l in range(samples): + low = float(l)/samples + high = float(l+1)/samples + + l_pos = rank == l + H[l_pos] = random_state.uniform(low, high, size=N) + return H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyDOE2-1.2.1/pyDOE2.egg-info/PKG-INFO new/pyDOE2-1.3.0/pyDOE2.egg-info/PKG-INFO --- old/pyDOE2-1.2.1/pyDOE2.egg-info/PKG-INFO 2019-07-24 13:30:26.000000000 +0200 +++ new/pyDOE2-1.3.0/pyDOE2.egg-info/PKG-INFO 2020-01-27 12:37:39.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: pyDOE2 -Version: 1.2.1 +Version: 1.3.0 Summary: Design of experiments for Python Home-page: https://github.com/clicumu/pyDOE2 Author: Rickard Sjoegren diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/pyDOE2-1.2.1/setup.py new/pyDOE2-1.3.0/setup.py --- old/pyDOE2-1.2.1/setup.py 2019-07-24 13:30:10.000000000 +0200 +++ new/pyDOE2-1.3.0/setup.py 2020-01-27 12:37:04.000000000 +0100 @@ -7,7 +7,7 @@ setup( name='pyDOE2', - version="1.2.1", + version="1.3.0", author='Rickard Sjoegren', author_email='[email protected]', description='Design of experiments for Python',
