Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F60984614
manual_sampler.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, May 3, 19:26
Size
2 KB
Mime Type
text/x-python
Expires
Sun, May 5, 19:26 (2 d)
Engine
blob
Format
Raw Data
Handle
17449275
Attached To
R6746 RationalROMPy
manual_sampler.py
View Options
# 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
Log In to Comment