utils
dsstools.utils
Module containing various helper functions.
NumpyEncoder
Bases: JSONEncoder
Json encoder for numpy arrays.
ensure_file_format(path, *, default_format, format_filter=None)
Ensures that the provided path has a saving format and its parents exist.
If the saving format is not in the defined format_filter, a TypeError will be raised.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
the path that needs to be validated |
required |
default_format
|
str
|
the format a programmer can set that will be used as default, if no format was provided. Leading periods can be included. |
required |
format_filter
|
set | None
|
this specifies a filter of accepted formats. Leading periods can be included. Adding the default parameter isn't mandatory, since it is added dynamically but should be best practice. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Path, str]
|
the filepath and format (without leading dot) as an 2-Tuple |