Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DesignProxy.computeDesign() does not return a Matrix? #2692

Open
mbaudin47 opened this issue Jun 16, 2024 · 1 comment
Open

DesignProxy.computeDesign() does not return a Matrix? #2692

mbaudin47 opened this issue Jun 16, 2024 · 1 comment
Labels

Comments

@mbaudin47
Copy link
Collaborator

mbaudin47 commented Jun 16, 2024

What happened?

The matrix returned by DesignProxy.computeDesign() fails to be used as an input argument to QRMethod.

The script (see below for the full script):

designMatrix = design_proxy.computeDesign(functionIndices)
leastSquaresMethod = ot.QRMethod(designMatrix)  # Fails!

produces:

TypeError: Wrong number or type of arguments for overloaded function 'new_QRMethod'.

The workaround is to convert the matrix into a Matrix:

leastSquaresMethod = ot.QRMethod(ot.Matrix(designMatrix))  # Workaround

How to reproduce the issue?

# %%
import openturns as ot
from openturns.usecases import ishigami_function
import numpy as np

# %%
print(ot.__version__)

# %%
im = ishigami_function.IshigamiModel()
sampleSize = 20
inputSample = im.distributionX.getSample(sampleSize)
multivariateBasis = ot.OrthogonalProductPolynomialFactory([im.X1, im.X2, im.X3])
selectionAlgorithm = ot.PenalizedLeastSquaresAlgorithmFactory()  # Not sparse
projectionStrategy = ot.LeastSquaresStrategy(selectionAlgorithm)
basisSize = 10  # Caution: set basis size <= sample size
adaptiveStrategy = ot.FixedStrategy(multivariateBasis, basisSize)
functionIndices = ot.Indices(basisSize)
functionIndices.fill()
functionCollection = [multivariateBasis.build(i) for i in functionIndices]
transformation = ot.DistributionTransformation(
    im.distributionX, multivariateBasis.getMeasure()
)
z_train = transformation(inputSample)
basis = ot.Basis(functionCollection)
design_proxy = ot.DesignProxy(z_train, basis)
designMatrix = design_proxy.computeDesign(functionIndices)

# %%
leastSquaresMethod = ot.QRMethod(designMatrix)  # Fails!

# %%
leastSquaresMethod = ot.QRMethod(ot.Matrix(designMatrix))  # Workaround

Version

1.21

Operating System

Linux

Installation media

conda

Additional Context

No response

@mbaudin47 mbaudin47 added the bug label Jun 16, 2024
@sofianehaddad
Copy link
Member

with OT 1.22 I can not reproduce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants