Public API#

View Module Index

class sire.base.Properties#

This class holds a collection of properties, indexed by name. Each property comes complete with a set of metadata. The metadata is actually another Properties object, and indeed Properties can itself be a Property, so allowing Properties to be nested indefinitely.

Author: Christopher Woods

addLink( (Properties)arg1, (object)key, (object)linked_property) -> None :
Add a link from the property key to the property linked_property.

The linked_property will be returned if there is no property called key in this set.

Note that the linked property must already be contained in this set.

C++ signature :

void addLink(SireBase::Properties {lvalue},QString,QString)

all_metadata()#
allMetadata( (Properties)arg1) -> Properties :

Return all of the metadata associated with this properties object

C++ signature :

SireBase::Properties allMetadata(SireBase::Properties {lvalue})

allMetadata( (Properties)arg1, (PropertyName)key) -> Properties :

Return the metadata for the property with key key Throw: SireBase::missing_property

C++ signature :

SireBase::Properties allMetadata(SireBase::Properties {lvalue},SireBase::PropertyName)

as_array()#
asAnArray( (Property)arg1) -> PropertyList :

Return this property converted to an array property. By default, this automatically puts this property into a PropertyList and returns that

C++ signature :

SireBase::PropertyList asAnArray(SireBase::Property {lvalue})

as_boolean()#
asABoolean( (Property)arg1) -> bool :

Return this property converted to a bool. This throws an invalid cast if this is not possible

C++ signature :

bool asABoolean(SireBase::Property {lvalue})

as_double()#
asADouble( (Property)arg1) -> float :

Return this property converted to a double. This throws an invalid cast if this is not possible

C++ signature :

double asADouble(SireBase::Property {lvalue})

as_integer()#
asAnInteger( (Property)arg1) -> int :

Return this property converted to an integer. This throws an invalid cast if this is not possible

C++ signature :

int asAnInteger(SireBase::Property {lvalue})

as_string()#
asAString( (Property)arg1) -> object :

Return this property converted to a string. This throws an invalid cast if this is not possible

C++ signature :

QString asAString(SireBase::Property {lvalue})

as_unit()#
asAUnit( (Property)arg1) -> GeneralUnit :

Return this property converted to a unit

C++ signature :

SireUnits::Dimension::GeneralUnit asAUnit(SireBase::Property {lvalue})

assert_contains_metadata()#
assertContainsMetadata( (Properties)arg1, (PropertyName)metakey) -> None :

Assert that this contains the metadata at metakey metakey

C++ signature :

void assertContainsMetadata(SireBase::Properties {lvalue},SireBase::PropertyName)

assertContainsMetadata( (Properties)arg1, (PropertyName)key, (PropertyName)metakey) -> None :

Assert that this set contains the metadata property for the property key with metakey metakey Throw: SireBase::missing_property

C++ signature :

void assertContainsMetadata(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::PropertyName)

assert_contains_property()#
assertContainsProperty( (Properties)arg1, (PropertyName)key) -> None :

Assert that this set contains a property with key key Throw: SireBase::missing_property

C++ signature :

void assertContainsProperty(SireBase::Properties {lvalue},SireBase::PropertyName)

assign((Properties)arg1, (Properties)other) Properties :#
C++ signature :

SireBase::Properties {lvalue} assign(SireBase::Properties {lvalue},SireBase::Properties)

clear((Properties)arg1) None :#

Completely clear this object of all properties and metadata

C++ signature :

void clear(SireBase::Properties {lvalue})

clone((Properties)arg1) Properties :#
C++ signature :

SireBase::Properties clone(SireBase::Properties)

count((Properties)arg1) int :#

Return the number of properties in this set

C++ signature :

int count(SireBase::Properties {lvalue})

getLinks( (Properties)arg1) -> object :

Return all of the property links

C++ signature :

QHash<QString, QString> getLinks(SireBase::Properties {lvalue})

hasLinks( (Properties)arg1) -> bool :

Return whether or not there are any property links

C++ signature :

bool hasLinks(SireBase::Properties {lvalue})

has_metadata()#
hasMetadata( (Properties)arg1, (PropertyName)metakey) -> bool :

Return whether or not this contains the metadata with metakey metakey

C++ signature :

bool hasMetadata(SireBase::Properties {lvalue},SireBase::PropertyName)

hasMetadata( (Properties)arg1, (PropertyName)key, (PropertyName)metakey) -> bool :

