BioSimSpace.Types.Length

class BioSimSpace.Types.Length(*args)

A length type.

__init__(*args)

Constructor.

*args can be a magnitude and unit, or a string representation of the length, e.g. “12 Angstrom”.

Parameters:
  • magnitude (float) – The magnitude.
  • unit (str) – The unit.
  • string (str) – A string representation of the length.

Examples

Create an object representing a length of 148.6 Angstrom then print the length in nanometers.

>>> import BioSimSpace as BSS
>>> length = BSS.Types.Length(148.6, "A")
>>> print(length.nanometers())

The same as above, except passing a string representation of the length to the constructor.

>>> import BioSimSpace as BSS
>>> length = BSS.Types.Length("148.6 A")
>>> print(length.nanometers())

The string matching is extremeley flexible, so all of the following would be valid arguments: “148.6 A”, “148.6 angstrom”, “1.48e2 Angstrom”.

Methods

__init__(*args) Constructor.
angstroms() Return the length in angstroms.
centimeters() Return the length in centimeters.
magnitude() Return the magnitude.
meters() Return the length in meters.
millimeters() Return the length in millimeters.
nanometers() Return the length in nanometers.
picometers() Return the length in picometers.
unit() Return the unit.
angstroms()

Return the length in angstroms.

Returns:length – The length in angstrom.
Return type:Length
centimeters()

Return the length in centimeters.

Returns:length – The length in centimeters.
Return type:Length
magnitude()

Return the magnitude.

Returns:magnitude – The magnitude of the type.
Return type:float
meters()

Return the length in meters.

Returns:length – The length in meters.
Return type:Length
millimeters()

Return the length in millimeters.

Returns:length – The length in millimeters.
Return type:Length
nanometers()

Return the length in nanometers.

Returns:length – The length in nanometers.
Return type:Length
picometers()

Return the length in picometers.

Returns:length – The length in picometers.
Return type:Length
unit()

Return the unit.

Returns:unit – The unit of the type.
Return type:str