BioSimSpace.Types.Time

class BioSimSpace.Types.Time(*args)

A time type.

__init__(*args)

Constructor.

*args can be a magnitude and unit, or a string representation of the time, e.g. “0.2 fs”.

Parameters
  • magnitude (float) – The magnitude.

  • unit (str) – The unit.

  • string (str) – A string representation of the time.

Examples

Create an object representing a time of 17.3 femtoseconds then print the time in nanoseconds.

>>> import BioSimSpace as BSS
>>> time = BSS.Types.Time(17.3, "fs")
>>> print(time.nanoseconds())

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

>>> import BioSimSpace as BSS
>>> time = BSS.Types.Time("17.3 fs")
>>> print(time.nanoseconds())

The string matching is extremeley flexible, so all of the following would be valid arguments: “17.3 fs”, “17.3 femtoseconds”, “1.73e1 fs”.

Methods

__add__(other)

Addition operator.

__delattr__

Implement delattr(self, name).

__dir__

Default dir() implementation.

__eq__(other)

Equals to operator.

__format__

Default object formatter.

__ge__(other)

Greater than or equal to operator.

__getattribute__

Return getattr(self, name).

__gt__(other)

Gretear than operator.

__init__(*args)

Constructor.

__init_subclass__

This method is called when a class is subclassed.

__le__(other)

Less than or equal to operator.

__lt__(other)

Less than operator.

__mul__(other)

Multiplication operator.

__ne__(other)

Not equals to operator.

__neg__()

Unary - operator.

__new__

Create and return a new object.

__pos__()

Unary + operator.

__reduce__

Helper for pickle.

__reduce_ex__

Helper for pickle.

__repr__()

Return a human readable string representation of the object.

__rmul__(other)

Multiplication operator.

__setattr__

Implement setattr(self, name, value).

__sizeof__

Size of object in memory, in bytes.

__str__()

Return a human readable string representation of the object.

__sub__(other)

Subtraction operator.

__subclasshook__

Abstract classes can override this to customize issubclass().

__truediv__(other)

Division operator.

_convert_to(unit)

Return the time in a different unit.

_default_unit([mag])

Internal method to return an object of the same type in the default unit.

_from_string(string)

Convert a string to an object of the same type.

_validate_unit(unit)

Validate that the unit are supported.

days()

Return the time in days.

femtoseconds()

Return the time in femtoseconds.

hours()

Return the time in hours.

magnitude()

Return the magnitude.

milliseconds()

Return the time in milliseconds.

minutes()

Return the time in minutes.

nanoseconds()

Return the time in nanoseconds.

picoseconds()

Return the time in picoseconds.

seconds()

Return the time in seconds.

unit()

Return the unit.

Attributes

__dict__

__doc__

__hash__

__module__

__weakref__

list of weak references to the object (if defined)

_abbreviations

_doc_strings

_null_unit

_print_format

_supported_units

days()

Return the time in days.

Returns

time – The time in days.

Return type

Time

femtoseconds()

Return the time in femtoseconds.

Returns

time – The time in femtoseconds.

Return type

Time

hours()

Return the time in hours.

Returns

time – The time in hours.

Return type

Time

magnitude()

Return the magnitude.

Returns

magnitude – The magnitude of the type.

Return type

float

milliseconds()

Return the time in milliseconds.

Returns

time – The time in milliseconds.

Return type

Time

minutes()

Return the time in minutes.

Returns

time – The time in minutes.

Return type

Time

nanoseconds()

Return the time in nanoseconds.

Returns

time – The time in nanoseconds.

Return type

Time

picoseconds()

Return the time in picoseconds.

Returns

time – The time in picoseconds.

Return type

Time

seconds()

Return the time in seconds.

Returns

time – The time in seconds.

Return type

Time

unit()

Return the unit.

Returns

unit – The unit of the type.

Return type

str