iam-git / WellMet (public) (License: MIT) (since 2021-08-31) (hash sha1)
WellMet is pure Python framework for spatial structural reliability analysis. Or, more specifically, for "failure probability estimation and detection of failure surfaces by adaptive sequential decomposition of the design domain".
List of commits:
Subject Hash Author Date (UTC)
blackbox: MinEnergyCensoredSampling is ready ba76383a0723c364aa44b79df51a320c0b8361cd Олёш 2020-08-04 10:12:25
blackbox: KechatoLukiskon comed back! 01237377ef931193951b7446561c88b4e10c0dae Олёш 2020-08-04 00:56:09
blackbox: WIP 897b4334a6a605702f9a3bfdccf57165a5dc1867 Олёш 2020-08-03 21:33:23
blackbox: WIP a59af121f46e67e275b39858ba38131c0002077d Олёш 2020-08-03 02:00:41
lukiskon comed back! blackbox WIP 2fc15ae88e89a4208149099a9e898e1a7448de31 Олёш 2020-08-02 21:56:24
every box got its own name to call him df268dcccc012fff6499d6a3427253f3d352072a Олёш 2020-08-01 22:28:36
estimation: little fix in Voronoi_2_point 84115e8d544a78bdaabcd624336ae181e61c845e Олёш 2020-08-01 19:35:48
candybox: reworked 07551958091f48d8f7eb62d27468c2abad030a33 Олёш 2020-08-01 17:24:33
IS_stat: defaultdict replaced by the own one, ISSI.add_single_event_data method added 131e8c23d8f164ae92b838451fc9976a888bffeb Олёш 2020-08-01 00:46:53
IS_stat: IS_like() and ISSI.delete_event_data() methods added a9b4514c9a802797bc15f518b3aeef61f4e3f24e Олёш 2020-07-31 19:58:21
blackbox: MinEnergyCensoredSampling at very begining a924d5d2991f624932d2f0165078e930bda65c58 Олёш 2020-07-31 01:04:09
estimation: --dtto-- 3816060e9da61b99593b7887ec66d6b0a8b239b9 Олёш 2020-07-28 11:27:22
estimation: nejde cell sampling pořadně zlepšit 824d5a2cf7bd10c0fec4b152549d61873cb897dc Олёш 2020-07-28 08:50:45
estimation: playing with cell sampling 78a8dc9a52993876b8a7991590590990efd98812 Олёш 2020-07-28 01:52:35
qt_plot: draw failure boundary by 1000 points d8737247d6cbdb52cc1b1a3d0935edd60234b515 Олёш 2020-07-27 10:38:57
estimation: Voronoi_2_point estimation node_pf_coloring fixed 35fc3d622fe9d5cfa519f1484862108b4003688b Олёш 2020-07-27 10:35:06
candybox: pandas index mess fix, __getattr__ will return numpyed array 10e7c39a69bd105780924319bbafb58602251a9d Олёш 2020-07-27 10:31:43
qt_plot: SimplexEstimationWidget: nodes size increased, VoronoiGraph: redraw item added 8176d66545bfcfa6ee4ea64cbdf3ffd9bbf5ca11 Олёш 2020-07-24 07:01:13
qt_plot: grafy aspoň něco kreslí c2c628d6edf48eb607e44902fa14022c97832cb1 Олёш 2020-07-22 14:40:30
qt_plot: с тех виӝетů на пока хватит 55ee0ccf1d72d6515a66b673c809b9548a2b1ecb Олёш 2020-07-22 09:01:26
Commit ba76383a0723c364aa44b79df51a320c0b8361cd - blackbox: MinEnergyCensoredSampling is ready
Author: Олёш
Author date (UTC): 2020-08-04 10:12
Committer name: Олёш
Committer date (UTC): 2020-08-04 10:12
Parent(s): 01237377ef931193951b7446561c88b4e10c0dae
Signer:
Signing key:
Signing status: N
Tree: 3fc088e9ed7572296d2c71ddd6463b39ff8b65da
File Lines added Lines deleted
blackbox.py 151 76
candybox.py 31 14
File blackbox.py changed (mode: 100644) (index b7128ae..550ac84)
... ... from scipy import spatial
15 15 from . import plot from . import plot
16 16 import pickle import pickle
17 17 from . import IS_stat from . import IS_stat
18 from .candybox import CandyBox
18 19 from . import sball # for adaptive censoring from . import sball # for adaptive censoring
19 20 from . import f_models # for adaptive censoring from . import f_models # for adaptive censoring
20 21 from scipy import stats # for adaptive censoring from scipy import stats # for adaptive censoring
 
