本文整理汇总了Python中tests.utils.helpers.get_output_path函数的典型用法代码示例。如果您正苦于以下问题:Python get_output_path函数的具体用法?Python get_output_path怎么用?Python get_output_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_output_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_writes_the_config_only_once
def test_writes_the_config_only_once(self):
data = [(shapes.Site(-122.5000, 37.5000),
{"IDmodel": "MMI_3_1",
"investigationTimeSpan": 50.0,
"endBranchLabel": "3_1",
"IMLValues": [5.0, 6.0, 7.0],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [0.1, 0.2, 0.3]}),
(shapes.Site(-122.4000, 37.5000),
{"IDmodel": "MMI_3_1",
"investigationTimeSpan": 50.0,
"endBranchLabel": "3_2",
"IMLValues": [5.0, 6.0, 7.0],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [0.4, 0.5, 0.6]})]
path = helpers.get_output_path(TEST_FILE_CONFIG_ONCE)
self._initialize_writer(path)
self.writer.serialize(data)
self.assertTrue(xml.validates_against_xml_schema(path))
示例2: _test_hazard_map_relative_scaling
def _test_hazard_map_relative_scaling(region, hm_data):
path = helpers.get_output_path(
'TEST_HAZARD_MAP_relative_scaling.tiff')
# expected colors for each pixel in the map:
exp_red_vals = numpy.array([
[49, 186, 255, 138, 186, 24],
[0, 208, 67, 0, 255, 24],
[143, 255, 123, 186, 143, 0],
[186, 0, 255, 186, 238, 143],
[255, 186, 0, 186, 12, 205],
[255, 143, 208, 238, 97, 0]])
exp_green_vals = numpy.array([
[190, 197, 255, 236, 197, 175],
[39, 216, 202, 39, 255, 175],
[161, 255, 235, 197, 161, 39],
[197, 39, 255, 197, 79, 161],
[255, 197, 39, 197, 129, 255],
[255, 161, 216, 79, 122, 39]])
exp_blue_vals = numpy.array([
[255, 247, 255, 174, 247, 255],
[224, 251, 255, 224, 255, 255],
[241, 255, 200, 247, 241, 224],
[247, 224, 255, 247, 77, 241],
[255, 247, 224, 247, 248, 162],
[255, 241, 251, 77, 236, 224]])
hm_writer = geotiff.HazardMapGeoTiffFile(
path, small_region.grid, html_wrapper=True)
hm_writer.serialize(hm_data)
self._assert_image_rgb_is_correct(
path, exp_red_vals, exp_green_vals, exp_blue_vals)
示例3: test_loss_serialization_with_inconsistent_site_fails
def test_loss_serialization_with_inconsistent_site_fails(self):
"""Assert that serialization of illegal loss curve data
raises error."""
xml_writer = risk_output.LossCurveXMLWriter(
helpers.get_output_path(LOSS_XML_FAIL_OUTPUT_FILE))
self.assertRaises(ValueError, xml_writer.serialize,
self.loss_curves_fail)
示例4: test_writes_a_single_result
def test_writes_a_single_result(self):
data = [(shapes.Site(-122.5000, 37.5000),
{"IDmodel": "MMI_3_1",
"investigationTimeSpan": 50.0,
"endBranchLabel": "3_1",
"IMLValues": [5.0000e-03, 7.0000e-03, 1.3700e-02,
1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01,
2.0300e-01, 2.8400e-01, 3.9700e-01, 5.5600e-01,
7.7800e-01, 1.0900e+00, 1.5200e+00, 2.1300e+00],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [9.8728e-01, 9.8266e-01, 9.4957e-01,
9.0326e-01, 8.1956e-01, 6.9192e-01, 5.2866e-01,
3.6143e-01, 2.4231e-01, 2.2452e-01, 1.2831e-01,
7.0352e-02, 3.6060e-02, 1.6579e-02, 6.4213e-03,
2.0244e-03, 4.8605e-04, 8.1752e-05, 7.3425e-06]})]
path = helpers.get_output_path(TEST_FILE_SINGLE_RESULT)
self._initialize_writer(path)
self.writer.serialize(data)
self.assertTrue(xml.validates_against_xml_schema(path))
self.assertTrue(XML_METADATA in self._result_as_string(path))
self.read_curves = self._read_curves(
(-123.0, 38.0), (-122.0, 35.0),
TEST_FILE_SINGLE_RESULT)
self._assert_number_of_curves_is(1)
self._assert_curves_are(data)
示例5: _read_curves
def _read_curves(self, upper_left_cor, lower_right_cor, test_file):
constraint = shapes.RegionConstraint.from_simple(
upper_left_cor, lower_right_cor)
reader = hazard_parser.NrmlFile(
helpers.get_output_path(test_file))
return reader.filter(constraint)
示例6: test_geotiff_generation_and_metadata_validation
def test_geotiff_generation_and_metadata_validation(self):
"""Create a GeoTIFF, and check if it has the correct metadata."""
path = helpers.get_output_path(GEOTIFF_FILENAME_WITHOUT_NUMBER)
smallregion = shapes.Region.from_coordinates(TEST_REGION_SMALL)
gwriter = geotiff.LossMapGeoTiffFile(
path, smallregion.grid, normalize=False)
gwriter.close()
self._assert_geotiff_metadata_is_correct(path, smallregion)
示例7: setUp
def setUp(self):
self.loss_curve_path = helpers.get_output_path(LOSS_XML_OUTPUT_FILE)
self.loss_ratio_curve_path = helpers.get_output_path(
LOSS_RATIO_XML_OUTPUT_FILE)
self.single_loss_curve_path = helpers.get_output_path(
SINGLE_LOSS_XML_OUTPUT_FILE)
self.single_loss_ratio_curve_path = helpers.get_output_path(
SINGLE_LOSS_RATIO_XML_OUTPUT_FILE)
self.schema_path = NRML_SCHEMA_PATH
# Build up some sample loss/loss ratio curves here
first_site = shapes.Site(-117.0, 38.0)
second_site = shapes.Site(-118.0, 39.0)
first_asset_a = {"assetID": "a1711", "endBranchLabel": "A"}
first_asset_b = {"assetID": "a1711", "endBranchLabel": "B"}
second_asset_a = {"assetID": "a1712", "endBranchLabel": "A"}
second_asset_b = {"assetID": "a1712", "endBranchLabel": "B"}
self.loss_curves = [
(first_site, (TEST_LOSS_CURVE, first_asset_a)),
(first_site, (TEST_LOSS_CURVE, first_asset_b)),
(second_site, (TEST_LOSS_CURVE, second_asset_a)),
(second_site, (TEST_LOSS_CURVE, second_asset_b))]
self.loss_ratio_curves = [
(first_site, (TEST_LOSS_RATIO_CURVE, first_asset_a)),
(first_site, (TEST_LOSS_RATIO_CURVE, first_asset_b)),
(second_site, (TEST_LOSS_RATIO_CURVE, second_asset_a)),
(second_site, (TEST_LOSS_RATIO_CURVE, second_asset_b))]
self.single_loss_curve = [
(first_site, (TEST_LOSS_CURVE, first_asset_a))]
self.single_loss_ratio_curve = [
(first_site, (TEST_LOSS_RATIO_CURVE, first_asset_a))]
# loss curve that fails with inconsistent sites for an asset
self.loss_curves_fail = [
(first_site, (TEST_LOSS_CURVE, first_asset_a)),
(second_site, (TEST_LOSS_CURVE, first_asset_a))]
示例8: test_lossmap_geotiff_generation_with_number_in_filename
def test_lossmap_geotiff_generation_with_number_in_filename(self):
"""Create a GeoTIFF with a number in its filename. This
test has been written because it has been reported that numbers in the
filename do not work."""
path = helpers.get_output_path(GEOTIFF_FILENAME_WITH_NUMBER)
smallregion = shapes.Region.from_coordinates(TEST_REGION_SMALL)
gwriter = geotiff.LossMapGeoTiffFile(
path, smallregion.grid, normalize=False)
gwriter.close()
self._assert_geotiff_metadata_is_correct(path, smallregion)
示例9: test_serializes_gmf
def test_serializes_gmf(self):
path = helpers.get_output_path(GMF_NORUPTURE_TEST_FILE)
writer = hazard_output.GMFXMLWriter(path)
writer.serialize(GMF_NORUPTURE_TEST_DATA)
check_data = {}
reader = hazard_parser.GMFReader(path)
for curr_site, curr_attribute in reader:
check_data[curr_site] = curr_attribute
self.assertEqual(check_data, GMF_NORUPTURE_TEST_DATA)
示例10: test_writes_multiple_results_with_statistics
def test_writes_multiple_results_with_statistics(self):
data = [(shapes.Site(-122.5000, 37.5000),
{"nrml_id": "nrml_instance_1",
"hazres_id": "hazard_result_0001",
"hcfield_id": "hazard_field_one",
"hcnode_id": "the_hazard_node_1000",
"IDmodel": "foo",
"investigationTimeSpan": 50.0,
"statistics": "quantile",
"quantileValue": "0.5",
"IMLValues": [5.0000e-03, 7.0000e-03, 1.3700e-02,
1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01,
2.0300e-01, 2.8400e-01, 3.9700e-01, 5.5600e-01,
7.7800e-01, 1.0900e+00, 1.5200e+00, 2.1300e+00],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [9.8728e-01, 9.8266e-01, 9.4957e-01,
9.0326e-01, 8.1956e-01, 6.9192e-01, 5.2866e-01,
3.6143e-01, 2.4231e-01, 2.2452e-01, 1.2831e-01,
7.0352e-02, 3.6060e-02, 1.6579e-02, 6.4213e-03,
2.0244e-03, 4.8605e-04, 8.1752e-05, 7.3425e-06]}),
(shapes.Site(-122.4000, 37.5000),
{"IDmodel": "foo",
"investigationTimeSpan": 50.0,
"statistics": "quantile",
"quantileValue": "0.5",
"IMLValues": [5.0000e-03, 7.0000e-03, 1.3700e-02,
1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01,
2.0300e-01, 2.8400e-01, 3.9700e-01, 5.5600e-01,
7.7800e-01, 1.0900e+00, 1.5200e+00, 2.1300e+00],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [9.8784e-01, 9.8405e-01, 9.5719e-01,
9.1955e-01, 8.5019e-01, 7.4038e-01, 5.9153e-01,
4.2626e-01, 2.9755e-01, 2.7731e-01, 1.6218e-01,
8.8035e-02, 4.3499e-02, 1.9065e-02, 7.0442e-03,
2.1300e-03, 4.9498e-04, 8.1768e-05, 7.3425e-06]})]
path = helpers.get_output_path(TEST_FILE_STATISTICS)
self._initialize_writer(path)
self.writer.serialize(data)
self._is_xml_valid(path)
self.readed_curves = self._read_curves(
(-123.0, 38.0), (-120.0, 35.0),
TEST_FILE_STATISTICS)
self._assert_number_of_curves_is(2)
self._assert_curves_are(data)
示例11: test_geotiff_generation_colorscale
def test_geotiff_generation_colorscale(self):
"""Check RGB geotiff generation with colorscale for GMF."""
path = helpers.get_output_path(GEOTIFF_FILENAME_COLORSCALE)
asymmetric_region = shapes.Region.from_coordinates(
TEST_REGION_LARGE_ASYMMETRIC)
gwriter = geotiff.GMFGeoTiffFile(path, asymmetric_region.grid,
discrete=False)
reference_raster = numpy.zeros((asymmetric_region.grid.rows,
asymmetric_region.grid.columns),
dtype=numpy.float)
self._fill_rasters(asymmetric_region, gwriter, reference_raster,
self._colorscale_fill)
gwriter.close()
示例12: setUp
def setUp(self):
self.loss_curve_path = helpers.get_output_path(LOSS_XML_OUTPUT_FILE)
self.loss_ratio_curve_path = helpers.get_output_path(
LOSS_RATIO_XML_OUTPUT_FILE)
self.single_loss_curve_path = helpers.get_output_path(
SINGLE_LOSS_XML_OUTPUT_FILE)
self.single_loss_ratio_curve_path = helpers.get_output_path(
SINGLE_LOSS_RATIO_XML_OUTPUT_FILE)
self.schema_path = NRML_SCHEMA_PATH
# Build up some sample loss/loss ratio curves here
first_site = shapes.Site(-117.0, 38.0)
second_site = shapes.Site(-118.0, 39.0)
first_asset = models.ExposureData(asset_ref='a1711')
second_asset = models.ExposureData(asset_ref='a1712')
self.loss_curves = [
(first_site, (TEST_LOSS_CURVE, first_asset)),
(second_site, (TEST_LOSS_CURVE, second_asset))]
self.loss_ratio_curves = [
(first_site, (TEST_LOSS_RATIO_CURVE, first_asset)),
(second_site, (TEST_LOSS_RATIO_CURVE, second_asset))]
self.single_loss_curve = [
(first_site, (TEST_LOSS_CURVE, first_asset))]
self.single_loss_ratio_curve = [
(first_site, (TEST_LOSS_RATIO_CURVE, first_asset))]
# loss curve that fails with inconsistent sites for an asset
self.loss_curves_fail = [
(first_site, (TEST_LOSS_CURVE, first_asset)),
(second_site, (TEST_LOSS_CURVE, first_asset))]
示例13: test_writes_multiple_results_with_one_branch_level
def test_writes_multiple_results_with_one_branch_level(self):
data = [(shapes.Site(-122.5000, 37.5000),
{"IDmodel": "MMI_3_1",
"investigationTimeSpan": 50.0,
"endBranchLabel": "3_1",
"IMLValues": [5.0000e-03, 7.0000e-03, 1.3700e-02,
1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01,
2.0300e-01, 2.8400e-01, 3.9700e-01, 5.5600e-01,
7.7800e-01, 1.0900e+00, 1.5200e+00, 2.1300e+00],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [9.8728e-01, 9.8266e-01, 9.4957e-01,
9.0326e-01, 8.1956e-01, 6.9192e-01, 5.2866e-01,
3.6143e-01, 2.4231e-01, 2.2452e-01, 1.2831e-01,
7.0352e-02, 3.6060e-02, 1.6579e-02, 6.4213e-03,
2.0244e-03, 4.8605e-04, 8.1752e-05, 7.3425e-06]}),
(shapes.Site(-122.4000, 37.5000),
{"IDmodel": "MMI_3_1",
"investigationTimeSpan": 50.0,
"endBranchLabel": "3_1",
"IMLValues": [5.0000e-03, 7.0000e-03, 1.3700e-02,
1.9200e-02, 2.6900e-02, 3.7600e-02, 5.2700e-02,
7.3800e-02, 9.8000e-02, 1.0300e-01, 1.4500e-01,
2.0300e-01, 2.8400e-01, 3.9700e-01, 5.5600e-01,
7.7800e-01, 1.0900e+00, 1.5200e+00, 2.1300e+00],
"saPeriod": 0.1,
"saDamping": 1.0,
"IMT": "PGA",
"PoEValues": [9.8784e-01, 9.8405e-01, 9.5719e-01,
9.1955e-01, 8.5019e-01, 7.4038e-01, 5.9153e-01,
4.2626e-01, 2.9755e-01, 2.7731e-01, 1.6218e-01,
8.8035e-02, 4.3499e-02, 1.9065e-02, 7.0442e-03,
2.1300e-03, 4.9498e-04, 8.1768e-05, 7.3425e-06]})]
path = helpers.get_output_path(TEST_FILE_MULTIPLE_ONE_BRANCH)
self._initialize_writer(path)
self.writer.serialize(data)
self.assertTrue(xml.validates_against_xml_schema(path))
self.read_curves = self._read_curves(
(-123.0, 38.0), (-120.0, 35.0),
TEST_FILE_MULTIPLE_ONE_BRANCH)
self._assert_number_of_curves_is(2)
self._assert_curves_are(data)
示例14: test_geotiff_generation_discrete_colorscale
def test_geotiff_generation_discrete_colorscale(self):
"""Check RGB geotiff generation with colorscale for GMF. Use
discrete colorscale based on IML values, with default IML."""
path = helpers.get_output_path(GEOTIFF_FILENAME_DISCRETE_COLORSCALE)
asymmetric_region = shapes.Region.from_coordinates(
TEST_REGION_LARGE_ASYMMETRIC)
gwriter = geotiff.GMFGeoTiffFile(path, asymmetric_region.grid,
iml_list=None, discrete=True, colormap=geotiff.COLORMAPS['gmt-seis'])
reference_raster = numpy.zeros((asymmetric_region.grid.rows,
asymmetric_region.grid.columns),
dtype=numpy.float)
self._fill_rasters(asymmetric_region, gwriter, reference_raster,
self._colorscale_cuts_fill)
gwriter.close()
示例15: test_geotiff_generation_nondefault_colorscale
def test_geotiff_generation_nondefault_colorscale(self):
"""Check RGB geotiff generation with colorscale for GMF. Use
alternative colorscale."""
path = helpers.get_output_path(GEOTIFF_FILENAME_NONDEFAULT_COLORSCALE)
asymmetric_region = shapes.Region.from_coordinates(
TEST_REGION_LARGE_ASYMMETRIC)
gwriter = geotiff.GMFGeoTiffFile(path, asymmetric_region.grid,
iml_list=None, discrete=False, colormap=geotiff.COLORMAPS['gmt-green-red'])
reference_raster = numpy.zeros((asymmetric_region.grid.rows,
asymmetric_region.grid.columns),
dtype=numpy.float)
self._fill_rasters(asymmetric_region, gwriter, reference_raster,
self._colorscale_cuts_fill)
gwriter.close()