Page MenuHomec4science

manual_sampler.py
No OneTemporary

File Metadata

Created
Fri, May 3, 19:26

manual_sampler.py

# Copyright (C) 2018 by the RROMPy authors
#
# This file is part of RROMPy.
#
# RROMPy is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# RROMPy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with RROMPy. If not, see <http://www.gnu.org/licenses/>.
#
import numpy as np
from copy import deepcopy as copy
from .generic_sampler import GenericSampler
from rrompy.utilities.base.types import List, DictAny, paramList
from rrompy.parameter import checkParameterList
__all__ = ['ManualSampler']
class ManualSampler(GenericSampler):
"""Manual generator of sample points."""
def __init__(self, lims:paramList, points:paramList,
parameterMap : DictAny = 1.,
normalFoci : List[np.complex] = [-1., 1.]):
super().__init__(lims = lims, parameterMap = parameterMap)
self.points = points
self._normalFoci = normalFoci
def normalFoci(self, d : int = 0):
return self._normalFoci
@property
def points(self):
"""Value of points."""
return self._points
@points.setter
def points(self, points):
points = checkParameterList(points, self.npar)
self._points = points
def __str__(self) -> str:
return "{}[{}]".format(self.name(), "_".join(map(str, self.points)))
def generatePoints(self, n:int, reorder : bool = True) -> paramList:
"""Array of sample points."""
if n > len(self.points):
pts = copy(self.points)
for j in range(int(np.ceil(n / len(self.points)))):
pts.append(self.points)
else:
pts = self.points
x = checkParameterList(pts[list(range(n))], self.npar)
return x

Event Timeline