... ... class BlackBox:
157 158 if attr == 'blackbox': if attr == 'blackbox':
158 159 return bx return bx
159 160
161 # branime sa rekurzii
162 # defend against recursion
163 # рекурсилы пезьдэт!
164 if attr == 'sample_box':
165 raise AttributeError
166
160 167 # По всем вопросам обращайтесь # По всем вопросам обращайтесь
161 168 # на нашу горячую линию # на нашу горячую линию
162 169 else: else:
 
... ... class BlackBox:
184 191 bx.sorted_plan_U[i] = np.insert(bx.sorted_plan_U[i], plan_index, input_sample.U[j,i]) bx.sorted_plan_U[i] = np.insert(bx.sorted_plan_U[i], plan_index, input_sample.U[j,i])
185 192
186 193 def regen(bx): def regen(bx):
194 # шайтан регенираци лэзьиз
195 bx._logger(msg='regeneration started')
187 196 # pro LHS_like_correction # pro LHS_like_correction
188 197 bx.sorted_plan_U = [i for i in range(bx.nvar)] # just create list bx.sorted_plan_U = [i for i in range(bx.nvar)] # just create list
189 198 for i in range(bx.nvar): for i in range(bx.nvar):
 
... ... class Censoring(BlackBox):
244 253 super().__init__(sample_object) super().__init__(sample_object)
245 254
246 255 def __repr__(bx): def __repr__(bx):
247 return "%s(%s, %s)"%('Censoring', repr(bx.sample_box), repr(bx.tri_space))
256 return "%s(%s, %s)"%(bx.__class__.__name__, repr(bx.sample_box), repr(bx.tri_space))
248 257
249 258 def __str__(bx): def __str__(bx):
250 return str('Censoring')
259 return str(bx.__class__.__name__)
251 260
252 261 def increment(bx, input_sample): def increment(bx, input_sample):
253 262 super().increment(input_sample) super().increment(input_sample)
 
... ... class Censoring(BlackBox):
267 276
268 277 def regen(bx): def regen(bx):
269 278 super().regen() super().regen()
279 # chcu zachytit spadnuti QHull na začatku, kdy ještě není dostatek teček.
280 # Jinak je třeba nechat QHull spadnout
281 if bx.nsim > 2*bx.nvar + 3:
282 # tady je to OK
283 bx.tri = spatial.Delaunay(getattr(bx.sampled_plan, bx.tri_space), incremental=True)
284 if len(bx.tri.coplanar):
285 #print('triangulace v pořádku není')
286 bx._logger(msg='triangulation is coplanar')
287 else:
288 #print('triangulace je v pořádku')
289 bx._logger(msg='triangulation is OK')
290
291 else: # lze přípustit chybu triangulace
292 try:
293 bx.tri = spatial.Delaunay(getattr(bx.sampled_plan, bx.tri_space), incremental=True)
294 except:
295 bx._logger(msg='triangulation failed')
296
297
270 298 # pokud tecek nestaci na vytvareni aspon jedneho simplexu - pokrcim rameny # pokud tecek nestaci na vytvareni aspon jedneho simplexu - pokrcim rameny
271 299 try: try:
272 300 # tady je to OK # tady je to OK
 