Return whether or not the property with key key contains some metadata with the metakey metakey Throw: SireBase::missing_property

C++ signature :

bool hasMetadata(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::PropertyName)

has_property()#
hasProperty( (Properties)arg1, (PropertyName)key) -> bool :

Return whether or not this contains a property with key key

C++ signature :

bool hasProperty(SireBase::Properties {lvalue},SireBase::PropertyName)

is_array()#
isAnArray( (Property)arg1) -> bool :

Return whether or not this is an array property (or can convert to an array property)

C++ signature :

bool isAnArray(SireBase::Property {lvalue})

is_boolean()#
isABoolean( (Property)arg1) -> bool :

Return whether or not this property holds a bool (or can convert to a bool)

C++ signature :

bool isABoolean(SireBase::Property {lvalue})

is_double()#
isADouble( (Property)arg1) -> bool :

Return whether or not this property holds a double (or can convert to a double)

C++ signature :

bool isADouble(SireBase::Property {lvalue})

is_empty()#
isEmpty( (Properties)arg1) -> bool :

Return whether this is empty (has no values)

C++ signature :

bool isEmpty(SireBase::Properties {lvalue})

is_integer()#
isAnInteger( (Property)arg1) -> bool :

Return whether or not this property holds an integer (or can convert to an integer)

C++ signature :

bool isAnInteger(SireBase::Property {lvalue})

is_string()#
isAString( (Property)arg1) -> bool :

Return whether or not this property holds a string (or can convert to a string)

C++ signature :

bool isAString(SireBase::Property {lvalue})

is_unit()#
isAUnit( (Property)arg1) -> bool :

Return whether or not this property holds a unit (or can convert to a unit)

C++ signature :

bool isAUnit(SireBase::Property {lvalue})

keys()#
propertyKeys( (Properties)arg1) -> object :

Return the keys for all of the properties in this set

C++ signature :

QStringList propertyKeys(SireBase::Properties {lvalue})

metadata((Properties)arg1, (PropertyName)metakey) Property :#
Return the metadata at metakey metakey - note that if metakey

specifies a value rather than a source, then the value contained in the metakey is returned. Throw: SireBase::missing_property

C++ signature :

SireBase::Property metadata(SireBase::Properties {lvalue},SireBase::PropertyName)

metadata( (Properties)arg1, (PropertyName)metakey, (Property)default_value) -> Property :

Return the metadata at metakey metakey - note that if metakey specifies a value rather than a source, then the value contained in the metakey is returned. If there is no such metadata, and no value is contained in the metakey, then default_value is returned

C++ signature :

SireBase::Property metadata(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::Property)

metadata( (Properties)arg1, (PropertyName)key, (PropertyName)metakey) -> Property :

Return the metadata at metakey metakey that is associated with the property at key key. Throw: SireBase::missing_property

C++ signature :

SireBase::Property metadata(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::PropertyName)

metadata( (Properties)arg1, (PropertyName)key, (PropertyName)metakey, (Property)default_value) -> Property :

Return the metadata at metakey metakey that is associated with the property at key key, or default_value if there is no such metadata.

C++ signature :

SireBase::Property metadata(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::PropertyName,SireBase::Property)

metadata_keys()#
metadataKeys( (Properties)arg1) -> object :

Return the list of metadata keys

C++ signature :

QStringList metadataKeys(SireBase::Properties {lvalue})

metadataKeys( (Properties)arg1, (PropertyName)key) -> object :

Return the list of metadata keys for the property with key key Throw: SireBase::missing_property

C++ signature :

QStringList metadataKeys(SireBase::Properties {lvalue},SireBase::PropertyName)

metadata_type()#
metadataType( (Properties)arg1, (PropertyName)metakey) -> str :

Return the type name of the metadata at metakey metakey Throw: SireBase::missing_property

C++ signature :

char const* metadataType(SireBase::Properties {lvalue},SireBase::PropertyName)

metadataType( (Properties)arg1, (PropertyName)key, (PropertyName)metakey) -> str :

Return the type name of the metadata at metakey metakey for the property at key key Throw: SireBase::missing_property

C++ signature :

char const* metadataType(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::PropertyName)

num_properties()#
nProperties( (Properties)arg1) -> int :

Return the number of properties in this set

C++ signature :

int nProperties(SireBase::Properties {lvalue})

