From c2232429872035ce263b7b25e4cc6d7a85a916cc Mon Sep 17 00:00:00 2001 From: francescoandreuzzi Date: Thu, 1 Apr 2021 13:31:35 +0200 Subject: [PATCH] generate docs for (k|radius_)neighbors_regressor.py --- docs/build/html/.buildinfo | 2 +- docs/build/html/LICENSE.html | 65 ++-- .../html/_modules/ezyrb/approximation.html | 59 +-- docs/build/html/_modules/ezyrb/database.html | 82 ++-- docs/build/html/_modules/ezyrb/linear.html | 68 ++-- docs/build/html/_modules/ezyrb/pod.html | 104 ++--- docs/build/html/_modules/ezyrb/rbf.html | 82 ++-- .../_modules/ezyrb/reducedordermodel.html | 95 +++-- docs/build/html/_modules/ezyrb/reduction.html | 59 +-- docs/build/html/_modules/index.html | 63 +-- docs/build/html/_static/basic.css | 144 +++++-- docs/build/html/_static/css/badge_only.css | 2 +- docs/build/html/_static/css/theme.css | 6 +- docs/build/html/_static/doctools.js | 17 +- .../html/_static/documentation_options.js | 3 +- docs/build/html/_static/graphviz.css | 2 +- docs/build/html/_static/jquery.js | 4 +- docs/build/html/_static/js/theme.js | 4 +- docs/build/html/_static/language_data.js | 6 +- docs/build/html/_static/pygments.css | 7 +- docs/build/html/_static/searchtools.js | 62 +-- docs/build/html/_static/underscore.js | 37 +- docs/build/html/approximation.html | 114 +++--- docs/build/html/code.html | 129 +++++-- docs/build/html/contact.html | 70 ++-- docs/build/html/contributing.html | 68 ++-- docs/build/html/database.html | 130 ++++--- docs/build/html/genindex.html | 365 ++++++++++++++++-- docs/build/html/index.html | 65 ++-- docs/build/html/linear.html | 120 +++--- docs/build/html/objects.inv | Bin 479 -> 1509 bytes docs/build/html/pod.html | 198 +++++----- docs/build/html/py-modindex.html | 72 ++-- docs/build/html/rbf.html | 130 ++++--- docs/build/html/reducedordermodel.html | 155 +++++--- docs/build/html/reduction.html | 116 +++--- docs/build/html/search.html | 66 ++-- docs/build/html/searchindex.js | 2 +- .../ezyrb.approximation.Approximation.fit.rst | 6 + ...rb.approximation.Approximation.predict.rst | 6 + .../ezyrb.approximation.Approximation.rst | 24 ++ .../ezyrb.database.Database.__getitem__.rst | 6 + .../ezyrb.database.Database.__len__.rst | 6 + .../ezyrb.database.Database.add.rst | 6 + .../ezyrb.database.Database.parameters.rst | 6 + .../_summaries/ezyrb.database.Database.rst | 30 ++ .../ezyrb.database.Database.snapshots.rst | 6 + ...bors_regressor.KNeighborsRegressor.fit.rst | 6 + ..._regressor.KNeighborsRegressor.predict.rst | 6 + ...eighbors_regressor.KNeighborsRegressor.rst | 24 ++ .../_summaries/ezyrb.linear.Linear.fit.rst | 6 + .../ezyrb.linear.Linear.predict.rst | 6 + .../source/_summaries/ezyrb.linear.Linear.rst | 24 ++ ...hbors_regressor.NeighborsRegressor.fit.rst | 6 + ...s_regressor.NeighborsRegressor.predict.rst | 6 + ...neighbors_regressor.NeighborsRegressor.rst | 24 ++ .../_summaries/ezyrb.pod.POD._corrm.rst | 6 + .../source/_summaries/ezyrb.pod.POD._rsvd.rst | 6 + docs/source/_summaries/ezyrb.pod.POD._svd.rst | 6 + .../_summaries/ezyrb.pod.POD._truncation.rst | 6 + .../_summaries/ezyrb.pod.POD.expand.rst | 6 + .../source/_summaries/ezyrb.pod.POD.modes.rst | 6 + .../_summaries/ezyrb.pod.POD.reduce.rst | 6 + docs/source/_summaries/ezyrb.pod.POD.rst | 31 ++ .../ezyrb.pod.POD.singular_values.rst | 6 + ...regressor.RadiusNeighborsRegressor.fit.rst | 6 + ...essor.RadiusNeighborsRegressor.predict.rst | 6 + ...ors_regressor.RadiusNeighborsRegressor.rst | 24 ++ docs/source/_summaries/ezyrb.rbf.RBF.fit.rst | 6 + .../_summaries/ezyrb.rbf.RBF.predict.rst | 6 + docs/source/_summaries/ezyrb.rbf.RBF.rst | 24 ++ ...odel.ReducedOrderModel._simplex_volume.rst | 6 + ...educedordermodel.ReducedOrderModel.fit.rst | 6 + ...ordermodel.ReducedOrderModel.loo_error.rst | 6 + ...rdermodel.ReducedOrderModel.optimal_mu.rst | 6 + ...edordermodel.ReducedOrderModel.predict.rst | 6 + ...rb.reducedordermodel.ReducedOrderModel.rst | 27 ++ .../ezyrb.reduction.Reduction.expand.rst | 6 + .../ezyrb.reduction.Reduction.reduce.rst | 6 + .../_summaries/ezyrb.reduction.Reduction.rst | 24 ++ docs/source/kneighbors_regressor.rst | 21 + docs/source/neighbors_regressor.rst | 21 + docs/source/radius_neighbors_regressor.rst | 21 + 83 files changed, 2252 insertions(+), 1032 deletions(-) create mode 100644 docs/source/_summaries/ezyrb.approximation.Approximation.fit.rst create mode 100644 docs/source/_summaries/ezyrb.approximation.Approximation.predict.rst create mode 100644 docs/source/_summaries/ezyrb.approximation.Approximation.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.__getitem__.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.__len__.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.add.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.parameters.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.rst create mode 100644 docs/source/_summaries/ezyrb.database.Database.snapshots.rst create mode 100644 docs/source/_summaries/ezyrb.kneighbors_regressor.KNeighborsRegressor.fit.rst create mode 100644 docs/source/_summaries/ezyrb.kneighbors_regressor.KNeighborsRegressor.predict.rst create mode 100644 docs/source/_summaries/ezyrb.kneighbors_regressor.KNeighborsRegressor.rst create mode 100644 docs/source/_summaries/ezyrb.linear.Linear.fit.rst create mode 100644 docs/source/_summaries/ezyrb.linear.Linear.predict.rst create mode 100644 docs/source/_summaries/ezyrb.linear.Linear.rst create mode 100644 docs/source/_summaries/ezyrb.neighbors_regressor.NeighborsRegressor.fit.rst create mode 100644 docs/source/_summaries/ezyrb.neighbors_regressor.NeighborsRegressor.predict.rst create mode 100644 docs/source/_summaries/ezyrb.neighbors_regressor.NeighborsRegressor.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD._corrm.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD._rsvd.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD._svd.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD._truncation.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD.expand.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD.modes.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD.reduce.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD.rst create mode 100644 docs/source/_summaries/ezyrb.pod.POD.singular_values.rst create mode 100644 docs/source/_summaries/ezyrb.radius_neighbors_regressor.RadiusNeighborsRegressor.fit.rst create mode 100644 docs/source/_summaries/ezyrb.radius_neighbors_regressor.RadiusNeighborsRegressor.predict.rst create mode 100644 docs/source/_summaries/ezyrb.radius_neighbors_regressor.RadiusNeighborsRegressor.rst create mode 100644 docs/source/_summaries/ezyrb.rbf.RBF.fit.rst create mode 100644 docs/source/_summaries/ezyrb.rbf.RBF.predict.rst create mode 100644 docs/source/_summaries/ezyrb.rbf.RBF.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel._simplex_volume.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel.fit.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel.loo_error.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel.optimal_mu.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel.predict.rst create mode 100644 docs/source/_summaries/ezyrb.reducedordermodel.ReducedOrderModel.rst create mode 100644 docs/source/_summaries/ezyrb.reduction.Reduction.expand.rst create mode 100644 docs/source/_summaries/ezyrb.reduction.Reduction.reduce.rst create mode 100644 docs/source/_summaries/ezyrb.reduction.Reduction.rst create mode 100644 docs/source/kneighbors_regressor.rst create mode 100644 docs/source/neighbors_regressor.rst create mode 100644 docs/source/radius_neighbors_regressor.rst diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo index 83571dfe..8c8d0255 100644 --- a/docs/build/html/.buildinfo +++ b/docs/build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 08325090b65bbf2ce8b62235eb64fbdd +config: f0c6b704ed37b7ff305e99b6bbef7c48 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/LICENSE.html b/docs/build/html/LICENSE.html index 60efed21..83ac9758 100644 --- a/docs/build/html/LICENSE.html +++ b/docs/build/html/LICENSE.html @@ -1,39 +1,42 @@ - - + - + - + - License — EZyRB 1.0 documentation + License — EZyRB 1.1 documentation + + + + + + + + - + - - - - + + + - - - - - @@ -60,7 +63,7 @@
- 1.0 + 1.1
@@ -77,6 +80,7 @@ + + @@ -144,18 +149,20 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs. - @@ -221,7 +229,6 @@