... ... class AdaptiveCensoring(Censoring):
704 732
705 733
706 734
707 class MinEnergyCensoredSampling(AdaptiveCensoring):
735 class MinEnergyCensoredSampling(Censoring):
708 736 # už mě to dědění nebaví # už mě to dědění nebaví
709 737 # без поллитры не разберёшься, что этот слоёный пирог делает # без поллитры не разберёшься, что этот слоёный пирог делает
710 738 def __init__(bx, sample_object, tri_space='Rn', tree_space=None, sampling_space=None, kechato_space='U', \ def __init__(bx, sample_object, tri_space='Rn', tree_space=None, sampling_space=None, kechato_space='U', \
711 potencial='ksee', p_norm=2, pf_lim=(1,0), budget=1000, simplex_budget=100):
712 super().__init__(sample_object, tri_space, pf_lim)
739 potencial='ksee', p_norm=2, budget=1000, simplex_budget=100):
740
741 bx.sball = sball.Sball(sample_object.nvar)
742 bx.base_r = bx.sball.get_r(0.5)
713 743
714 744 if tree_space is None: if tree_space is None:
715 745 bx.tree_space = tri_space bx.tree_space = tri_space
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
720 750 bx.sampling_space = tri_space bx.sampling_space = tri_space
721 751 else: else:
722 752 bx.sampling_space = sampling_space bx.sampling_space = sampling_space
723
724 bx.sampling_space = sampling_space
753
754 bx.kechato_space = kechato_space
725 755 # pro simplexy. Chcu ukladat jejich míry # pro simplexy. Chcu ukladat jejich míry
726 bx.siss = IS_stat.ISSI()
756 # viz. .regen()
757 #bx.siss = IS_stat.ISSI()
727 758 bx.budget = budget bx.budget = budget
728 759 bx.simplex_budget = simplex_budget bx.simplex_budget = simplex_budget
729 760 bx.p_norm = p_norm bx.p_norm = p_norm
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
731 762
732 763 # for current candidates # for current candidates
733 764 # kandidaty musí být 'judged' a 'assessed' # kandidaty musí být 'judged' a 'assessed'
734 bx.candidates_index = dict()
765 # viz. regen()
766 #bx.candidates_index = dict()
735 767 # krám, přece třidíme odpad! # krám, přece třidíme odpad!
736 768 bx.former_candidates = [] bx.former_candidates = []
737 769 bx.unjudged_candidates = [] bx.unjudged_candidates = []
738 770 # user .candidates should be initializated in the base class # user .candidates should be initializated in the base class
739 771 # but we need to set additional attributes to them # but we need to set additional attributes to them
772 super().__init__(sample_object, tri_space)
740 773 bx.candidates = CandyBox(bx.f()) bx.candidates = CandyBox(bx.f())
741 774
742 775
776
777
743 778 def regen(bx): def regen(bx):
744 779 """ """
745 780 regen() recreates data structures of the box. regen() recreates data structures of the box.
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
748 783 super().regen() super().regen()
749 784 # zás mám vyhodit odhady? # zás mám vyhodit odhady?
750 785 bx.siss = IS_stat.ISSI() bx.siss = IS_stat.ISSI()
786 bx.candidates_index = dict()
751 787
752 # chcu zachytit spadnuti QHull na začatku, kdy ještě není
753 # dostatek teček. Je-li bx.tri fakticky existuje, tj.
754 # triangulace jíž existovala - je třeba nechat QHull spadnout
755 choose = bx.LHS_like_correction(bx.get_candidates(1))
756 if bx.nsim < bx.nvar + 1: # je to legální
757 bx._log("we have no enough points to build the triangulation, so", str(choose), "is our recommendation")
758 return choose
788 if "tri" in dir(bx):
789 # tri - Deloneho triangulace
790 bx.simplex_events = bx.get_events()
791 bx.estimate_outside()
792 for simplex_id in range(bx.tri.nsimplex):
793 # zde jen počítame
794 bx.estimate_simplex(simplex_id)
795
796
797 elif bx.nsim > 0: # požaduji, aby nějaké těčíčky byly vždy pritomné
759 798
760 elif bx.nsim < 2*bx.nvar + 3: # to je ještě budiž
761 bx._log("we have troubles with the triangulation, so we offer this random sample for now:", str(choose))
762 return choose
763 else: # no to teda ne!
764 raise ValueError("AdaptiveCensoring: s tou triangulací je fakt něco není v pořadku")
799 candidates = IS_stat.IS(bx.f, bx.h, space_from_h='R', space_to_f=bx.sampling_space, Nsim=bx.budget)
800 # nevím co tam bylo za h-ko, ale nechť IM zůstane 1
801 implicit_multiplicator = 1
802
803 # teoreticky lze
804 #bx.siss.add_IS_serie(candidates.w, candidates.simplex, implicit_multiplicator)
805
806 bx.assess_candidates(candidates)
807 # uložíme
808 bx.candidates_index[-1] = candidates
809
810
811
812
813
814
815 def export_estimation(bx):
816 simplices = np.array(tuple(bx.siss.estimations.keys()))
817 probabilities = np.array(tuple(bx.siss.estimations.values()))
818
819 estimation = dict()
820 estimation[-1] = np.sum(probabilities[simplices == -1])
821
822 # jevy aj klidně in-place (nerobím kopiju)
823 events = simplices[simplices != -1]
824 probabilities = probabilities[simplices != -1]
825
826 # zhruba - get_events() vrací pole s odpovidajícími čísly jevů pro každý simplex, počineje od nuly
827 # tím slajsingem my jakoby vybirame ke každemu nalezenemu simplexovi ten správnej mu odpovídajicí jev
828 events = bx.simplex_events[events]
829
830 for i in range(3): # kvůli 0,1,2 robiť cyklus?
831 estimation[i] = np.sum(probabilities[events == i])
832
833 bx.guessbox.guess('TRI_overall_estimations', bx.tri.npoints, estimation)
765 834
766 835
767 836 def increment(bx, input_sample): def increment(bx, input_sample):
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
775 844
776 845
777 846
778 # current estimations
779 try: # to čo já vidím v kódu - ISSI slovníky se pokažde generujóu znovu,
780 # není nutně je explicitně kopirovať
781 # nsimky, Alexi, prosím, překopej
782 bx.guessbox.guess('TRI_overall_estimations', bx.nsim-1, bx.oiss.estimations)
783 bx.guessbox.guess('TRI_current_estimations', bx.nsim-1, bx.ciss.estimations)
784 except AttributeError:
785 bx.guessbox.guess('TRI_upper_pf', bx.nsim-1, 1)
786
787
788 847 # fór je v tom, že tu triangulaci nemůžeme výtvořit hned na začátku # fór je v tom, že tu triangulaci nemůžeme výtvořit hned na začátku
789 848 if "tri" in dir(bx): if "tri" in dir(bx):
790 849 # tri - Deloneho triangulace # tri - Deloneho triangulace
791 850
851 bx.export_estimation()
852
853 # чыры-пыры
854 # invalidujeme staré vzorky
855 if -2 in bx.candidates_index:
856 bx.former_candidates.append(bx.candidates_index.pop(-2))
857
858
792 859 former_simplices = bx.tri.simplices former_simplices = bx.tri.simplices
860 mixed = bx.is_mixed()
793 861
794 862 # sample je jíž převeden na f (v .add_sample()), takže je to bezpěčný # sample je jíž převeden na f (v .add_sample()), takže je to bezpěčný
795 863 bx.tri.add_points(getattr(input_sample, bx.tri_space)) bx.tri.add_points(getattr(input_sample, bx.tri_space))
864 bx.simplex_events = bx.get_events()
796 865 # print('increment se podaril') # print('increment se podaril')
797 866 if len(bx.tri.coplanar): # pokud triangulace není v pořadku if len(bx.tri.coplanar): # pokud triangulace není v pořadku
798 867 #print('triangulace v pořádku není') #print('triangulace v pořádku není')
799 868 bx._logger(msg='triangulation has coplanar points') bx._logger(msg='triangulation has coplanar points')
800 869
801 # invalidujeme staré
802 if -2 in bx.candidates_index:
803 pass
804 #D.pop(k[,d])
805 870
806 # pokud není splněná podmínka,
807 # tak nemáme jistotu, že se potenciály nezměni
808 # ani u kandidatů, které se nacházejí v pojíštěných státem buňkách
809 if (bx.tree_space != bx.tri_space) or (bx.p_norm != 2):
810 for candidates in bx.candidates_index.values():
811 bx.assess_candidates(candidates)
812 871
813 872
814 873 # zkontrolujeme co se změnilo # zkontrolujeme co se změnilo
815 874 # předpokladám, že se počet simplexů přidaním bodů nezměnší # předpokladám, že se počet simplexů přidaním bodů nezměnší
816 875 equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)] equal_mask = former_simplices == bx.tri.simplices[:len(former_simplices)]
817 changed_simplices_ids = np.argwhere(~equal_mask)
876 changed_simplices_ids = np.argwhere(~equal_mask.all(axis=1)).flatten()
877
878 # invalidirujeme jejich odhady
818 879 for simplex_id in changed_simplices_ids: for simplex_id in changed_simplices_ids:
819 # invalidirujeme jejich odhady
820 880 bx.siss.delete_event_data(simplex_id) bx.siss.delete_event_data(simplex_id)
821 # a hned je znovu spočítame
822 bx.simplex_estimation(simplex_id)
881
882 # popajem pouze mixy, ty musel jsem spočítat před aktualizací
883 for simplex_id in changed_simplices_ids[mixed[changed_simplices_ids]]:
884 bx.former_candidates.append(bx.candidates_index.pop(simplex_id))
885
886
887 # pokud není splněná podmínka,
888 # tak nemáme jistotu, že se potenciály nezměni
889 # ani u kandidatů, které se nacházejí v pojíštěných státem buňkách
890 if (bx.tree_space != bx.tri_space) or (bx.p_norm != 2):
891 for candidates in bx.candidates_index.values():
892 bx.assess_candidates(candidates)
893
894 # změněné simplexy přepočítáme
895 for simplex_id in changed_simplices_ids:
896 bx.estimate_simplex(simplex_id)
897
823 898
824 899
825 900 # teď nové simplexy # teď nové simplexy
826 901 # simplexy свежего разлива # simplexy свежего разлива
827 for simplex_id in range(len(former_simplices), len(bx.tri.simplices)):
902 for simplex_id in range(len(former_simplices), bx.tri.nsimplex):
828 903 # zde jen počítame # zde jen počítame
829 bx.simplex_estimation(simplex_id)
904 bx.estimate_simplex(simplex_id)
830 905
831 906
832 907
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
836 911 test = input_sample.simplex > -1 test = input_sample.simplex > -1
837 912 # эскером # эскером
838 913 if not test.all(): if not test.all():
839 bx.outside_estimation()
914 bx.former_candidates.append(bx.candidates_index.pop(-1))
915 bx.siss.delete_event_data(-1)
916 bx.estimate_outside()
840 917 except BaseException as e: except BaseException as e:
841 918 msg = "input sample didn't provide correct 'simplex' attribute " msg = "input sample didn't provide correct 'simplex' attribute "
842 919 error_msg = bx.__class__.__name__ + ": " + msg + repr(e) error_msg = bx.__class__.__name__ + ": " + msg + repr(e)
843 920 bx._logger(msg=error_msg) bx._logger(msg=error_msg)
844 bx.outside_estimation()
921 bx.former_candidates.append(bx.candidates_index.pop(-1))
922 bx.siss.delete_event_data(-1)
923 bx.estimate_outside()
845 924
846 925
847 926
848 for i in range(len(bx.tri.simplices)):
849 len(np.setdiff1d(simplex, bx.failure_points))
850 927
851 # drop indexes
852 bx.simplex_index = {'failure':[], 'success':[], 'mix':[]}
853
854 # a znovu začneme počítat
855 # -1 = 'out', 0=success, 1=failure, 2=mix
856 bx.ciss = IS_stat.ISSI([-1,0,1,2])
857
858 elif bx.nsim > bx.nvar:
928 else:
859 929 bx._logger('Triangulace (zatím?) neexistuje') bx._logger('Triangulace (zatím?) neexistuje')
860 930 bx.regen() bx.regen()
861 931
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
881 951 bx._logger(msg="median first!") bx._logger(msg="median first!")
882 952 return bx.LHS_like_correction(bx.h(1)) return bx.LHS_like_correction(bx.h(1))
883 953 else: else:
954 selected = bx.select_candidate()
884 955 # hrubě ošidíme s takovejhlema usilima námi pěčlivě vybraný vzorečiček # hrubě ošidíme s takovejhlema usilima námi pěčlivě vybraný vzorečiček
885 return bx.LHS_like_correction(bx.select_candidate())
956 selected.sampling_plan = bx.LHS_like_correction(selected)
957 return selected
886 958
887 959
888 960
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
917 989 # -1 = 'out', 0=success, 1=failure, 2=mix # -1 = 'out', 0=success, 1=failure, 2=mix
918 990 candidates = candidates[candidates.event != 0] candidates = candidates[candidates.event != 0]
919 991 candidates = candidates[candidates.event != 1] candidates = candidates[candidates.event != 1]
920 if len(candidates) > 0:
921 # uvalíme pokutu
922 bx.assess_candidates(candidates)
923 # uložíme
924 bx.candidates_index[-1].add_sample(candidates[candidates.event == -1] )
992 # uvalíme pokutu
993 bx.assess_candidates(candidates)
994 # uložíme
995 bx.candidates_index[-1].add_sample(candidates[candidates.event == -1] )
996 if len(candidates[candidates.event == 2]) > 0:
925 997 # -2 je určen pro zbytky, кылем-мылем # -2 je určen pro zbytky, кылем-мылем
926 998 bx.candidates_index[-2] = candidates[candidates.event == 2] bx.candidates_index[-2] = candidates[candidates.event == 2]
927 999
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
933 1005 highest_bid = 0 highest_bid = 0
934 1006 for candidates in bx.candidates_index.values(): for candidates in bx.candidates_index.values():
935 1007 bids = getattr(candidates, bx.potencial) bids = getattr(candidates, bx.potencial)
936 bid = max(bids)
1008 bid = np.max(bids)
937 1009 # side effect # side effect
938 1010 if bid > highest_bid: if bid > highest_bid:
939 1011 bidder = candidates[np.argmax(bids)] bidder = candidates[np.argmax(bids)]
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
1010 1082 # -1 = 'out', 0=success, 1=failure, 2=mix # -1 = 'out', 0=success, 1=failure, 2=mix
1011 1083 candidates = candidates[candidates.event != 0] candidates = candidates[candidates.event != 0]
1012 1084 candidates = candidates[candidates.event != 1] candidates = candidates[candidates.event != 1]
1013 if len(candidates) > 0:
1014 # uvalíme pokutu
1015 bx.assess_candidates(candidates)
1016 # uložíme
1017 bx.candidates_index[-1] = candidates[candidates.event == -1]
1085 # uvalíme pokutu
1086 bx.assess_candidates(candidates)
1087 # uložíme
1088 bx.candidates_index[-1] = candidates[candidates.event == -1]
1089 if len(candidates[candidates.event == 2]) > 0:
1018 1090 # -2 je určen pro zbytky, кылем-мылем # -2 je určen pro zbytky, кылем-мылем
1019 1091 bx.candidates_index[-2] = candidates[candidates.event == 2] bx.candidates_index[-2] = candidates[candidates.event == 2]
1020 1092
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
1036 1108 # multiply by simplex_volume, but it looks like it shouldn't be here # multiply by simplex_volume, but it looks like it shouldn't be here
1037 1109 # for simplex: d = nvar+2 # for simplex: d = nvar+2
1038 1110 # sice to má nazev h_plan, ale nese rozdělení a hustoty v f-ku # sice to má nazev h_plan, ale nese rozdělení a hustoty v f-ku
1039 h_plan = IS_like(vertices, sampling_space=bx.sampling_space, nis=bx.simplex_budget, d=bx.nvar+2)
1111 h_plan = IS_stat.IS_like(vertices, sampling_space=bx.sampling_space, nis=bx.simplex_budget, d=bx.nvar+2)
1040 1112
1041 1113 # nejdřív vyfiltrujeme vzorky, pak budeme řešit hustoty # nejdřív vyfiltrujeme vzorky, pak budeme řešit hustoty
1042 1114 # #
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
1063 1135
1064 1136 # fp like a failure points. Number of failure points # fp like a failure points. Number of failure points
1065 1137 # intersect 2 times faster than setdiff (in my tests) # intersect 2 times faster than setdiff (in my tests)
1066 fp = len(np.intersect1d(simplex, sample_box.failure_points, assume_unique=True))
1138 fp = len(np.intersect1d(simplex, bx.sample_box.failure_points, assume_unique=True))
1067 1139 # -1 = 'out', 0=success, 1=failure, 2=mix # -1 = 'out', 0=success, 1=failure, 2=mix
1068 if fp == nvar + 1:
1140 if fp == bx.nvar + 1:
1069 1141 pass pass
1070 1142 #event = 'failure' #event = 'failure'
1071 1143 #event_id = 0 #event_id = 0
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
1123 1195 ksee = np.empty(len(candidates)) ksee = np.empty(len(candidates))
1124 1196 for i in np.unique(ii): for i in np.unique(ii):
1125 1197 # doufám, že je to legální # doufám, že je to legální
1126 ksee[i==ii] = lk.kechato_potential(bx.f_model[i], candidates, kechato_space=bx.kechato_space)
1198 ksee[i==ii] = lk.kechato_potential(bx.f_model[i], candidates[i==ii], kechato_space=bx.kechato_space)
1127 1199 candidates.ksee = ksee candidates.ksee = ksee
1128 1200
1129 1201
 
