本文整理汇总了Python中Orange.data.io.FileFormat.locate方法的典型用法代码示例。如果您正苦于以下问题:Python FileFormat.locate方法的具体用法?Python FileFormat.locate怎么用?Python FileFormat.locate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orange.data.io.FileFormat
的用法示例。
在下文中一共展示了FileFormat.locate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_locate_sample_datasets
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import locate [as 别名]
def test_locate_sample_datasets(self):
with self.assertRaises(OSError):
FileFormat.locate("iris.tab",
search_dirs=[os.path.dirname(__file__)])
iris = FileFormat.locate("iris.tab",
search_dirs=[get_sample_datasets_dir()])
self.assertEqual(os.path.basename(iris), "iris.tab")
# test extension adding
iris = FileFormat.locate("iris",
search_dirs=[get_sample_datasets_dir()])
self.assertEqual(os.path.basename(iris), "iris.tab")
示例2: test_locate_wildcard_extension
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import locate [as 别名]
def test_locate_wildcard_extension(self):
tempdir = tempfile.mkdtemp()
with self.assertRaises(OSError):
FileFormat.locate("t.wild9", search_dirs=[tempdir])
fn = os.path.join(tempdir, "t.wild8")
with open(fn, "wt") as f:
f.write("\n")
l = FileFormat.locate("t.wild8", search_dirs=[tempdir])
self.assertEqual(l, fn)
# test extension adding
l = FileFormat.locate("t", search_dirs=[tempdir])
self.assertEqual(l, fn)
shutil.rmtree(tempdir)
示例3: load_from_file
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import locate [as 别名]
def load_from_file():
filename = self.last_path()
if not filename:
return None, ""
if not os.path.exists(filename):
filename = os.path.basename(filename)
filename = FileFormat.locate(filename, "")
self.information("Loading '{}' from the current directory."
.format(filename))
reader = FileFormat.get_reader(filename)
if isinstance(reader, ExcelReader):
reader.select_sheet(self.xls_sheet)
try:
return load(lambda x: reader.read(), filename)
except Exception as exc:
self.warnings.setText(str(exc))
# Let us not remove from recent files: user may fix them
raise
示例4: test_mosaic_ifg_read
# 需要导入模块: from Orange.data.io import FileFormat [as 别名]
# 或者: from Orange.data.io.FileFormat import locate [as 别名]
def test_mosaic_ifg_read(self):
# This reader will only be selected manually due to shared .dmt extension
absolute_filename = FileFormat.locate("agilent/5_mosaic_agg1024.dmt",
Orange.data.table.dataset_dirs)
d = agilentMosaicIFGReader(absolute_filename).read()
self.assertEqual(len(d), 32)
self.assertEqual(len(d.domain.attributes), 311)
# Pixel sizes are 5.5 * 32 = 176.0 (binning to reduce test data)
self.assertAlmostEqual(
d[1]["map_x"] - d[0]["map_x"], 176.0)
self.assertAlmostEqual(
d[4]["map_y"] - d[3]["map_y"], 176.0)
# Last pixel should start at (4 - 1) * 176.0 = 528.0
self.assertAlmostEqual(d[-1]["map_x"], 528.0)
# 1 x 2 mosiac, (8 - 1) * 176.0 = 1232.0
self.assertAlmostEqual(d[-1]["map_y"], 1232.0)
self.assertAlmostEqual(d[21][0], 0.7116039)
self.assertAlmostEqual(d[26][0], 0.48532167)
# Metadata
self.assertEqual(d.metas[0, 2], 1.57980039e+04)
self.assertEqual(d.metas[0, 3], 4)