License jQuery(function () { SphinxRtdTheme.Navigation.enable(true); diff --git a/docs/build/html/_modules/ezyrb/approximation.html b/docs/build/html/_modules/ezyrb/approximation.html index 7c3f526d..d10c173b 100644 --- a/docs/build/html/_modules/ezyrb/approximation.html +++ b/docs/build/html/_modules/ezyrb/approximation.html @@ -1,39 +1,42 @@ - - + - + - + - ezyrb.approximation — EZyRB 1.0 documentation + ezyrb.approximation — EZyRB 1.1 documentation + + + + + + - + + + - - - - + + + - - - - - @@ -59,7 +62,7 @@
- 1.0 + 1.1
@@ -76,6 +79,7 @@ + + @@ -128,11 +133,13 @@ + +
    -
  • Docs »
  • +
  • »
  • Module code »
  • @@ -155,7 +162,7 @@

    Source code for ezyrb.approximation

     """
     Module for the Approximation abstract class
     """
    -from abc import ABC, abstractmethod
    +from abc import ABC, abstractmethod
     
     
    [docs]class Approximation(ABC):
    [docs] @abstractmethod @@ -171,23 +178,28 @@

    Source code for ezyrb.approximation

                
               
    -

    - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

    - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
    -
    @@ -196,7 +208,6 @@

    Source code for ezyrb.approximation

       
    - + - - - - + + + - - - - - @@ -59,7 +62,7 @@
    - 1.0 + 1.1
    @@ -76,6 +79,7 @@
    + +
@@ -128,11 +133,13 @@ + +
    -
  • Docs »
  • +
  • »
  • Module code »
  • @@ -169,7 +176,7 @@

    Source code for ezyrb.database

         :param Scale scaler_snapshots: the scaler for the snapshots. Default is
             None meaning no scaling.
         """
    -    def __init__(self,
    +
    [docs] def __init__(self, parameters=None, snapshots=None, scaler_parameters=None, @@ -184,7 +191,7 @@

    Source code for ezyrb.database

                 raise RuntimeError
     
             if not (parameters is None) and not (snapshots is None):
    -            self.add(parameters, snapshots)
    +            self.add(parameters, snapshots)
    @property def parameters(self): @@ -210,7 +217,7 @@

    Source code for ezyrb.database

             else:
                 return self._snapshots
     
    -    def __getitem__(self, val):
    +
    [docs] def __getitem__(self, val): """ This method returns a new Database with the selected parameters and snapshots. @@ -218,16 +225,25 @@

    Source code for ezyrb.database

                 original Database.
             """
             return Database(self._parameters[val], self._snapshots[val],
    -                        self.scaler_parameters, self.scaler_snapshots)
    +                        self.scaler_parameters, self.scaler_snapshots)
    - def __len__(self): - return len(self._snapshots) +
    [docs] def __len__(self): + """ + This method returns the number of snapshots. + + :rtype: int + """ + return len(self._snapshots)
    [docs] def add(self, parameters, snapshots): """ + Add (by row) new sets of snapshots and parameters to the original + database. + + :param array_like parameters: the parameters to add. + :param array_like snapshots: the snapshots to add. """ - - if len(parameters) is not len(snapshots): + if len(parameters) != len(snapshots): raise RuntimeError('Different number of parameters and snapshots.') if self._parameters is None and self._snapshots is None: @@ -244,23 +260,28 @@

    Source code for ezyrb.database

                
               
    -

    - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

    - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
    -
    @@ -269,7 +290,6 @@

    Source code for ezyrb.database

       
    - + + + - - - - + + + - - - - - @@ -59,7 +62,7 @@
    - 1.0 + 1.1
    @@ -76,6 +79,7 @@
    + +
    @@ -128,11 +133,13 @@ + +
      -
    • Docs »
    • +
    • »
    • Module code »
    • @@ -157,9 +164,9 @@

      Source code for ezyrb.linear

       """
       
       import numpy as np
      -from scipy.interpolate import LinearNDInterpolator
      +from scipy.interpolate import LinearNDInterpolator
       
      -from .approximation import Approximation
      +from .approximation import Approximation
       
       
       
      [docs]class Linear(Approximation): @@ -171,8 +178,8 @@

      Source code for ezyrb.linear

               default is numpy.nan.
           """
       
      -    def __init__(self, fill_value=np.nan):
      -        self.fill_value = fill_value
      +
      [docs] def __init__(self, fill_value=np.nan): + self.fill_value = fill_value
      [docs] def fit(self, points, values): """ @@ -181,7 +188,8 @@

      Source code for ezyrb.linear

               :param array_like points: the coordinates of the points.
               :param array_like values: the values in the points.
               """
      -        self.intepolator = LinearNDInterpolator(points, values)
      + self.intepolator = LinearNDInterpolator(points, values, + fill_value=self.fill_value)
      [docs] def predict(self, new_point): """ @@ -198,23 +206,28 @@

      Source code for ezyrb.linear

                  
                 
      -

      - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

      - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
      -
      @@ -223,7 +236,6 @@

      Source code for ezyrb.linear

         
      - + - - - - + + + - - - - - @@ -59,7 +62,7 @@
      - 1.0 + 1.1
      @@ -76,6 +79,7 @@
      + +
      @@ -128,11 +133,13 @@ + +
        -
      • Docs »
      • +
      • »
      • Module code »
      • @@ -153,14 +160,18 @@

        Source code for ezyrb.pod

         """
        +Module for Proper Orthogonal Decomposition (POD).
        +Three different methods can be employed: Truncated Singular Value Decomposition,
        +Truncated Randomized Singular Value Decomposition, Truncated Singular Value 
        +Decomposition via correlation matrix.
         """
         import numpy as np
         
        -from .reduction import Reduction
        +from .reduction import Reduction
         
         
         
        [docs]class POD(Reduction): - def __init__(self, method='svd', **kwargs): +
        [docs] def __init__(self, method='svd', **kwargs): """ """ available_methods = { @@ -185,11 +196,11 @@

        Source code for ezyrb.pod

                         "Invalid method for POD. Please chose one among {}".format(
                             ', '.join(available_methods)))
         
        -        self.__method, default_args = method
        -        kwargs.update(default_args)
        +        self.__method, args = method
        +        args.update(kwargs)
         
        -        for hyperparam, value in kwargs.items():
        -            setattr(self, hyperparam, value)
        +        for hyperparam, value in args.items():
        +            setattr(self, hyperparam, value)
        @property def modes(self): @@ -203,7 +214,7 @@

        Source code for ezyrb.pod

             @property
             def singular_values(self):
                 """
        -        The singular values  
        +        The singular values
         
                 :type: numpy.ndarray
                 """
        @@ -216,7 +227,7 @@ 

        Source code for ezyrb.pod

                 :type: numpy.ndarray
                 """
                 self._modes, self._singular_values = self.__method(X)
        -        return self.modes.T.dot(X)
        + return self.modes.T.conj().dot(X)
        [docs] def expand(self, X): """ @@ -224,13 +235,16 @@

        Source code for ezyrb.pod

         
                 :type: numpy.ndarray
                 """
        -        return np.sum(self.modes * X, axis=1)
        + return self.modes.dot(X).T
        -
        [docs] def _truncation(self, X): +
        [docs] def _truncation(self, X, s): """ Return the number of modes to select according to the `rank` parameter. See POD.__init__ for further info. + :param numpy.ndarray X: the matrix to decompose. + :param numpy.ndarray s: the singular values of X. + :return: the number of modes :rtype: int """ @@ -239,11 +253,11 @@

        Source code for ezyrb.pod

                     beta = np.divide(*sorted(X.shape))
                     tau = np.median(s) * omega(beta)
                     rank = np.sum(s > tau)
        -        elif self.rank > 0 and svd_rank < 1:
        +        elif self.rank > 0 and self.rank < 1:
                     cumulative_energy = np.cumsum(s**2 / (s**2).sum())
        -            rank = np.searchsorted(cumulative_energy, svd_rank) + 1
        -        elif self.rank >= 1 and isinstance(svd_rank, int):
        -            rank = min(svd_rank, U.shape[1])
        +            rank = np.searchsorted(cumulative_energy, self.rank) + 1
        +        elif self.rank >= 1 and isinstance(self.rank, int):
        +            rank = self.rank #min(self.rank, U.shape[1])
                 else:
                     rank = X.shape[1]
         
        @@ -265,13 +279,13 @@ 

        Source code for ezyrb.pod

                 """
                 U, s = np.linalg.svd(X, full_matrices=False)[:2]
         
        -        rank = self._truncation(X)
        +        rank = self._truncation(X, s)
                 return U[:, :rank], s[:rank]
        [docs] def _rsvd(self, X): """ Truncated randomized Singular Value Decomposition. - + :param numpy.ndarray X: the matrix to decompose. :return: the truncated left-singular vectors matrix, the truncated singular values array, the truncated right-singular vectors matrix. @@ -286,13 +300,13 @@

        Source code for ezyrb.pod

                 Uy, s = np.linalg.svd(Y, full_matrices=False)[:2]
                 U = Q.dot(Uy)
         
        -        rank = self._truncation(X)
        +        rank = self._truncation(X, s)
                 return U[:, :rank], s[:rank]
        [docs] def _corrm(self, X): """ Truncated Singular Value Decomposition. calculated with correlation matrix. - + :param numpy.ndarray X: the matrix to decompose. :return: the truncated left-singular vectors matrix, the truncated singular values array, the truncated right-singular vectors matrix. @@ -300,7 +314,7 @@

        Source code for ezyrb.pod

                 """
         
                 if self.save_memory:
        -            corr = np.empty(size=(X.shape[1], X.shape[1]))
        +            corr = np.empty(shape=(X.shape[1], X.shape[1]))
                     for i, i_snap in enumerate(X.T):
                         for j, k_snap in enumerate(X.T):
                             corr[i, j] = np.inner(i_snap, k_snap)
        @@ -310,7 +324,7 @@ 

        Source code for ezyrb.pod

         
                 s, U = np.linalg.eig(corr)
                 U = X.dot(U) / np.sqrt(s)
        -        rank = self._truncation(X)
        +        rank = self._truncation(X, s)
         
                 return U[:, :rank], s[:rank]
        @@ -319,23 +333,28 @@

        Source code for ezyrb.pod

                    
                   
        -

        - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

        - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
        -
        @@ -344,7 +363,6 @@

        Source code for ezyrb.pod

           
        - + - - - - + + + - - - - - @@ -59,7 +62,7 @@
        - 1.0 + 1.1
        @@ -76,6 +79,7 @@
        + +
        @@ -128,11 +133,13 @@ + +
          -
        • Docs »
        • +
        • »
        • Module code »
        • @@ -157,9 +164,9 @@

          Source code for ezyrb.rbf

           """
           
           import numpy as np
          -from scipy.interpolate import Rbf
          +from scipy.interpolate import Rbf
           
          -from .approximation import Approximation
          +from .approximation import Approximation
           
           
           
          [docs]class RBF(Approximation): @@ -175,11 +182,23 @@

          Source code for ezyrb.rbf

               :cvar kernel: The radial basis function; the default is ‘multiquadric’.
               :cvar list interpolators: the RBF interpolators (the number of
                   interpolators depenend by the dimensionality of the output)
          +
          +    Example:
          +    >>> import ezyrb
          +    >>> import numpy as np
          +    >>> 
          +    >>> x = np.random.uniform(-1, 1, size=(4, 2))
          +    >>> y = np.array([np.sin(x[:, 0]), np.cos(x[:, 1]**3)]).T
          +    >>> rbf = ezyrb.RBF()
          +    >>> rbf.fit(x, y)
          +    >>> y_pred = rbf.predict(x)
          +    >>> print(np.allclose(y, y_pred))
          +
               """
           
          -    def __init__(self, kernel='multiquadric', smooth=0):
          +
          [docs] def __init__(self, kernel='multiquadric', smooth=0): self.kernel = kernel - self.smooth = smooth + self.smooth = smooth
          [docs] def fit(self, points, values): """ @@ -189,7 +208,7 @@

          Source code for ezyrb.rbf

                   :param array_like values: the values in the points.
                   """
                   self.interpolators = []
          -        for value in values:
          +        for value in values.T:
                       argument = np.hstack([points, value.reshape(-1, 1)]).T
                       self.interpolators.append(
                           Rbf(*argument, smooth=self.smooth, function=self.kernel))
          @@ -202,30 +221,36 @@

          Source code for ezyrb.rbf

                   :return: the interpolated values.
                   :rtype: numpy.ndarray
                   """
          -        return np.array([interp(*new_point) for interp in self.interpolators])
          + new_point = np.array(new_point) + return np.array([interp(*new_point.T) for interp in self.interpolators]).T
        -

        - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

        - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
        -
    @@ -234,7 +259,6 @@

    Source code for ezyrb.rbf

       
    - + - - - - + + + - - - - - @@ -59,7 +62,7 @@
    - 1.0 + 1.1
    @@ -76,6 +79,7 @@
    + +
@@ -128,11 +133,13 @@ + +
    -
  • Docs »
  • +
  • »
  • Module code »
  • @@ -157,21 +164,23 @@

    Source code for ezyrb.reducedordermodel

     """
     import numpy as np
     import math
    -from scipy.spatial import Delaunay
    +from scipy.spatial import Delaunay
     
     
     
    [docs]class ReducedOrderModel(object): - def __init__(self, database, reduction, approximation): +
    [docs] def __init__(self, database, reduction, approximation): self.database = database self.reduction = reduction - self.approximation = approximation + self.approximation = approximation
    -
    [docs] def fit(self): +
    [docs] def fit(self, *args, **kwargs): """ Calculate reduced space """ - self.approximation.fit(self.database.parameters, - self.reduction.reduce(self.database.snapshots.T)) + self.approximation.fit( + self.database.parameters, + self.reduction.reduce(self.database.snapshots.T).T, + *args, **kwargs) return self
    @@ -179,7 +188,27 @@

    Source code for ezyrb.reducedordermodel

             """
             Calculate predicted solution for given mu
             """
    -        return self.reduction.expand(self.approximation.predict(mu))
    + predicted_sol = self.reduction.expand( + np.atleast_2d(self.approximation.predict(mu)).T) + if 1 in predicted_sol.shape: + predicted_sol = predicted_sol.ravel() + return predicted_sol
    + +
    [docs] def test_error(self, test, norm=np.linalg.norm): + """ + Compute the mean norm of the relative error vectors of predicted + test snapshots. + + :param database.Database test: the input test database. + :param function func: the function used to assign at the vector of + errors a float number. It has to take as input a 'numpy.ndarray' + and returns a float. Default value is the L2 norm. + :return: the mean L2 norm of the relative errors of the estimated + test snapshots. + :rtype: numpy.float64 + """ + predicted_test = self.predict(test.parameters) + return np.mean(norm(predicted_test - test.snapshots, axis=1)/norm(test.snapshots, axis=1))
    [docs] def loo_error(self, norm=np.linalg.norm): """ @@ -206,7 +235,7 @@

    Source code for ezyrb.reducedordermodel

                 remaining_index = db_range[:]
                 remaining_index.remove(j)
                 new_db = self.database[remaining_index]
    -            rom = ReducedOrderModel(new_db, self.reduction,
    +            rom = type(self)(new_db, self.reduction,
                         self.approximation).fit()
     
                 error[j] = norm(self.database.snapshots[j] -
    @@ -271,23 +300,28 @@ 

    Source code for ezyrb.reducedordermodel

                
               
    -

    - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

    - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
    -
    @@ -296,7 +330,6 @@

    Source code for ezyrb.reducedordermodel

       
    - + + + - - - - + + + - - - - - @@ -59,7 +62,7 @@
    - 1.0 + 1.1
    @@ -76,6 +79,7 @@
    + +
    @@ -128,11 +133,13 @@ + +
      -
    • Docs »
    • +
    • »
    • Module code »
    • @@ -156,7 +163,7 @@

      Source code for ezyrb.reduction

       Module for the Reduction abstract class
       """
       
      -from abc import ABC, abstractmethod
      +from abc import ABC, abstractmethod
       
       
       
      [docs]class Reduction(ABC): @@ -173,23 +180,28 @@

      Source code for ezyrb.reduction

                  
                 
      -

      - © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

      - Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
      -
      @@ -198,7 +210,6 @@

      Source code for ezyrb.reduction

         
      - + + + - - - - + + + - - - - - @@ -59,7 +62,7 @@
      - 1.0 + 1.1
      @@ -76,6 +79,7 @@
    + +
@@ -128,11 +133,13 @@ + +
@@ -189,7 +203,6 @@

All modules for which code is available

- + + + - - - - + + + - - - - - - + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,11 +164,13 @@ + +
- @@ -278,7 +275,6 @@ - + - - - - + + + - - - - - @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,18 +159,20 @@ + +
@@ -199,32 +253,32 @@

Code Documentation - - - - - - + + -

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs. - @@ -233,7 +287,6 @@

Code Documentation jQuery(function () { SphinxRtdTheme.Navigation.enable(true); diff --git a/docs/build/html/contact.html b/docs/build/html/contact.html index a7064c89..116424cc 100644 --- a/docs/build/html/contact.html +++ b/docs/build/html/contact.html @@ -1,43 +1,46 @@ - - + - + - + - Contact — EZyRB 1.0 documentation + Contact — EZyRB 1.1 documentation + + + + + + + + - + - - - - + + + - - - - - - + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -145,18 +150,20 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs. - @@ -218,7 +225,6 @@

Contact jQuery(function () { SphinxRtdTheme.Navigation.enable(true); diff --git a/docs/build/html/contributing.html b/docs/build/html/contributing.html index 4d41f4ee..aa6ffba8 100644 --- a/docs/build/html/contributing.html +++ b/docs/build/html/contributing.html @@ -1,39 +1,42 @@ - - + - + - + - How to contribute — EZyRB 1.0 documentation + How to contribute — EZyRB 1.1 documentation + + + + + + + + - + - - - - + + + - - - - - @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -145,18 +150,20 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs. - @@ -243,7 +250,6 @@

How to contribute jQuery(function () { SphinxRtdTheme.Navigation.enable(true); diff --git a/docs/build/html/database.html b/docs/build/html/database.html index 36839956..aec669f4 100644 --- a/docs/build/html/database.html +++ b/docs/build/html/database.html @@ -1,43 +1,46 @@ - - + - + - + - Database — EZyRB 1.0 documentation + Database — EZyRB 1.1 documentation + + + + + + - + + + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ +
+ @@ -154,11 +167,13 @@ + +
    -
  • Docs »
  • +
  • »
  • Code Documentation »
  • @@ -167,7 +182,7 @@
  • - + View page source @@ -190,29 +205,29 @@ -

    Database

    +

    Database

    Database class

    -

    Database.parameters

    +

    Database.parameters

    The matrix containing the input parameters (by row).

    -

    Database.snapshots

    +

    Database.snapshots

    The matrix containing the snapshots (by row).

    -

    Database.__getitem__

    +

    Database.__getitem__

    This method returns a new Database with the selected parameters and snapshots.

    -

    Database.__len__

    -

    +

    Database.__len__

    +

    This method returns the number of snapshots.

    -

    Database.add

    -

    +

    Database.add

    +

    Add (by row) new sets of snapshots and parameters to the original database.

    -
    +
    -class Database(parameters=None, snapshots=None, scaler_parameters=None, scaler_snapshots=None)[source]
    +class Database(parameters=None, snapshots=None, scaler_parameters=None, scaler_snapshots=None)[source]

    Bases: object

    Database class

    @@ -227,29 +242,39 @@
-
+
-add(parameters, snapshots)[source]
-
+add(parameters, snapshots)[source] +

Add (by row) new sets of snapshots and parameters to the original +database.

+
+
Parameters
+
    +
  • parameters (array_like) – the parameters to add.

  • +
  • snapshots (array_like) – the snapshots to add.

  • +
+
+
+
-
+
-property parameters
+property parameters

The matrix containing the input parameters (by row).

Return type
-

numpy.ndarray

+

numpy.ndarray

-
+
-property snapshots
+property snapshots

The matrix containing the snapshots (by row).

Return type
-

numpy.ndarray

+

numpy.ndarray

@@ -263,32 +288,32 @@
- @@ -297,7 +322,6 @@ - + - - - - + + + - - - - - @@ -60,7 +62,7 @@
- 1.0 + 1.1
@@ -77,6 +79,7 @@ + + @@ -129,18 +133,20 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
- @@ -212,7 +512,6 @@

E

- + - - - - + + + - - - - - @@ -60,7 +63,7 @@
- 1.0 + 1.1
@@ -77,6 +80,7 @@ + + @@ -144,18 +149,20 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs. - @@ -261,7 +269,6 @@

Indices and tables jQuery(function () { SphinxRtdTheme.Navigation.enable(true); diff --git a/docs/build/html/linear.html b/docs/build/html/linear.html index be9cffc2..6a7cc527 100644 --- a/docs/build/html/linear.html +++ b/docs/build/html/linear.html @@ -1,43 +1,46 @@ - - + - + - + - Linear — EZyRB 1.0 documentation + Linear — EZyRB 1.1 documentation + + + + + + - + + + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ +
+ @@ -154,11 +164,13 @@ + +
    -
  • Docs »
  • +
  • »
  • Code Documentation »
  • @@ -167,7 +179,7 @@
  • - + View page source @@ -190,21 +202,21 @@ -

    Linear

    +

    Linear

    Multidimensional linear interpolator.

    -

    Linear.fit

    +

    Linear.fit

    Construct the interpolator given points and values.

    -

    Linear.predict

    +

    Linear.predict

    Evaluate interpolator at given new_points.

    -
    +
    -class Linear(fill_value=nan)[source]
    -

    Bases: ezyrb.approximation.Approximation

    +class Linear(fill_value=nan)[source] +

    Bases: ezyrb.approximation.Approximation

    Multidimensional linear interpolator.

    Parameters
    @@ -213,29 +225,14 @@ default is numpy.nan.

    -
    +
    -_abc_cache = <_weakrefset.WeakSet object>
    +_abc_impl = <_abc_data object>
    -
    +
    -_abc_negative_cache = <_weakrefset.WeakSet object>
    -
    - -
    -
    -_abc_negative_cache_version = 48
    -
    - -
    -
    -_abc_registry = <_weakrefset.WeakSet object>
    -
    - -
    -
    -fit(points, values)[source]
    +fit(points, values)[source]

    Construct the interpolator given points and values.

    Parameters
    @@ -247,9 +244,9 @@
    -
    +
    -predict(new_point)[source]
    +predict(new_point)[source]

    Evaluate interpolator at given new_points.

    Parameters
    @@ -259,7 +256,7 @@

    the interpolated values.

    Return type
    -

    numpy.ndarray

    +

    numpy.ndarray

    @@ -273,32 +270,32 @@
- @@ -307,7 +304,6 @@ - + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,11 +170,13 @@ + +
@@ -402,7 +415,6 @@ - + - - - - + + + - - - - - @@ -62,7 +65,7 @@
- 1.0 + 1.1
@@ -79,6 +82,7 @@ + + @@ -131,11 +136,13 @@ + +
-

- © Copyright Copyright 2016-2019, EZyRB contributors + © Copyright Copyright 2016-2019, EZyRB contributors. - Last updated on Dec 17, 2019. + Last updated on Apr 01, 2021.

- Built with Sphinx using a theme provided by Read the Docs. + + + + Built with Sphinx using a + + theme + + provided by Read the Docs.
- @@ -236,7 +263,6 @@

Python Module Index

- + + + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,11 +164,13 @@ + +
-
+

Example: +>>> import ezyrb +>>> import numpy as np +>>> +>>> x = np.random.uniform(-1, 1, size=(4, 2)) +>>> y = np.array([np.sin(x[:, 0]), np.cos(x[:, 1]**3)]).T +>>> rbf = ezyrb.RBF() +>>> rbf.fit(x, y) +>>> y_pred = rbf.predict(x) +>>> print(np.allclose(y, y_pred))

+
-_abc_cache = <_weakrefset.WeakSet object>
+_abc_impl = <_abc_data object>
-
+
-_abc_negative_cache = <_weakrefset.WeakSet object>
-
- -
-
-_abc_negative_cache_version = 48
-
- -
-
-_abc_registry = <_weakrefset.WeakSet object>
-
- -
-
-fit(points, values)[source]
+fit(points, values)[source]

Construct the interpolator given points and values.

Parameters
@@ -257,9 +264,9 @@
-
+
-predict(new_point)[source]
+predict(new_point)[source]

Evaluate interpolator at given new_points.

Parameters
@@ -269,7 +276,7 @@

the interpolated values.

Return type
-

numpy.ndarray

+

numpy.ndarray

@@ -283,32 +290,32 @@
- @@ -317,7 +324,6 @@ - + + + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,11 +167,13 @@ + +
@@ -311,32 +347,32 @@ - @@ -345,7 +381,6 @@ - + + + - - - - + + + - - - - - - - + + @@ -61,7 +64,7 @@
- 1.0 + 1.1
@@ -78,6 +81,7 @@ + + @@ -154,11 +164,13 @@ + +
- @@ -278,7 +275,6 @@ - + + - - - - - + + + - - - - - + + @@ -60,7 +65,7 @@
- 1.0 + 1.1
@@ -77,6 +82,7 @@ + + @@ -129,19 +136,19 @@ + +
@@ -155,8 +162,7 @@ @@ -170,23 +176,28 @@
- @@ -195,7 +206,6 @@ -