flitsr.advanced.Config

class flitsr.advanced.Config(ranker: RankerType | None = None, cluster: ClusterType | None = None, refiner: RefinerType | None = None, args: Dict[str, Dict[str, Any]] | None = None)

Bases: object

The advanced type configuration for a particular run of SBFL methods.

Optionally contains a single Refiner, Cluster, and/or Ranker, as well as any arguments related to these advanced types. Multiple of these Config objects can be created in the same execution.

Changed in version 2.3.0: Replaced the ranker, cluster, and refiner attributes with functions constructing them

__init__(ranker: RankerType | None = None, cluster: ClusterType | None = None, refiner: RefinerType | None = None, args: Dict[str, Dict[str, Any]] | None = None)

Construct a Config object with the given ranker, cluster, and/or refiner (all optional).

Parameters:
  • ranker – The (optional) RankerType to include in this config

  • cluster – The (optional) ClusterType to include in this config

  • refiner – The (optional) RefinerType to include in this config

  • args – If given, the dictionary containing additional arguments for each of the advanced types. The dictionary is indexed by the name of the advanced type, with the value being another dictionary with argument names and values. For example: {‘MULTI’: {‘cutoff’: 5}} will set the cutoff parameter of the MULTI RankerType.

Changed in version 2.4.0: Added the args optional argument

Methods

__init__([ranker, cluster, refiner, args])

Construct a Config object with the given ranker, cluster, and/or refiner (all optional).

build_adv_type(...)

Constructs the advanced type given by adv_type using the parameters in both the given args and this Config's arguments.

cluster(args)

Build and return this Config's ClusterType, if available.

get_concrete(adv_type)

Returns a string name of this Config's concrete advanced type for the given category (Refiner, Cluster or Ranker), if it is available.

get_file_name([params])

Synonym for Config.get_str(filename=True, ...).

get_str([filename, params])

Returns a string description of the advanced types of this config object that can be used either in the name of the output file (filename=True), or for other script use (filename=False).

ranker(args)

Build and return this Config's RankerType, if available.

refiner(args)

Build and return this Config's RefinerType, if available.

set_arg(adv_type, arg_name, arg_value)

Set the argument given by arg_name with arg_value for the given advanced type.

build_adv_type(adv_type: RankerType, args: Args) Ranker
build_adv_type(adv_type: ClusterType, args: Args) Cluster
build_adv_type(adv_type: RefinerType, args: Args) Refiner
build_adv_type(adv_type: None, args: Args) None

Constructs the advanced type given by adv_type using the parameters in both the given args and this Config’s arguments.

Parameters:
  • adv_type – The advanced type to construct, which is one of RefinerType, ClusterType, or RankerType.

  • args – The global flitsr arguments to use when constructing the given advanced type.

Returns:

The constructed advanced type object, which corresponds to the given adv_type argument.

Added in version 2.4.0.

cluster(args: Args) Cluster | None

Build and return this Config’s ClusterType, if available.

Parameters:

args – The global flitsr arguments to use when constructing this Config’s ClusterType.

Returns:

This Config’s constructed Cluster object, or None if no ClusterType has been set.

Added in version 2.4.0.

get_concrete(adv_type: Type[RefinerType] | Type[ClusterType] | Type[RankerType]) str | None

Returns a string name of this Config’s concrete advanced type for the given category (Refiner, Cluster or Ranker), if it is available. For example, if RankerType was given, and this Config contained the SBFL RankerType, then “SBFL” would be returned. If there is no concrete advanced type for the given category, None is returned.

Parameters:

adv_type – The advanced type category to retrieve.

Returns:

The name of the concrete implementation for the given advanced type in this Config object, or None if no concrete implementation is available.

Added in version 2.4.0.

get_file_name(params: str | None = None)

Synonym for Config.get_str(filename=True, ...).

Returns a string description of the advanced types of this config object that can be used in the name of the output file.

Parameters:

params – (Default value = None) Whether to include advanced type parameters in the file name. See the get_str method for a description of the format.

Returns:

A string description of this Config for filename use.

Changed in version 2.4.0: Added the params optional argument

get_str(filename=False, params: str | None = None)

Returns a string description of the advanced types of this config object that can be used either in the name of the output file (filename=True), or for other script use (filename=False).

Parameters:

params – (Default value = None) If and how to include advanced type parameters in the output string. If None, parameters will not be included in the output string. If the empty string (“”) is given, parameters will be included in the format “{k}-{v}” (for filenames) or “{k}={v}” (for non-filenames), where “{k}” is the parameter name, and “{v}” the value. Alternatively, a different format can be specified by giving a string using the same “{k}”, “{v}” format.

Returns:

A string description of this Config.

Added in version 2.4.0.

ranker(args: Args) Ranker | None

Build and return this Config’s RankerType, if available.

Parameters:

args – The global flitsr arguments to use when constructing this Config’s RankerType.

Returns:

This Config’s constructed Ranker object, or None if no RankerType has been set.

Added in version 2.4.0.

refiner(args: Args) Refiner | None

Build and return this Config’s RefinerType, if available.

Parameters:

args – The global flitsr arguments to use when constructing this Config’s RefinerType.

Returns:

This Config’s constructed Refiner object, or None if no RefinerType has been set.

Added in version 2.4.0.

set_arg(adv_type: RefinerType | ClusterType | RankerType, arg_name: str, arg_value: Any)

Set the argument given by arg_name with arg_value for the given advanced type.

Parameters:
  • adv_type – The advanced type to set the argument for.

  • arg_name – str: The name of the argument to set

  • arg_valueAny: The value of the argument to set

Added in version 2.4.0.