... ... class MinEnergyCensoredSampling(AdaptiveCensoring):
1142 1214
1143 1215 candidates.simplex = found_simplices candidates.simplex = found_simplices
1144 1216 events = found_simplices.copy() events = found_simplices.copy()
1145 events[found_simplices >= 0] = bx.get_events()[found_simplices[found_simplices >= 0]]
1217 # black magic
1218 # zhruba - get_events() vrací pole s odpovidajícími čísly jevů pro každý simplex, počineje od nuly
1219 # tím slajsingem my jakoby vybirame ke každemu nalezenemu simplexovi ten správnej mu odpovídajicí jev
1220 events[found_simplices >= 0] = bx.simplex_events[found_simplices[found_simplices >= 0]]
1146 1221 candidates.event = events candidates.event = events
1147 1222
1148 1223
File candybox.py changed (mode: 100644) (index e5ef3df..94281ed)
... ... class CandyBox:
80 80 # Houston, we've got a problem... # Houston, we've got a problem...
81 81 # call meaning is different for underlaying f_models and upper Boxes # call meaning is different for underlaying f_models and upper Boxes
82 82 # but SampleBox expect f_model under # but SampleBox expect f_model under
83 return cb.sampling_plan(*args, **kwargs)
83
84 # hovnokód, překopat
85 f = cb.sampling_plan(*args, **kwargs)
86 if len(f) == 0:
87 return CandyBox(f)
88 else:
89 return f
90
91
84 92
85 93
86 94 def __getitem__(cb, slice): def __getitem__(cb, slice):
 