property((Properties)arg1, (PropertyName)key) Property :#
Return the property with key key - note that if

key specifies a value rather than a source, then the value contained in the key is returned Throw: SireBase::missing_property

C++ signature :

SireBase::Property property(SireBase::Properties {lvalue},SireBase::PropertyName)

property( (Properties)arg1, (PropertyName)key, (Property)default_value) -> Property :

Return the property with key key - note that if key specifies a value rather than a source, then the value contained in the key is returned. If no such source exists, and there is no value in the key, then default_value is returned

C++ signature :

SireBase::Property property(SireBase::Properties {lvalue},SireBase::PropertyName,SireBase::Property)

property_keys()#
propertyKeys( (Properties)arg1) -> object :

Return the keys for all of the properties in this set

C++ signature :

QStringList propertyKeys(SireBase::Properties {lvalue})

property_type()#
propertyType( (Properties)arg1, (PropertyName)key) -> str :

Return the type name of the property at key key Throw: SireBase::missing_property

C++ signature :

char const* propertyType(SireBase::Properties {lvalue},SireBase::PropertyName)

removeAllLinks( (Properties)arg1) -> None :

Remove all property links from this set

C++ signature :

void removeAllLinks(SireBase::Properties {lvalue})

remove_all_metadata()#
removeAllMetadata( (Properties)arg1) -> None :

Remove all of the top-level metadata

C++ signature :

void removeAllMetadata(SireBase::Properties {lvalue})

removeAllMetadata( (Properties)arg1, (object)key) -> None :

Remove all of the metadata associated with the property at key key

C++ signature :

void removeAllMetadata(SireBase::Properties {lvalue},QString)

removeLink( (Properties)arg1, (object)key) -> None :

Remove the link associated with the key key

C++ signature :

void removeLink(SireBase::Properties {lvalue},QString)

remove_metadata()#
removeMetadata( (Properties)arg1, (object)metakey) -> None :

Remove the metadata at metakey metakey

C++ signature :

void removeMetadata(SireBase::Properties {lvalue},QString)

removeMetadata( (Properties)arg1, (object)key, (object)metakey) -> None :

Remove the metadata at metakey metakey for the property at key key

C++ signature :

void removeMetadata(SireBase::Properties {lvalue},QString,QString)

remove_property()#
removeProperty( (Properties)arg1, (object)key) -> None :

Remove the property with key key and all of its metadata

C++ signature :

void removeProperty(SireBase::Properties {lvalue},QString)

set_metadata()#
setMetadata( (Properties)arg1, (object)metakey, (Property)value) -> None :

Set the metadata at metakey metakey to have the value value. This replaces any existing metadata with this metakey

C++ signature :

void setMetadata(SireBase::Properties {lvalue},QString,SireBase::Property)

setMetadata( (Properties)arg1, (object)key, (object)metakey, (Property)value) -> None :

Set the metadata at metakey metakey for the property at key key. This replaces any existing metadata for this keymetakey pair

C++ signature :

void setMetadata(SireBase::Properties {lvalue},QString,QString,SireBase::Property)

size((Properties)arg1) int :#

Return the number of properties in this set

C++ signature :

int size(SireBase::Properties {lvalue})

to_string()#
toString( (Properties)arg1) -> object :

Return a string representation of this set of properties

C++ signature :

QString toString(SireBase::Properties {lvalue})

typename()#

typeName() -> str :

C++ signature :

char const* typeName()

update_property()#
updateProperty( (Properties)arg1, (object)key, (Property)value [, (bool)auto_add=True]) -> bool :
Update the passed property to have the value value. This does

an in-place update on the existing property (which must have a compatible type). If auto-add is true, then this will add the property if it doesnt exist. This returns whether or not a property was updated (or added)

C++ signature :

bool updateProperty(SireBase::Properties {lvalue},QString,SireBase::Property [,bool=True])

class sire.base.PropertyMap#

This is the class that holds the collection of user-supplied optional properties and their locations to functions.

This class allows the following code to be written;

cljff.add( mol, Property::set(charges,chgs) + Property::set(ljs,ljparams) );

The PropertyMapPropertyName classes provide a kwargs like interface for the C++ classes - indeed the python wrappers should allow code to be written like;

cljff.add( mol, {charges : chgs, ljs : ljparams} )

or

cljff.add( mol, charges=charges, ljs=ljparams )

