/samplebox.py (a0e0b4e593204ff6254f23a67652804db07800a6) (4284 bytes) (mode 100644) (type blob)
#!/usr/bin/env python
# coding: utf-8
"""
SampleBox = sample_R(f_model) + g_values
"""
import numpy as np
class SampleBox:
"""
SampleBox = sample_R(f_model) + g_values
.sampled_plan object
.g_values
.failsi
Souřadnice primárně z prostoru modelu, ty co jsme rovnou
posilali do g_modelu!
"""
# nechtěl bys nazvy proměnných?
def __new__(cls, sample_object, g_values=(), gm_signature=''):
"""
Jedname tvrdě - není-li vstup konzistentní,
tak sbox vůbec nevytvaříme
"""
g_values = np.atleast_1d(g_values)
if len(sample_object) == len(g_values):
sb = super(SampleBox, cls).__new__(cls)
# nepotrebujeme žádné rozdělení, nic
sb.sampled_plan = sample_object
sb.g_values = g_values
sb.gm_signature = gm_signature
return sb
else:
raise ValueError("Sample and g_value hasn't the same length. Zkrátka, do sebe nepatří")
def __str__(sb):
return '%s: %s at %s' %(sb.gm_signature, sb.g_values, sb.sampled_plan)
def __repr__(sb):
return 'SampleBox(%s, %s, %s)' %(repr(sb.sampled_plan), repr(sb.g_values), repr(sb.gm_signature))
def __len__(sb):
return len(sb.g_values)
def __call__(sb):
# я ваще хз
# offer next sample?
# do calculation?
# add to this sample?
# return new instance?
# мар, сакра, кароно?
# finally, we will offer sample to sample
# like BlackBox does
return sb.sampled_plan(1)
def __getitem__(sb, slice):
return SampleBox(sb.sampled_plan[slice], sb.g_values[slice], sb.gm_signature)
def __getattr__(sb, attr):
if attr == 'samplebox':
return sb
elif attr == 'failsi':
# ~(g_values>0) to handle nan
return ~(sb.g_values>0)
elif attr == 'success_points':
return np.argwhere(sb.g_values>0).flatten()
elif attr == 'failure_points':
return np.argwhere(~(sb.g_values>0)).flatten()
elif attr == 'failure_samples':
return sb[~(sb.g_values>0)]
elif attr == 'success_samples':
return sb[sb.g_values>0]
# to je jistě k samplovi
else:
return getattr(sb.sampled_plan, attr)
def add_sample(sb, input_sb):
input_sb.consistency_check()
# ты чьих будешь?
# where are you from?
# are you one of us?
if sb.gm_signature == input_sb.gm_signature:
# dá se tuhle kontrolu jednoduše napálit, ale to neřeším
sb.sampled_plan.add_sample(input_sb.sampled_plan)
sb.g_values = np.append(sb.g_values, input_sb.g_values)
return sb.consistency_check()
# je to pro případ prázdného sample_boxu
elif sb.gm_signature == '':
# dá se tuhle kontrolu jednoduše napálit, ale to neřeším
sb.sampled_plan.add_sample(input_sb.sampled_plan)
sb.g_values = np.append(sb.g_values, input_sb.g_values)
sb.gm_signature = input_sb.gm_signature
return sb.consistency_check()
else:
#raise ValueError("Merge sa nám nějak nepovedol")
raise ValueError("gm_signatures are unequal. You are probably trying to merge data from different sources")
def new_sample(sb, input_sb):
"""
We want to create new SampleBox object with our distribution (f_model)
but with data of input_sb (just like f_model.new_sample() does)
"""
return SampleBox(sb.sampled_plan.new_sample(input_sb), input_sb.g_values, input_sb.gm_signature)
def consistency_check(sb):
if len(sb.sampled_plan)==len(sb.g_values):
return True
else:
# уг тодӥськы чик мар кароно
# ConsistencyError
raise ValueError('SampleBox is in an inconsistent state and nobody knows what to do with it')
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
28117 |
0907e38499eeca10471c7d104d4b4db30b8b7084 |
IS_stat.py |
100644 |
blob |
6 |
0916b75b752887809bac2330f3de246c42c245cd |
__init__.py |
100644 |
blob |
72 |
458b7e2ca46acd9ec0d2caf3cc4d72e515bb73dc |
__main__.py |
100644 |
blob |
73368 |
3d245b8568158ac63c80fa0847631776a140db0f |
blackbox.py |
100644 |
blob |
11243 |
10c424c2ce5e8cdd0da97a5aba74c54d1ca71e0d |
candybox.py |
100644 |
blob |
29927 |
066a2d10ea1d21daa6feb79fa067e87941299ec4 |
convex_hull.py |
100644 |
blob |
102798 |
059ae717e71c651975673420cd8230fbef171e5e |
dicebox.py |
100644 |
blob |
36930 |
a775d1114bc205bbd1da0a10879297283cca0d4c |
estimation.py |
100644 |
blob |
34394 |
3f0ab9294a9352a071de18553aa687c2a9e6917a |
f_models.py |
100644 |
blob |
31142 |
3e14ac49d16a724bb43ab266e8bea23114e47958 |
g_models.py |
100644 |
blob |
20908 |
457329fe567f1c0a9950c21c7c494cccf38193cc |
ghull.py |
100644 |
blob |
2718 |
5d721d117448dbb96c554ea8f0e4651ffe9ac457 |
gp_plot.py |
100644 |
blob |
29393 |
96162a5d181b8307507ba2f44bafe984aa939163 |
lukiskon.py |
100644 |
blob |
2004 |
6ea8dc8f50a656c48f786d5a00bd6398276c9741 |
misc.py |
040000 |
tree |
- |
c0c40f3968c1e44d1d7114eb70bd72173342d4fa |
mplot |
100644 |
blob |
1462 |
437b0d372b6544c74fea0d2c480bb9fd218e1854 |
plot.py |
100644 |
blob |
2807 |
1feb1d43e90e027f35bbd0a6730ab18501cef63a |
plotly_plot.py |
040000 |
tree |
- |
92aa143106644f120bdc42b9062db3513c499e60 |
qt_gui |
100644 |
blob |
8566 |
5c8f8cc2a34798a0f25cb9bf50b5da8e86becf64 |
reader.py |
100644 |
blob |
4284 |
a0e0b4e593204ff6254f23a67652804db07800a6 |
samplebox.py |
100644 |
blob |
6558 |
df0e88ea13c95cd1463a8ba1391e27766b95c3a5 |
sball.py |
100644 |
blob |
6739 |
0b6f1878277910356c460674c04d35abd80acf13 |
schemes.py |
100644 |
blob |
76 |
11b2fde4aa744a1bc9fa1b419bdfd29a25c4d3e8 |
shapeshare.py |
100644 |
blob |
54074 |
ba978868adb487385157afa5b3420f9ad90e4f46 |
simplex.py |
100644 |
blob |
13090 |
2b9681eed730ecfadc6c61b234d2fb19db95d87d |
spring.py |
100644 |
blob |
10940 |
6965eabdb5599bb22773e7fef1178f9b2bb51efe |
stm_df.py |
040000 |
tree |
- |
2e8d08eec735088322a3ea5f667ff338db7808ca |
testcases |
100644 |
blob |
2465 |
d829bff1dd721bdb8bbbed9a53db73efac471dac |
welford.py |
100644 |
blob |
20204 |
1a281748b81481f8d51c3793bcf46b0034082152 |
whitebox.py |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/WellMet
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/WellMet
Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/WellMet
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main