flitsr.input.Input¶
- class flitsr.input.Input(split_faults: bool = False, method_level: bool = False, duplicate_strategy: DuplicateStrategy = DuplicateStrategy.REFUSE)¶
Bases:
ABCAn abstract spectral input type. If extending from this type, see
DirInputandFileInput.- final __init__(split_faults: bool = False, method_level: bool = False, duplicate_strategy: DuplicateStrategy = DuplicateStrategy.REFUSE)¶
Internal constructor for an
Inputtype.Caution
This constructor should not be called directly. Use the
read_inmethod instead.Changed in version 2.5.0: Added the
split_faults, method_level, and duplicate_strategy parameters
Methods
__init__([split_faults, method_level, ...])Internal constructor for an
Inputtype.The type (file or directory) expected for this Input method.
check_format(input_path)Check whether the files from the specified input_path are of the concrete types format.
Method to get the separators used for printing out elements when writing a spectrum in the format of this input type.
get_reader(input_path)Static helper method that guesses the input type of the given input path out of all available input types.
get_run_file_name(input_path)Return the name of the run file that this input type determines for the given input string.
get_type()Return the InputType enum of this input type.
read_in(input_path[, split_faults, ...])Read in the spectrum from the given input file.
read_spectrum(-> ~flitsr.spectrum.Spectrum)Deprecated alias of
Input.read_in.search_pattern(**kwargs)Returns the search pattern to use in the run_all script when searching for inputs of the given
Inputtype to run on.write_spectrum(spectrum, output_path)Write the given spectrum in the format of this input type.
- abstractmethod classmethod base_input_type() BaseInputType¶
The type (file or directory) expected for this Input method. For convenience in implementing this method, extend either
FileInputorDirInput.Added in version 2.5.0.
- abstractmethod static check_format(input_path: str) bool¶
Check whether the files from the specified input_path are of the concrete types format. The implementation of this abstract method must return a boolean, where True indicates that the input is in the format recognized by the implementing class, and False otherwise
- Parameters:
input_path – str: The input path to check for format.
- Returns:
True if the input path refers to input in the format that this input type can read, or False otherwise.
- classmethod get_elem_separators() List[str]¶
Method to get the separators used for printing out elements when writing a spectrum in the format of this input type. NOTE: this method does not need to be implemented by an input type unless it is used in the implemented write_spectrum method.
- final static get_reader(input_path: str) Type[Input]¶
Static helper method that guesses the input type of the given input path out of all available input types.
- Parameters:
input_path – str: The input path string to guess the input type for.
- Returns:
The concrete input type that can read in the given input path.
- static get_run_file_name(input_path: str) str¶
Return the name of the run file that this input type determines for the given input string. Note: this function assumes the given string is a valid input of a particular type, and thus is either a file or directory which represents a single program spectrum.
- Parameters:
input_path – str: The name of the input file representing a single program spectrum.
- Returns:
The name of the run file. For files, this is just the input file name with the extension replaced with “.run”. For directories, this is the name of the directory with the “.run” extension appended.
- final classmethod get_type() InputType¶
Return the InputType enum of this input type.
- final classmethod read_in(input_path: str, split_faults: bool = False, method_level: bool = False, duplicate_strategy: DuplicateStrategy = DuplicateStrategy.REFUSE) Spectrum¶
Read in the spectrum from the given input file. When called from a concrete
Inputclass, simply reads the spectrum using that input type. When called fromInput, or any other abstract class, this method guesses the input type of the given input path out of all available input types, and reads in the spectrum using that input type.- Parameters:
input_path – The spectrum input path string to read in.
split_faults – Whether to split faults using FLITSR’s split_faults functionality.
method_level – Whether to read this spectrum in as a method level spectrum.
duplicate_strategy – The policy for allowing duplicate values in the spectrum.
- Returns:
The spectrum that was read in.
- final classmethod read_spectrum(input_path: str) Spectrum¶
- final classmethod read_spectrum(input_path: str, split_faults: bool = False, method_level: bool = False, duplicate_strategy: DuplicateStrategy = DupStrat.REFUSE) Spectrum
Deprecated alias of
Input.read_in.Deprecated since version 2.5.0: This method is deprecated and will be removed in a future release. Consider using the
read_inmethod instead.
- classmethod search_pattern(**kwargs) str¶
Returns the search pattern to use in the run_all script when searching for inputs of the given
Inputtype to run on. The format is a Unix shell style pattern (seefnmatch).For
FileInputtypes, will be the pattern to match against the name of the file, forDirInputtypes, will match against the name of any file within the directory.The default is “*”, i.e., match any file, but may be overriden by any
Inputsub-class. Sub-classes may also define optional arguments which can be used to render specialized patterns.
- classmethod write_spectrum(spectrum: Spectrum, output_path: str) None¶
Write the given spectrum in the format of this input type. NOTE: this method does not need to be implemented by an input type. If it is not implemented and this method is called, a NotImplementedError will be thrown.
- Parameters:
spectrum – Spectrum: The spectrum to write.
output_path – str: The output path location string.