Author: Christopher Woods

add_prefix()#
addPrefix( (PropertyMap)arg1, (object)prefix, (object)properties) -> PropertyMap :
Add the passed prefix onto all of the passed properties,

returning a new property map that would map from map[key] = X to map[prefixkey] = X

C++ signature :

SireBase::PropertyMap addPrefix(SireBase::PropertyMap {lvalue},QString,QStringList)

add_suffix()#
addSuffix( (PropertyMap)arg1, (object)suffix, (object)properties) -> PropertyMap :
Add the passed suffix onto all of the passed properties,

returning a new property map that would map from map[key] = X to map[keysuffix] = X

C++ signature :

SireBase::PropertyMap addSuffix(SireBase::PropertyMap {lvalue},QString,QStringList)

assign((PropertyMap)arg1, (PropertyMap)other) PropertyMap :#
C++ signature :

SireBase::PropertyMap {lvalue} assign(SireBase::PropertyMap {lvalue},SireBase::PropertyMap)

clone((PropertyMap)arg1) PropertyMap :#
C++ signature :

SireBase::PropertyMap clone(SireBase::PropertyMap)

get_string(key: str)#

Return the string value associated with the passed ‘key’

This returns ‘key’ if there is no value associated

is_default()#
isDefault( (PropertyMap)arg1) -> bool :

Return whether or not this map is default - if it is, then it doesnt specify any properties

C++ signature :

bool isDefault(SireBase::PropertyMap {lvalue})

merge((PropertyMap)arg1, (PropertyMap)other) PropertyMap :#
Return a PropertyMap that is the combination of this and other.

Keys set in other take precedence over keys in this.

C++ signature :

SireBase::PropertyMap merge(SireBase::PropertyMap {lvalue},SireBase::PropertyMap)

specified((PropertyMap)arg1, (str)name) bool :#
Return whether or not this map specifies the source or value

of the property called name

C++ signature :

bool specified(SireBase::PropertyMap {lvalue},char const*)

specified( (PropertyMap)arg1, (object)name) -> bool :

Return whether or not this map specifies the source or value of the property called name

C++ signature :

bool specified(SireBase::PropertyMap {lvalue},QString)

specified( (PropertyMap)arg1, (PropertyName)name) -> bool :

Return whether or not this map specifies the source or value of the property called name

C++ signature :

bool specified(SireBase::PropertyMap {lvalue},SireBase::PropertyName)

to_dict()#
toDict( (PropertyMap)arg1) -> object :

Return the raw underlying dictionary of the map

C++ signature :

QHash<QString, SireBase::PropertyName> toDict(SireBase::PropertyMap {lvalue})

to_string()#
toString( (PropertyMap)arg1) -> object :

Return a string representation of this PropertyMap

C++ signature :

QString toString(SireBase::PropertyMap {lvalue})

typename()#

typeName() -> str :

C++ signature :

char const* typeName()

unset((PropertyMap)arg1, (object)name) None :#

Unset the property called name. This will return it to default

C++ signature :

void unset(SireBase::PropertyMap {lvalue},QString)

what((PropertyMap)arg1) str :#
C++ signature :

char const* what(SireBase::PropertyMap {lvalue})

sire.base.create_map(values, extras=None)[source]#

Construct a PropertyMap from the passed values. A PropertyMap is a class that lets you either provide extra options to some of the C++ functions, or to map the default keys used to find properties to your own keys

You normally wouldn’t use the class yourself. Instead, objects of this class will be created automatically from dictionaries, e.g.

>>> mol.energy(map={"cutoff": 5*angstrom})

would automatically create a PropertyMap, and is equivalent to writing

>>> mol.energy(map=create_map({"cutoff": 5*angstrom}))

In the above case you are providing an extra “cutoff” option, and are passing the value “5*angstrom”.

You can also use the map to change the keys used to find properties, e.g.

>>> mol.energy(map={"coordinates": "my_coords"})

would map the default “coordinates” property to your “my_coords” property. This means that the coordinates for the energy would be found at “my_coords” rather than “coordinates”.

You can map as many properties, and provide as many extra options as you want.

sire.base.wrap(value)[source]#

Wrap the passed value into a Property object. This works recursively, wrapping all items in a container, such that the returned value is derived from Property and can be passed to the C++ code in sire. Note that you normally don’t need to call this yourself, as wrapping is handled automatically.