本文整理汇总了Python中numpy.ma.allequal函数的典型用法代码示例。如果您正苦于以下问题:Python allequal函数的具体用法?Python allequal怎么用?Python allequal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了allequal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ematch
def test_ematch(self):
from numpy import array, ma
self.assertEqual(ma.allequal(ematch(array(["abcde", "abcd"]), "abcd"), array([1])), True,
msg = "Error in ematch.")
self.assertEqual(ma.allequal(ematch(array(["ab(c]de", "abcd"]), "ab(c]de"), array([0])), True,
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:6,代码来源:misc.py
示例2: test_transformation
def test_transformation(self):
from numpy import array, ma
a = array([9, 4, 25, 36])
self.assertEqual(ma.allequal(try_transformation(a, "sqrt"), array([3, 2, 5, 6])), True)
self.assertEqual(ma.allequal(try_transformation(a, "*2"), array([18, 8, 50, 72])), True)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:6,代码来源:misc.py
示例3: test_quantile
def test_quantile(self):
from numpy import array, ma
a = array([35, 6, 22, 1, 60])
b = array([6, 3, 5, 9, 1, 7, 10, 2, 8, 4, 0])
self.assertEqual(ma.allequal(quantile(a, array([0.2, 0.9, 0.5])), array([1, 35, 6])), True)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:6,代码来源:misc.py
示例4: test_agent_times_choice
def test_agent_times_choice(self):
expression = 'agent_x_choice.agent_times_choice(attr)'
storage = StorageFactory().get_storage('dict_storage')
storage.write_table(table_name='agents',
table_data={'id': array([1, 2, 3, 4, 5]), 'attr_2': array([3, 2, 4, 10, 20]),
'attr_3': array([10, 100, 1000, 500, 0]),
'attr_4': array([100, 500, 0, 20, -30])
}
)
storage.write_table(table_name='choices',
table_data={'id': array([1, 2, 3, 4])}
)
agents = Dataset(in_storage=storage, in_table_name='agents', dataset_name='agent', id_name='id')
choices = Dataset(in_storage=storage, in_table_name='choices', dataset_name='choice', id_name='id')
ids = InteractionDataset(dataset1=agents, dataset2=choices, index1=array([0,1,3,4]), index2=array([1,2,3]))
result = ids.compute_variables(expression)
should_be = array([[3, 10, 100], [2,100,500], [10,500, 20], [20, 0, -30]])
self.assertEqual(ma.allequal(result, should_be), True)
agents.touch_attribute('attr_2') # in order to recompute the expression
choices.add_primary_attribute(name='name', data=array(['bus', 'car', 'tran', 'walk']))
agents.add_primary_attribute(name='attr_tran', data=array([100, 1000, 10000, 5000,10]))
result = ids.compute_variables(expression)
should_be = array([[3, 100, 100], [2,1000,500], [10,5000, 20], [20, 10, -30]])
self.assertEqual(ma.allequal(result, should_be), True)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:25,代码来源:interaction_sets.py
示例5: test_add_nothing
def test_add_nothing(self):
projects = None
m = AddProjectsToBuildings()
m.run(projects, self.buildings)
self.assertEqual(ma.allequal(self.buildings.get_attribute("residential_units"), array(10*[200, 0, 0])), True)
self.assertEqual(ma.allequal(self.buildings.get_attribute("commercial_job_spaces"), array(10*[0, 100, 0])), True)
self.assertEqual(ma.allequal(self.buildings.get_attribute("industrial_job_spaces"), array(10*[0, 0, 100])), True)
开发者ID:psrc,项目名称:urbansim,代码行数:7,代码来源:add_projects_to_buildings.py
示例6: _check_dataset_methods_on_dataset_view
def _check_dataset_methods_on_dataset_view(self, ds, years_to_merge):
self.assert_(ds is not None)
ds.load_dataset(attributes='*',
in_table_name='tests',
in_storage=AttributeCache()
)
id = ds.get_attribute('id')
attr1 = ds.get_attribute('attr1')
# Does compute_variables work?
ds.compute_variables(['opus_core.test.attr1_times_2'])
attr1_times_2 = ds.get_attribute('attr1_times_2')
# Are values as expected?
self.assert_(ma.allequal(attr1*2, attr1_times_2))
# Does results have expected number of elements?
self.assertEqual(len(years_to_merge)*3, len(attr1_times_2))
# Does _compute_if_needed work?
ds._compute_if_needed(
'opus_core.test.attr2_times_2',
dataset_pool=SessionConfiguration().get_dataset_pool()
)
attr2_times_2 = ds.get_attribute('attr2_times_2')
attr2 = ds.get_attribute('attr2')
self.assert_(ma.allequal(attr2*2, attr2_times_2))
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:27,代码来源:multiple_year_dataset_view.py
示例7: test_change_three_elements
def test_change_three_elements(self):
"""3 values are in common - change them to -1. Other attributes stay unchanged."""
data = {
'my_id': array([1,2,3,4,5]),
'attr': array([10,2,3,50,2]),
'attr2': array([4,3,2,5,3])
}
data2 = {
'attr': array([2,6,7,3])
}
storage = StorageFactory().get_storage('dict_storage')
storage.write_table(table_name='dataset', table_data=data)
dataset = Dataset(in_storage = storage,
in_table_name='dataset',
id_name='my_id'
)
storage.write_table(table_name='dataset2', table_data=data2)
dataset2 = Dataset(in_storage = storage,
in_table_name='dataset2',
id_name='attr'
)
JoinAttributeModificationModel().run(dataset,dataset2, value=-1)
self.assertEqual(ma.allequal(dataset.get_attribute('attr'), array([10,-1,-1,50,-1])), True)
self.assertEqual(ma.allequal(dataset.get_attribute('attr2'), data['attr2']), True)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:25,代码来源:join_attribute_modification_model.py
示例8: test_agent_times_choice
def test_agent_times_choice(self):
expression = "agent_x_choice.agent_times_choice(attr)"
storage = StorageFactory().get_storage("dict_storage")
storage.write_table(
table_name="agents",
table_data={
"id": array([1, 2, 3, 4, 5]),
"attr_2": array([3, 2, 4, 10, 20]),
"attr_3": array([10, 100, 1000, 500, 0]),
"attr_4": array([100, 500, 0, 20, -30]),
},
)
storage.write_table(table_name="choices", table_data={"id": array([1, 2, 3, 4])})
agents = Dataset(in_storage=storage, in_table_name="agents", dataset_name="agent", id_name="id")
choices = Dataset(in_storage=storage, in_table_name="choices", dataset_name="choice", id_name="id")
ids = InteractionDataset(dataset1=agents, dataset2=choices, index1=array([0, 1, 3, 4]), index2=array([1, 2, 3]))
result = ids.compute_variables(expression)
should_be = array([[3, 10, 100], [2, 100, 500], [10, 500, 20], [20, 0, -30]])
self.assertEqual(ma.allequal(result, should_be), True)
agents.touch_attribute("attr_2") # in order to recompute the expression
choices.add_primary_attribute(name="name", data=array(["bus", "car", "tran", "walk"]))
agents.add_primary_attribute(name="attr_tran", data=array([100, 1000, 10000, 5000, 10]))
result = ids.compute_variables(expression)
should_be = array([[3, 100, 100], [2, 1000, 500], [10, 5000, 20], [20, 10, -30]])
self.assertEqual(ma.allequal(result, should_be), True)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:26,代码来源:interaction_sets.py
示例9: test_join_datasets_with_2_ids
def test_join_datasets_with_2_ids(self):
from numpy import ma
storage = StorageFactory().get_storage('dict_storage')
storage.write_table(
table_name='data1',
table_data={
'id1':array([2,4,2]),
'id2':array([1,2,3]),
'attr1':array([4,7,1]),
'attr2':array([100,0,1000]),
}
)
storage.write_table(
table_name='data2',
table_data={
'id1':array([4,2,2]),
'id2':array([2,3,1]),
'attr1':array([50,60,70])
}
)
ds1 = Dataset(in_storage=storage, in_table_name='data1', id_name=['id1', 'id2'], dataset_name='data1')
ds2 = Dataset(in_storage=storage, in_table_name='data2', id_name=['id1', 'id2'], dataset_name='data2')
ds1.join(ds2, 'attr1')
self.assertEqual(ma.allequal(ds1.get_attribute('attr1'), array([70,50,60])), True)
self.assertEqual(ma.allequal(ds1.get_attribute('attr2'), array([100,0,1000])), True)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:27,代码来源:test_dataset.py
示例10: test_ZonalMaximum_exec
def test_ZonalMaximum_exec(self):
lo=ZonalMaximum_exec(self.l12,self.l13)
res=np.asarray([[5,5,5,6],[6,6,3,3],[3,7,7,7],[9,9,7,9]])
self.assertTrue(allequal(lo._data,res))
lo=ZonalMaximum_exec(self.l14,self.l13)
res=np.asarray([[-1,-1,-1,-2],[-2,-2,-1,-1],[-1,-1,-1,-1],[-1,-1,-1,-1]])
self.assertTrue(allequal(lo._data,res))
开发者ID:KevinWhalen,项目名称:pcml,代码行数:7,代码来源:test_layer_ZonalOperations.py
示例11: test_focalmean_np_exec
def test_focalmean_np_exec(self):
lo = FocalMean_np_exec(self.l1, buffersize=1)
res = np.asarray([[1]*4]*4)
self.assertTrue(allequal(lo._data, res))
lo = FocalMean_np_exec(self.l2, buffersize=3,decomposition=columndecomposition)
res = np.asarray([[2]*4]*4)
self.assertTrue(allequal(lo._data, res))
开发者ID:HPCGISLab,项目名称:pcml,代码行数:7,代码来源:test_layer_FocalOperations.py
示例12: test_focalmaximum
def test_focalmaximum(self):
lo = FocalMaximum(self.l1,self.l2, buffersize=0)
self.assertTrue(allequal(lo._data, self.l2._data))
lo = FocalMaximum(self.l1,self.l2, buffersize=2)
self.assertTrue(allequal(lo._data, self.l2._data))
lo = FocalMaximum(self.l1,self.l2, buffersize=2,decomposition=columndecomposition)
self.assertTrue(allequal(lo._data, self.l2._data))
开发者ID:HPCGISLab,项目名称:pcml,代码行数:7,代码来源:test_layer_FocalOperations.py
示例13: test_load_specification
def test_load_specification(self):
specification = {1: [
("urbansim.gridcell.population", "BPOP"),
("urbansim.gridcell.average_income", "BINC"),
],
2: [
("urbansim.gridcell.is_near_arterial", "BART"),
("urbansim.gridcell.is_near_highway", "BHWY"),
],
3: [
("lage = ln(urbansim.gridcell.average_age+1)", "BAGE")
]
}
result = load_specification_from_dictionary(specification)
vars = result.get_variable_names()
coefs = result.get_coefficient_names()
subm = result.get_submodels()
fixedval = result.get_fixed_values()
self.assert_(alltrue(coefs == array(["BPOP", "BINC", "BART", "BHWY", "BAGE"])),
msg = "Error in test_load_specification (coefficients)")
self.assert_(alltrue(vars ==
array(["population", "average_income", "is_near_arterial", "is_near_highway", "lage"])),
msg = "Error in test_load_specification (variables)")
self.assert_(ma.allequal(subm, array([1, 1, 2, 2, 3])),
msg = "Error in test_load_specification (submodels)")
self.assert_(fixedval.size == 0, msg = "Error in test_load_specification (fixed_values should be empty)")
# add a variable with a fixed value coefficient
specification[3].append(("constant", "C", 1))
result = load_specification_from_dictionary(specification)
fixedval = result.get_fixed_values()
self.assert_(ma.allequal(fixedval, array([0, 0, 0, 0, 0, 1])),
msg = "Error in test_load_specification (fixed_values)")
开发者ID:janowicz,项目名称:urbansim_drcog,代码行数:33,代码来源:equation_specification.py
示例14: test_simple_lag_variable
def test_simple_lag_variable(self):
test_data = {
1000:{
'tests':{
'id':array([1,2,3]),
'attr1':array([10,20,30]),
},
},
1001:{
'tests':{
'id':array([1,2,3]),
'attr1':array([111,222,333]),
},
},
}
cache_creator = CreateTestAttributeCache()
cache_creator.create_attribute_cache_with_data(self._temp_dir, test_data)
SimulationState().set_current_time(1001)
attribute_cache = AttributeCache()
SessionConfiguration(new_instance=True,
package_order=['opus_core'],
in_storage=attribute_cache)
ds = Dataset(in_storage = attribute_cache,
in_table_name = 'tests',
id_name = ['id'],
dataset_name = 'tests')
ds.compute_variables(['opus_core.tests.attr1'])
self.assert_(ma.allequal(ds.get_attribute('attr1'), array([111,222,333])))
ds.compute_variables(['opus_core.tests.attr1_lag1'])
self.assert_(ma.allequal(ds.get_attribute('attr1_lag1'), array([10,20,30])))
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:35,代码来源:lag_variable.py
示例15: test
def test(self):
opus_core_path = OpusPackage().get_opus_core_path()
dbf_directory = os.path.join(
opus_core_path, 'tests', 'data', 'dbf')
table_name = 'test_logical'
cache_directory = self._temp_dir
year = 1000
exporter = ExportDbfTableToCacheCommand(
dbf_directory = dbf_directory,
table_name = table_name,
cache_directory = cache_directory,
year = year,
)
exporter.execute()
attribute_cache = AttributeCache(cache_directory=cache_directory)
old_time = SimulationState().get_current_time()
SimulationState().set_current_time(year)
values = attribute_cache.load_table(table_name)
self.assertEqual(set(['keyid', 'works']), set(values.keys()))
self.assert_(ma.allequal(array([1,2,3,4,5]), values['keyid']))
self.assert_(ma.allequal(array([1,1,-1,0,0]), values['works']))
SimulationState().set_current_time(old_time)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:28,代码来源:export_dbf_table_to_cache_command.py
示例16: test_load_specification_with_definition_nest_and_equations
def test_load_specification_with_definition_nest_and_equations(self):
specification = {
"_definition_": [
("pop = urbansim.gridcell.population", "bpop"),
"inc = urbansim.gridcell.average_income",
"art = urbansim.gridcell.is_near_arterial",
],
-2: {
'name': 'nest_id',
1: {1: [
"pop",
"inc",
"constant" ],
2: [ "art"]
},
2: {3:["pop",
"inc"
]}
}
}
result = load_specification_from_dictionary(specification)
vars = result.get_variable_names()
coefs = result.get_coefficient_names()
eqs = result.get_equations()
other = result.get_other_fields()
self.assert_(alltrue(coefs == array(["bpop", "inc", "constant", "art", "bpop", "inc"])),
msg = "Error in test_load_specification_with_definition_nest_and_equations (coefficients)")
self.assert_(alltrue(vars == array(["pop", "inc", "constant", "art", "pop", "inc"])),
msg = "Error in test_load_specification_with_definition_nest_and_equations (variables)")
self.assert_(ma.allequal(eqs, array([1,1,1,2,3,3])),
msg = "Error in test_load_specification_with_definition_nest_and_equations (equations)")
self.assert_(ma.allequal(other['dim_nest_id'], array([1,1,1,1,2,2])),
msg = "Error in test_load_specification_with_definition_nest_and_equations (nests)")
开发者ID:janowicz,项目名称:urbansim_drcog,代码行数:34,代码来源:equation_specification.py
示例17: test_ZonalMinimum_exec
def test_ZonalMinimum_exec(self):
lo=ZonalMinimum_exec(self.l12,self.l13)
res=np.asarray([[1,1,1,2],[2,2,1,1],[1,1,1,1],[1,1,1,1]])
self.assertTrue(allequal(lo._data,res))
lo=ZonalMinimum_exec(self.l14,self.l13)
res=np.asarray([[-5,-5,-5,-6],[-6,-6,-3,-3],[-3,-7,-7,-7],[-9,-9,-7,-9]])
self.assertTrue(allequal(lo._data,res))
开发者ID:KevinWhalen,项目名称:pcml,代码行数:7,代码来源:test_layer_ZonalOperations.py
示例18: test_focalsum
def test_focalsum(self):
lo = FocalSum(self.l1, buffersize=1)
res = np.asarray([[4,6,6,4],[6,9,9,6],[6,9,9,6],[4,6,6,4]])
self.assertTrue(allequal(lo._data, res))
lo = FocalSum(self.l1, buffersize=2)
res = np.asarray([[9,12,12,9],[12,16,16,12],[12,16,16,12],[9,12,12,9]])
self.assertTrue(allequal(lo._data, res))
开发者ID:HPCGISLab,项目名称:pcml,代码行数:7,代码来源:test_layer_FocalOperations.py
示例19: test_ZonalMean_exec
def test_ZonalMean_exec(self):
lo=ZonalMean_exec(self.l12,self.l13)
res=np.asarray([[3,3,3,4],[4,4,2,2],[2,5,5,5],[6,6,5,6]])
self.assertTrue(allequal(lo._data,res))
lo=ZonalMean_exec(self.l14,self.l13)
res=np.asarray([[-3,-3,-3,-4],[-4,-4,-2,-2],[-2,-5,-5,-5],[-6,-6,-5,-6]])
self.assertTrue(allequal(lo._data,res))
开发者ID:KevinWhalen,项目名称:pcml,代码行数:7,代码来源:test_layer_ZonalOperations.py
示例20: test_create
def test_create(self):
proposals = self.dataset_pool.get_dataset("development_project_proposal")
where_valid_units = where(proposals.get_attribute("units_proposed") > 0)[0]
self.assert_(ma.allequal(self.dataset.get_id_attribute(), proposals.get_id_attribute()[where_valid_units]))
self.assert_(ma.allequal(self.dataset.get_attribute("parcel_id"),
proposals.get_attribute("parcel_id")[where_valid_units]))
self.assert_(ma.allequal(self.dataset.get_attribute("template_id"),
proposals.get_attribute("template_id")[where_valid_units]))
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:8,代码来源:development_project_proposal_dataset.py
注:本文中的numpy.ma.allequal函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论