Write Strategy Factory
Module containing convenience function to create WriteStrategy.
create_write_strategy(write_type, tiled, write_func=None, write_extension=None, write_func_kwargs=None)
Create a write strategy from convenient parameters.
Parameters:
-
write_type((tiff, custom), default:"tiff") –The data type to save as, includes custom.
-
tiled(bool) –Whether the prediction will be tiled or not.
-
write_func(WriteFunc, default:None) –If a known
write_typeis selected this argument is ignored. For a customwrite_typea function to save the data must be passed. See notes below. -
write_extension(str, default:None) –If a known
write_typeis selected this argument is ignored. For a customwrite_typean extension to save the data with must be passed. -
write_func_kwargs(dict of {str: any}, default:None) –Additional keyword arguments to be passed to the save function.
Returns:
-
WriteStrategy–A strategy for writing predicions.
select_write_extension(write_type, write_extension=None)
Return an extension to add to file paths.
If write_type is "custom" then write_extension, otherwise the known
write extension is selected.
Parameters:
-
write_type((tiff, custom), default:"tiff") –The data type to save as, includes custom.
-
write_extension(str, default:None) –If a known
write_typeis selected this argument is ignored. For a customwrite_typean extension to save the data with must be passed.
Returns:
-
str–The extension to be added to file paths.
Raises:
-
ValueError–If
self.save_type="custom"butsave_extensionhas not been given.
select_write_func(write_type, write_func=None)
Return a function to write images.
If write_type is "custom" then write_func, otherwise the known write function
is selected.
Parameters:
-
write_type((tiff, custom), default:"tiff") –The data type to save as, includes custom.
-
write_func(WriteFunc, default:None) –If a known
write_typeis selected this argument is ignored. For a customwrite_typea function to save the data must be passed. See notes below.
Returns:
-
WriteFunc–A function for writing images.
Raises:
-
ValueError–If
write_type="custom"butwrite_funchas not been given.