本文整理汇总了Python中ert.util.BoolVector类的典型用法代码示例。如果您正苦于以下问题:Python BoolVector类的具体用法?Python BoolVector怎么用?Python BoolVector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoolVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_bool_vector
def test_bool_vector(self):
b = BoolVector()
b.setDefault(True)
b[4] = False
self.assertEqual(list(b), [True, True, True, True, False])
示例2: test_update_active_mask
def test_update_active_mask(self):
vec = BoolVector(False, 10)
self.assertTrue(BoolVector.updateActiveMask("1-2,5", vec))
self.assertTrue(vec[1])
self.assertTrue(vec[2])
self.assertTrue(vec[5])
self.assertFalse(vec[4])
vec = BoolVector(False, 10)
self.assertTrue(BoolVector.updateActiveMask("1-5,2,3", vec))
self.assertTrue(vec[1])
self.assertTrue(vec[2])
self.assertTrue(vec[3])
self.assertTrue(vec[4])
self.assertTrue(vec[5])
self.assertFalse(vec[0])
self.assertFalse(vec[6])
vec = BoolVector(False, 10)
self.assertTrue(BoolVector.updateActiveMask("5,6,7,15", vec))
self.assertTrue(vec[5])
self.assertTrue(vec[6])
self.assertTrue(vec[7])
self.assertFalse(vec[4])
self.assertFalse(vec[8])
self.assertEqual(len(vec), 16)
示例3: test_it
def test_it(self):
state_size = 10
with ErtTestContext("update" , self.config_file) as tc:
analysis = self.createAnalysisModule()
ert = tc.getErt()
obs = ert.getObservations()
local_obsdata = obs.createLocalObsdata("OBS")
fs = ert.getEnkfFsManager().getCurrentFileSystem()
state = EnkfStateType.FORECAST
mask = BoolVector( initial_size = ert.getEnsembleSize() , default_value = True)
meas_data = MeasData(mask)
obs_data = ObsData()
obs.getObservationAndMeasureData( fs , local_obsdata , state , mask.createActiveList() , meas_data , obs_data )
update( self.rng , mask , analysis , ert , meas_data , obs_data , state_size)
mask[0] = False
mask[4] = False
meas_data = MeasData(mask)
obs_data = ObsData()
obs.getObservationAndMeasureData( fs , local_obsdata , state , mask.createActiveList() , meas_data , obs_data )
update( self.rng , mask , analysis , ert , meas_data , obs_data , state_size)
示例4: test_analysis_module
def test_analysis_module(self):
rng = RandomNumberGenerator( )
module = self.createAnalysisModule()
ens_size = 12
obs_size = 1
state_size = 2
true_params = [1.25 , 0.75]
true_state = forward_model( true_params )
obs = [(measure( true_state ) , 0.75)]
A = Matrix( state_size , ens_size )
ens = []
for iens in range(ens_size):
param = [ random.gauss( 1.00 , 1.00 ) , random.gauss(1.00 , 1.00)]
ens.append( param )
mask = BoolVector(default_value = True , initial_size = ens_size)
mask[2] = False
(A , S , E , D , R , dObs) = init_matrices( ens , mask , obs , rng )
module.initUpdate( mask , S , R , dObs , E , D )
module.updateA( A , S , R , dObs , E , D )
mask[10] = False
mask[5] = False
(A , S , E , D , R , dObs) = init_matrices( ens , mask , obs , rng )
self.assertEqual( S.dims() , (obs_size , mask.countEqual( True )))
self.assertEqual( E.dims() , (obs_size , mask.countEqual( True )))
self.assertEqual( D.dims() , (obs_size , mask.countEqual( True )))
module.initUpdate( mask , S , R , dObs , E , D )
module.updateA( A , S , R , dObs , E , D )
示例5: getActiveRealizationsMask
def getActiveRealizationsMask(self):
count = getRealizationCount()
mask = BoolVector(default_value=False, initial_size = count)
if not mask.updateActiveMask(self.getValue()):
raise ValueError('Error while parsing range string "%s"!' % self.getValue())
if len(mask) != count:
raise ValueError("Mask size changed %d != %d!" % (count, len(mask)))
return mask
示例6: test_activeMask
def test_activeMask(self):
active_list = BoolVector.active_mask("1 , 4 - 7 , 10")
self.assertTrue(len(active_list) == 11)
self.assertTrue(active_list[1])
self.assertTrue(active_list[4])
self.assertTrue(active_list[10])
self.assertFalse(active_list[9])
self.assertFalse(active_list[8])
active_list = BoolVector.active_mask("1,4-7,10X")
self.assertFalse(active_list)
示例7: getActiveRealizationsMask
def getActiveRealizationsMask(self):
mask = BoolVector(False, self.__realization_count)
mask.updateActiveMask(self.getValue(), mask)
# mask = BoolVector.active_mask(self.getValue())
if mask is None:
raise ValueError("Error while parsing range string!")
if len(mask) > self.__realization_count:
raise ValueError("Mask size changed %d != %d!" % (self.__realization_count, len(mask)))
return mask
示例8: test_activeMask
def test_activeMask(self):
active_list = BoolVector.createActiveMask("1 , 4 - 7 , 10")
self.assertTrue(len(active_list) == 11)
self.assertTrue(active_list[1])
self.assertTrue(active_list[4])
self.assertTrue(active_list[10])
self.assertFalse(active_list[9])
self.assertFalse(active_list[8])
self.assertEqual(6, active_list.count(True))
active_list = BoolVector.createActiveMask("1,4-7,10X")
self.assertFalse(active_list)
示例9: createActiveList
def createActiveList(ert, fs):
state_map = fs.getStateMap()
ens_mask = BoolVector(False, ert.getEnsembleSize())
state_map.selectMatching(ens_mask, RealizationStateEnum.STATE_HAS_DATA)
active_list = BoolVector.createActiveList(ens_mask)
return [iens for iens in active_list]
示例10: load
def load(self, fs, report_step, input_mask=None):
"""
@type fs: EnkfFs
@type report_step: int
@type input_mask: BoolVector
@rtype: PlotBlockData
"""
state_map = fs.getStateMap()
ensemble_size = len(state_map)
if not input_mask is None:
mask = BoolVector.copy(input_mask)
else:
mask = BoolVector(False, ensemble_size)
state_map.selectMatching(mask, RealizationStateEnum.STATE_HAS_DATA)
depth = self.getDepthValues(report_step)
self.__permutation_vector = depth.permutationSort()
depth.permute(self.__permutation_vector)
plot_block_data = PlotBlockData(depth)
thread_pool = ThreadPool()
for index in range(ensemble_size):
if mask[index]:
thread_pool.addTask(self.loadVector, plot_block_data, fs, report_step, index)
thread_pool.nonBlockingStart()
thread_pool.join()
return plot_block_data
示例11: load
def load(self, args):
arguments = splitArguments(args)
if len(arguments) < 1:
self.lastCommandFailed("Loading requires a realization mask.")
return False
realization_count = self.ert().getEnsembleSize()
mask = BoolVector(False, realization_count)
mask_success = mask.updateActiveMask(arguments[0])
if not mask_success:
self.lastCommandFailed("The realization mask: '%s' is not valid." % arguments[0])
return False
fs = self.ert().getEnkfFsManager().getCurrentFileSystem()
self.ert().loadFromForwardModel(mask, 0, fs)
示例12: realizationList
def realizationList(self , state_value):
"""
Will create a list of all realisations with state equal to state_value.
@type state_value: RealizationStateEnum
@rtype: ert.util.IntVector
"""
mask = BoolVector(False, len(self))
self.selectMatching(mask, state_value)
return BoolVector.createActiveList(mask)
示例13: initializeCurrentCaseFromExisting
def initializeCurrentCaseFromExisting(source_case, target_case, source_report_step, parameters, members):
if caseExists(source_case) and caseIsInitialized(source_case) and caseExists(target_case):
total_member_count = getRealizationCount()
member_mask = BoolVector.createFromList(total_member_count, members)
selected_parameters = StringList(parameters)
ERT.ert.getEnkfFsManager().customInitializeCurrentFromExistingCase(source_case, source_report_step, member_mask,
selected_parameters)
ERT.emitErtChange()
示例14: buttonTriggered
def buttonTriggered(self):
source_case = InitializedCaseSelectorModel().getCurrentChoice()
source_report_step = HistoryLengthModel().getSpinnerValue()
selected_members = InitializationMembersModel().getSelectedItems()
total_member_count = EnsembleSizeModel().getSpinnerValue()
member_mask = BoolVector.createFromList(total_member_count, selected_members)
selected_parameters = StringList((InitializationParametersModel()).getSelectedItems())
self.ert().getEnkfFsManager().customInitializeCurrentFromExistingCase(source_case, source_report_step, member_mask, selected_parameters)
self.observable().notify(ButtonModelMixin.BUTTON_TRIGGERED_EVENT)
示例15: getActiveRealizationsMask
def getActiveRealizationsMask(self):
count = EnsembleSizeModel().getValue()
mask = BoolVector.active_mask(self.getValue())
if mask is None:
raise ValueError("Error while parsing range string!")
if len(mask) > count:
raise ValueError("Mask size changed %d != %d!" % (count, len(mask)))
return mask