... ... class CandyBox:
96 104
97 105 # chcem jednoduché numpy-like chovaní # chcem jednoduché numpy-like chovaní
98 106 # dělá problémy # dělá problémy
99 #df.reset_index(inplace=True)
107 df.reset_index(drop=True, inplace=True)
100 108 return CandyBox(cb.sampling_plan[slice], df=df) return CandyBox(cb.sampling_plan[slice], df=df)
101 109 # if not # if not
102 110 else: else:
 
... ... class CandyBox:
239 247 # year, we need it # year, we need it
240 248 # мыным выль сэмпл кулэ! # мыным выль сэмпл кулэ!
241 249 def new_sample(cb, input=None, space='R'): def new_sample(cb, input=None, space='R'):
242 # čo to je za vstup?
243 if hasattr(input, 'sampling_plan'): #sweety_input:
244 # if pandas
245 if hasattr(input, 'df'):
246 return CandyBox(cb.sampling_plan.new_sample(input.sampling_plan, space=space), df=input.df)
247
248 # if there is no pandas DataFrame
249 # we suppose there is dictionary in input.kwargs
250 else:
251 return CandyBox(cb.sampling_plan.new_sample(input.sampling_plan, space=space), **input.kwargs)
250 # už je to stavá matoucím
251 # pokud input je, děláme tohle
252 # vrácíme samy sobě
253 if input is None:
254 return CandyBox(cb.sampling_plan())
252 255
253 # nesladký vstup
256 # pokud input není, děláme vonohle
257 # konvertujem vstup na naše rozdělení
254 258 else: else:
255 return cb.sampling_plan.new_sample(input, space)
259 # čo to je za vstup?
260 if hasattr(input, 'sampling_plan'): #sweety_input:
261 # if pandas
262 if hasattr(input, 'df'):
263 return CandyBox(cb.sampling_plan.new_sample(input.sampling_plan, space=space), df=input.df)
264
265 # if there is no pandas DataFrame
266 # we suppose there is dictionary in input.kwargs
267 else:
268 return CandyBox(cb.sampling_plan.new_sample(input.sampling_plan, space=space), **input.kwargs)
269
270 # nesladký vstup
271 else:
272 return cb.sampling_plan.new_sample(input, space)
256 273
257 274
258 275
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