Property classes#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Property classes used in other parts of the code.

class pixSED.misc.properties.BoolProperty(default: bool, testFunc: ~typing.Callable[[~typing.Any], bool] = <function BoolProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property object which stores a single boolean.

Arguments

Parameters:

default (bool) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP <wilfried.mercier@irap.omp.eu>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.EnumProperty(value: ~enum.Enum, testFunc: ~typing.Callable[[~typing.List[str]], bool] = <function EnumProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores an Enum object.

Arguments

Parameters:

default (enum.Enum) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.FloatProperty(default: float, minBound: ~typing.Optional[float] = None, maxBound: ~typing.Optional[float] = None, testFunc: ~typing.Callable[[float], bool] = <function FloatProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property object which stores a single float.

Arguments

Parameters:

default (float) – default value used at init

Keyword arguments

Parameters:
  • minBound (float) – minimum value for the property. If None, it is ignored.

  • maxBound (float) – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.IntProperty(default: int, minBound: ~typing.Optional[int] = None, maxBound: ~typing.Optional[int] = None, testFunc: ~typing.Callable[[int], bool] = <function IntProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property object which stores a single integer.

Arguments

Parameters:

default (int) – default value used at init

Keyword arguments

Parameters:
  • minBound (int) – minimum value for the property. If None, it is ignored.

  • maxBound (int) – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.ListFloatProperty(default: ~typing.List[float], minBound: ~typing.Optional[float] = None, maxBound: ~typing.Optional[float] = None, testFunc: ~typing.Callable[[~typing.List[float]], bool] = <function ListFloatProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: ListProperty

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores an int list object.

Arguments

Parameters:

default (list[float]) – default value used at init

Keyword arguments

Parameters:
  • minBound (float) – minimum value for the property. If None, it is ignored.

  • maxBound (float) – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value (list) – new value. Must be of correct type, and within bounds.

class pixSED.misc.properties.ListIntProperty(default: ~typing.List[int], minBound: ~typing.Optional[int] = None, maxBound: ~typing.Optional[int] = None, testFunc: ~typing.Callable[[~typing.List[int]], bool] = <function ListIntProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: ListProperty

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores an int list object.

Arguments

Parameters:

default (list[int]) – default value used at init

Keyword arguments

Parameters:
  • minBound (int) – minimum value for the property. If None, it is ignored.

  • maxBound (int) – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value (list) – new value. Must be of correct type, and within bounds.

class pixSED.misc.properties.ListPathProperty(default: ~typing.List[str], testFunc: ~typing.Callable[[~typing.List[str]], bool] = <function ListPathProperty.<lambda>>, testMsg: str = '', path: str = '', ext: str = '', **kwargs)[source]#

Bases: ListProperty

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores a str list object which includes additional checks for paths.

Arguments

Parameters:

default (list[str]) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

  • path (str) – path to append each time to the new value

  • ext (str) – extension to append at the end of the file name when checking the path

Raises:

TypeError – if neither path nor ext are str

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value (list) – new value. Must be of correct type, and within bounds.

class pixSED.misc.properties.ListProperty(default: ~typing.List[~typing.Any], minBound: ~typing.Optional[~typing.Any] = None, maxBound: ~typing.Optional[~typing.Any] = None, testFunc: ~typing.Callable[[~typing.List[~typing.Any]], bool] = <function ListProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

An abstract class which defines a property which stores a list object.

You must subclass it with __str__ and set methods or use a default subclass in order to use it.

Arguments

Parameters:

default – default value used at init

Keyword arguments

Parameters:
  • minBound – minimum value for the property. If None, it is ignored.

  • maxBound – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

static check_bounds(value: List[Any], mini: Any, maxi: Any, func: Callable, msg: str) None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Parameters:
  • value (list) – value to check

  • mini – minimum value

  • maxi – maximum value

  • func (Callable) – test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • msg (str) – test message used to throw an error if testFunc returns False

Raises:

ValueError

  • if one of the values in value is below the minimum bound

  • if one of the values in value is above the maximum bound

  • if the test function is not passed

abstract set(value: List[Any], *args, **kwargs) None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value (list) – new value. Must be of correct type, and within bounds.

class pixSED.misc.properties.ListStrProperty(default: ~typing.List[str], testFunc: ~typing.Callable[[~typing.List[str]], bool] = <function ListStrProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: ListProperty

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores an int list object.

Arguments

Parameters:

default (list[str]) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value (list) – new value. Must be of correct type, and within bounds.

class pixSED.misc.properties.PathProperty(default: str, testFunc: ~typing.Callable[[str], bool] = <function PathProperty.<lambda>>, testMsg: str = '', path: str = '', ext: str = '', skipCheckPath: bool = False, **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores a str object and can include additional checks for paths.

Arguments

Parameters:

default (str) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

  • path (str) – path to append each time to the new value

  • ext (str) – extension to append at the end of the file name when checking the path

  • skipCheckPath (bool) – whether to skip the check of the existence of the path. It can be useful for paths that have not been created yet.

Raises:

TypeError – if neither path nor ext are str

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Type:

str

_checkPath(value: str, *args, **kwargs) bool[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Check whether the path exists or not.

Parameters:

value (str) – new value

Returns:

True if the path is ok and False otherwise

Return type:

bool

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.Property(default: ~typing.Any, minBound: ~typing.Optional[~typing.Any] = None, maxBound: ~typing.Optional[~typing.Any] = None, testFunc: ~typing.Callable[[~typing.Any], bool] = <function Property.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: ABC

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Abstract class which defines a property object used by SED objects to store SED parameters.

You must subclass it with __str__ and set methods or used a default subclass in order to use it.

Arguments

Parameters:

default – default value used at init

Keyword arguments

Parameters:
  • minBound – minimum value for the property. If None, it is ignored.

  • maxBound – maximum value for the property. If None, it is ignored.

  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

Raises:
  • TypeError

    • if testFunc is not a Callable

    • if testMsg is not of type str

  • ValueError – if minBound is larger than maxBound and both are not None

abstract __str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representation

Return type:

str

static check_bounds(value: Any, mini: Any, maxi: Any, func: Callable, msg: str) None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Parameters:
  • value – value to check

  • mini – minimum value

  • maxi – maximum value

  • func (Callable) – test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • msg (str) – test message used to throw an error if testFunc returns False

Raises:

ValueError

  • if value < mini

  • if value > maxi

  • if the test function is not passed

abstract set(value: Any, *args, **kwargs) None[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value

class pixSED.misc.properties.StrProperty(default: str, testFunc: ~typing.Callable[[str], bool] = <function StrProperty.<lambda>>, testMsg: str = '', **kwargs)[source]#

Bases: Property

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Define a property which stores a single str object.

Arguments

Parameters:

default (str) – default value used at init

Keyword arguments

Parameters:
  • testFunc (Callable) – a test function with the value to test as argument which must not be passed in order to set a value. This can be used to add additional checks which are not taken into account by default.

  • testMsg (str) – a test message used to throw an error if testFunc returns False

__str__(*args, **kwargs) str[source]#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Implement a string representation of the class.

Returns:

the string representatin

Return type:

str

set(**kwargs)#

Code author: Wilfried Mercier - IRAP/LAM <wilfried.mercier@lam.fr>

Set the current value.

Parameters:

value – new value