Networks#
This documentation is auto-generated from the NeuroML schema.
Connection#
- class neuroml.nml.nml.Connection(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell_id: a Nml2PopulationReferencePath (required) = None, pre_segment_id: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell_id: a Nml2PopulationReferencePath (required) = None, post_segment_id: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', gds_collector_=None, **kwargs_)#
Bases:
BaseConnectionOldFormat
Connection – Event connection directly between named components, which gets processed via a new instance of a synapse component which is created on the target component. Normally contained inside a projection element.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() str #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
ConnectionWD#
- class neuroml.nml.nml.ConnectionWD(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell_id: a Nml2PopulationReferencePath (required) = None, pre_segment_id: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell_id: a Nml2PopulationReferencePath (required) = None, post_segment_id: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', weight: a float (required) = None, delay: a Nml2Quantity_time (required) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseConnectionOldFormat
ConnectionWD – Event connection between named components, which gets processed via a new instance of a synapse component which is created on the target component, includes setting of weight and delay for the synaptic connection
- Parameters:
weight (none)
delay (time)
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- get_delay_in_ms() float #
Get connection delay in milli seconds
- Returns:
connection delay in milli seconds
- Return type:
float
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() str #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
ContinuousConnection#
- class neuroml.nml.nml.ContinuousConnection(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', pre_component: a NmlId (required) = None, post_component: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#
Bases:
BaseConnectionNewFormat
ContinuousConnection – An instance of a connection in a continuousProjection between presynapticPopulation to another postsynapticPopulation through a preComponent at the start and postComponent at the end. Can be used for analog synapses.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() str #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ContinuousConnectionInstance#
- class neuroml.nml.nml.ContinuousConnectionInstance(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', pre_component: a NmlId (required) = None, post_component: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#
Bases:
ContinuousConnection
ContinuousConnectionInstance – An instance of a connection in a continuousProjection between presynapticPopulation to another postsynapticPopulation through a preComponent at the start and postComponent at the end. Populations need to be of type populationList and contain instance and location elements. Can be used for analog synapses.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() str #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ContinuousConnectionInstanceW#
- class neuroml.nml.nml.ContinuousConnectionInstanceW(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', pre_component: a NmlId (required) = None, post_component: a NmlId (required) = None, weight: a float (required) = None, gds_collector_=None, **kwargs_)#
Bases:
ContinuousConnectionInstance
ContinuousConnectionInstanceW – An instance of a connection in a continuousProjection between presynapticPopulation to another postsynapticPopulation through a preComponent at the start and postComponent at the end. Populations need to be of type populationList and contain instance and location elements. Can be used for analog synapses. Includes setting of weight for the connection
- Parameters:
weight (none)
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() str #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- get_weight()#
Get weight.
If weight is not set, the default value of 1.0 is returned.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ContinuousProjection#
- class neuroml.nml.nml.ContinuousProjection(id: a NmlId (required) = None, presynaptic_population: a NmlId (required) = None, postsynaptic_population: a NmlId (required) = None, continuous_connections: list of ContinuousConnection(s) (optional) = None, continuous_connection_instances: list of ContinuousConnectionInstance(s) (optional) = None, continuous_connection_instance_ws: list of ContinuousConnectionInstanceW(s) (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseProjection
ContinuousProjection – A projection between presynapticPopulation and postsynapticPopulation through components preComponent at the start and postComponent at the end of a continuousConnection or continuousConnectionInstance . Can be used for analog synapses.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ElectricalConnection#
- class neuroml.nml.nml.ElectricalConnection(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', synapse: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#
Bases:
BaseConnectionNewFormat
ElectricalConnection – To enable connections between populations through gap junctions.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() float #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ElectricalConnectionInstance#
- class neuroml.nml.nml.ElectricalConnectionInstance(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', synapse: a NmlId (required) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#
Bases:
ElectricalConnection
ElectricalConnectionInstance – To enable connections between populations through gap junctions. Populations need to be of type populationList and contain instance and location elements.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() float #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ElectricalConnectionInstanceW#
- class neuroml.nml.nml.ElectricalConnectionInstanceW(id: a NonNegativeInteger (required) = None, neuro_lex_id: a NeuroLexId (optional) = None, pre_cell: a string (required) = None, pre_segment: a NonNegativeInteger (optional) = '0', pre_fraction_along: a ZeroToOne (optional) = '0.5', post_cell: a string (required) = None, post_segment: a NonNegativeInteger (optional) = '0', post_fraction_along: a ZeroToOne (optional) = '0.5', synapse: a NmlId (required) = None, weight: a float (required) = None, gds_collector_=None, **kwargs_)#
Bases:
ElectricalConnectionInstance
ElectricalConnectionInstanceW – To enable connections between populations through gap junctions. Populations need to be of type populationList and contain instance and location elements. Includes setting of weight for the connection
- Parameters:
weight (none)
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_post_cell_id() str #
Get the ID of the post-synaptic cell
- Returns:
ID of post-synaptic cell
- Return type:
str
- get_post_fraction_along()#
Get post-synaptic fraction along information
- get_post_info()#
Get post-synaptic information summary
- get_post_segment_id() str #
Get the ID of the post-synpatic segment
- Returns:
ID of post-synaptic segment.
- Return type:
str
- get_pre_cell_id() float #
Get the ID of the pre-synaptic cell
- Returns:
ID of pre-synaptic cell
- Return type:
str
- get_pre_fraction_along()#
Get pre-synaptic fraction along information
- get_pre_info()#
Get pre-synaptic information summary
- get_pre_segment_id() str #
Get the ID of the pre-synpatic segment
- Returns:
ID of pre-synaptic segment.
- Return type:
str
- get_weight() float #
Get the weight of the connection
If a weight is not set (or is set to None), returns the default value of 1.0.
- Returns:
weight of connection or 1.0 if not set
- Return type:
float
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ElectricalProjection#
- class neuroml.nml.nml.ElectricalProjection(id: a NmlId (required) = None, presynaptic_population: a NmlId (required) = None, postsynaptic_population: a NmlId (required) = None, electrical_connections: list of ElectricalConnection(s) (optional) = None, electrical_connection_instances: list of ElectricalConnectionInstance(s) (optional) = None, electrical_connection_instance_ws: list of ElectricalConnectionInstanceW(s) (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseProjection
ElectricalProjection – A projection between presynapticPopulation to another postsynapticPopulation through gap junctions.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
ExplicitInput#
- class neuroml.nml.nml.ExplicitInput(target: a Nml2PopulationReferencePath (required) = None, input: a NmlId (required) = None, destination: a NmlId (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseWithoutId
ExplicitInput – An explicit input ( anything which extends basePointCurrent ) to a target cell in a population
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- get_fraction_along()#
Get fraction along.
Returns 0.5 is fraction_along was not set.
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_segment_id()#
Get the ID of the segment.
Returns 0 if segment_id was not set.
- get_target_cell_id()#
Get target cell ID
- get_target_population()#
Get target population.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
Input#
- class neuroml.nml.nml.Input(id: a NonNegativeInteger (required) = None, target: a Nml2PopulationReferencePath (required) = None, destination: a NmlId (required) = None, segment_id: a NonNegativeInteger (optional) = None, fraction_along: a ZeroToOne (optional) = None, extensiontype_=None, gds_collector_=None, **kwargs_)#
Bases:
BaseNonNegativeIntegerId
Input – Specifies a single input to a target, optionally giving the segmentId ( default 0 ) and fractionAlong the segment ( default 0. 5 ).
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- get_fraction_along()#
Get fraction along.
Returns 0.5 is fraction_along was not set.
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_segment_id()#
Get the ID of the segment.
Returns 0 if segment_id was not set.
- get_target_cell_id()#
Get ID of target cell.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
InputList#
- class neuroml.nml.nml.InputList(id: a NonNegativeInteger (required) = None, populations: a NmlId (required) = None, component: a NmlId (required) = None, input: list of Input(s) (optional) = None, input_ws: list of InputW(s) (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
Base
InputList – An explicit list of input s to a population.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
InputW#
- class neuroml.nml.nml.InputW(id: a NonNegativeInteger (required) = None, target: a Nml2PopulationReferencePath (required) = None, destination: a NmlId (required) = None, segment_id: a NonNegativeInteger (optional) = None, fraction_along: a ZeroToOne (optional) = None, weight: a float (required) = None, gds_collector_=None, **kwargs_)#
Bases:
Input
InputW – Specifies input lists. Can set weight to scale individual inputs.
- Parameters:
weight (none)
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- get_fraction_along()#
Get fraction along.
Returns 0.5 is fraction_along was not set.
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_segment_id()#
Get the ID of the segment.
Returns 0 if segment_id was not set.
- get_target_cell_id()#
Get ID of target cell.
- get_weight()#
Get weight.
If weight is not set, the default value of 1.0 is returned.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
Instance#
- class neuroml.nml.nml.Instance(id: a nonNegativeInteger (optional) = None, i: a nonNegativeInteger (optional) = None, j: a nonNegativeInteger (optional) = None, k: a nonNegativeInteger (optional) = None, location: a Location (required) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseWithoutId
Instance – Specifies a single instance of a component in a population ( placed at location ).
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
Location#
- class neuroml.nml.nml.Location(x: a float (required) = None, y: a float (required) = None, z: a float (required) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseWithoutId
Location – Specifies the ( x, y, z ) location of a single instance of a component in a population
- Parameters:
x (none)
y (none)
z (none)
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
Network#
- class neuroml.nml.nml.Network(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, type: a networkTypes (optional) = None, temperature: a Nml2Quantity_temperature (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, spaces: list of Space(s) (optional) = None, regions: list of Region(s) (optional) = None, extracellular_properties: list of ExtracellularPropertiesLocal(s) (optional) = None, populations: list of Population(s) (required) = None, cell_sets: list of CellSet(s) (optional) = None, synaptic_connections: list of SynapticConnection(s) (optional) = None, projections: list of Projection(s) (optional) = None, electrical_projections: list of ElectricalProjection(s) (optional) = None, continuous_projections: list of ContinuousProjection(s) (optional) = None, explicit_inputs: list of ExplicitInput(s) (optional) = None, input_lists: list of InputList(s) (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
Standalone
Network – Network containing: population s ( potentially of type populationList , and so specifying a list of cell location s ); projection s ( with lists of connection s ) and/or explicitConnection s; and inputList s ( with lists of input s ) and/or explicitInput s. Note: often in NeuroML this will be of type networkWithTemperature if there are temperature dependent elements ( e. g. ion channels ).
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- get_by_id(id: str) Any | None #
Get a component by its ID
- Parameters:
id (str) – ID of component to find
- Returns:
component with specified ID or None if no component with specified ID found
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
Population#
- class neuroml.nml.nml.Population(id: a NmlId (required) = None, metaid: a MetaId (optional) = None, notes: a string (optional) = None, properties: list of Property(s) (optional) = None, annotation: a Annotation (optional) = None, component: a NmlId (required) = None, size: a NonNegativeInteger (optional) = None, type: a populationTypes (optional) = None, extracellular_properties: a NmlId (optional) = None, neuro_lex_id: a NeuroLexId (optional) = None, layout: a Layout (optional) = None, instances: list of Instance(s) (required) = None, gds_collector_=None, **kwargs_)#
Bases:
Standalone
Population – A population of components, with just one parameter for the size, i. e. number of components to create. Note: quite often this is used with type= populationList which means the size is determined by the number of instance s ( with location s ) in the list. The size attribute is still set, and there will be a validation error if this does not match the number in the list.
- Parameters:
size (none) – Number of instances of this Component to create when the population is instantiated
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- get_size()#
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
Projection#
- class neuroml.nml.nml.Projection(id: a NmlId (required) = None, presynaptic_population: a NmlId (required) = None, postsynaptic_population: a NmlId (required) = None, synapse: a NmlId (required) = None, connections: list of Connection(s) (optional) = None, connection_wds: list of ConnectionWD(s) (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseProjection
Projection – Projection from one population, presynapticPopulation to another, postsynapticPopulation, through synapse. Contains lists of connection or connectionWD elements.
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- exportHdf5(h5file, h5Group)#
Export to HDF5 file.
- Parameters:
h5file (file object) – HDF5 file handler
h5Group (tables.Group) – the tables Group object to write
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
Region#
- class neuroml.nml.nml.Region(id: a NmlId (required) = None, spaces: a NmlId (optional) = None, anytypeobjs_=None, gds_collector_=None, **kwargs_)#
Bases:
Base
Region – Initial attempt to specify 3D region for placing cells. Work in progress…
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
SynapticConnection#
- class neuroml.nml.nml.SynapticConnection(neuro_lex_id: a NeuroLexId (optional) = None, from_: a Nml2PopulationReferencePath (required) = None, to: a Nml2PopulationReferencePath (required) = None, synapse: a NmlId (required) = None, destination: a NmlId (optional) = None, gds_collector_=None, **kwargs_)#
Bases:
BaseWithoutId
SynapticConnection – Explicit event connection between named components, which gets processed via a new instance of a synapse component which is created on the target component
- add(obj=None, hint=None, force=False, validate=True, **kwargs)#
Generic function to allow easy addition of a new member to a NeuroML object. Without arguments, when obj=None, it simply calls the info() method to provide the list of valid member types for the NeuroML class.
Please use the info() method directly for more information on the current contents of this component object.
When obj is given a string name of a NeuroML class (“NeuroMLDocument”), or the class itself (neuroml.NeuroMLDocument), a new object will be created of this type and added as a member to the calling (parent) component type object.
- Parameters:
obj (Object) – member object or class type (neuroml.NeuroMLDocument) or name of class type (“NeuroMLDocument”), or None
hint (string) – member name to add to when there are multiple members that obj can be added to
force (bool) – boolean to force addition when an obj has already been added previously
validate (bool) – validate component after adding (default: True)
- Returns obj:
the provided or created object
- Raises:
Exception – if a member compatible to obj could not be found
Exception – if multiple members can accept the object and no hint is provided.
- classmethod component_factory(component_type, validate=True, **kwargs)#
Factory function to create a NeuroML Component object.
Users can provide the name of the component as a string or the class variable, along with its named constructor arguments, and this function will create a new object of the Component and return it.
Users can use the add() helper function to further modify components
This factory runs two checks while creating the component object:
that all arguments given do belong to the ComponentType (useful for caching typos)
that the created component is valid NeuroML
It is therefore less error prone than creating Components directly using the ComponentType constructors.
It may be useful to disable validation when starting a model. The validate parameter can be set to False for this.
- Parameters:
component_type (str/type) – component type to create component from: this can either be the name of the component as a string, e.g. “NeuroMLDocument”, or it can be the class type itself: NeuroMLDocument. Note that when providing the class type, one will need to import it, e.g.: import NeuroMLDocument, to ensure that it is defined, whereas this will not be required when using the string.
validate (bool) – toggle validation (default: True)
kwargs (named arguments) – named arguments to be passed to ComponentType constructor
- Returns:
new Component (object) of provided ComponentType
- Return type:
object
- Raises:
ValueError – if validation/checks fail
- classmethod get_class_hierarchy()#
Get the class hierarchy for a component classs.
Reference: https://stackoverflow.com/a/75161393/375067
See the methods in neuroml.utils to use this generated hierarchy.
- Returns:
nested single key dictionaries where the key of each dictionary is the root node of that subtree, and keys are its immediate descendents
- classmethod get_nml2_class_hierarchy()#
Return the NeuroML class hierarchy.
The root here is NeuroMLDocument. This is useful in calculating paths to different components to aid in construction of relative paths.
This caches the value as a class variable so that it is not re-calculated when used multiple times.
- has__content()#
- info(show_contents=False, return_format='string')#
Provide information on NeuroML component.
This is useful to quickly check what members can go into a particular NeuroML class (which will match the Schema definitions). It lists these members and notes whether they are “single” type elements (Child elements) or “List” elements (Children elements). It will also note whether a member is optional or required.
To get a list of possible parents, use the parentinfo() method.
By default, this will only show the members, and not their contents. To see contents that have been set, use show_contents=True. This will not show empty/unset contents. To see all contents, set show_contents=all.
Note that not all members will have ids (since not all NeuroML2 ComponentTypes have ids). For members that do not have ids, the object reference is listed instead.
See http://www.davekuhlman.org/generateDS.html#user-methods for more information on the MemberSpec_ class that generateDS uses.
- Parameters:
show_contents (bool or str) – toggle to print out the contents of the members
return_format (str) –
select what format to return information in “string” (default), or “dict” or “list”.
If “dict” or “list” is provided, the information is returned as a dict/list instead of being printed. Note that if show_contents is False, only a list of members is available and will be returned even if “dict” is supplied. If show_contents is True or “all” but “list” is provided, only the list of members will be returned. If something other than “string”, “list”, or “dict” is provided, the string representation is returned and printed.
- Returns:
info string, or list of members or dict with members as keys and member values as values
- Return type:
str, list/dict
- parentinfo(return_format='string')#
Show the list of possible parents.
This object can then be added to objects of the parents using the add method.
It is similar to the info() method. However, where in the info() method, it is possible to find the contents of members for a component (object) rather easily, it is not so easily possible to get all the objects that may refer to another object.
So, this will provide information on possible parents. It will not provide information on whether the components (objects) of the particular parent have already been instantiated and what their values are. The user should be able to gather this information easily by reading the sources.
Please also note that various component types in NeuroML take ids of components as parameters. For example, an ExplicitInput will take the id of a cell as its target, and the id of a PulseGenerator as input. However, these are string fields, and the cell/pulse generator classes do not currently know that their ids can be used in ExplicitInput. This information does not live in the XSD schema, and so cannot be obtained here either.
- Parameters:
return_format (str) – format in which to return information. If “string” (default), an information string is returned. If “list” or “dict”, a list or dictionary is returned. The list will only contain the parent names, whereas the dict will also include the member of the parent that the component type matches to.
- Returns:
info string, or list of parents or dict with parents as keys and member information as values
- Return type:
str, list/dict
- validate(recursive=False)#
Validate the component.
Throws a Python ValueError if a the component is invalid. You can ignore this by using a try .. except ValueError: pass block.
Note: validating your NeuroML file against the schema, which pynml and jnml do, will also check this.
Note: that this is different from the validate_ method, which does not validate inherited members.
- Parameters:
recursive (bool) – toggle recursive validation (default: False)
- Returns:
None
- Return type:
None
- Raises:
ValueError – if component is invalid
- validate_Nml2PopulationReferencePath(value)#
- validate_Nml2PopulationReferencePath_patterns_ = [['^((\\.\\./)?([a-zA-Z_][a-zA-Z0-9_]*)((\\[[0-9]+\\])|(/[0-9]+)+((/[a-zA-Z_][a-zA-Z0-9_]*)?)/?))$']]#
networkTypes#
- class neuroml.nml.nml.networkTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
str
,Enum
- NETWORK = 'network'#
- NETWORK_WITH_TEMPERATURE = 'networkWithTemperature'#
- capitalize()#
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
- casefold()#
Return a version of the string suitable for caseless comparisons.
- center(width, fillchar=' ', /)#
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
- count(sub[, start[, end]]) int #
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
- encode(encoding='utf-8', errors='strict')#
Encode the string using the codec registered for encoding.
- encoding
The encoding in which to encode the string.
- errors
The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
- endswith(suffix[, start[, end]]) bool #
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
- expandtabs(tabsize=8)#
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(sub[, start[, end]]) int #
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- format(*args, **kwargs) str #
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).
- format_map(mapping) str #
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).
- index(sub[, start[, end]]) int #
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- isalnum()#
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
- isalpha()#
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
- isascii()#
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
- isdecimal()#
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
- isdigit()#
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
- isidentifier()#
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.
- islower()#
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
- isnumeric()#
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
- isprintable()#
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
- isspace()#
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
- istitle()#
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
- isupper()#
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
- join(iterable, /)#
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
- ljust(width, fillchar=' ', /)#
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
- lower()#
Return a copy of the string converted to lowercase.
- lstrip(chars=None, /)#
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
- static maketrans()#
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
- partition(sep, /)#
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
- removeprefix(prefix, /)#
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
- removesuffix(suffix, /)#
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
- replace(old, new, count=-1, /)#
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
- rfind(sub[, start[, end]]) int #
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(sub[, start[, end]]) int #
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- rjust(width, fillchar=' ', /)#
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
- rpartition(sep, /)#
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
- rsplit(sep=None, maxsplit=-1)#
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
- rstrip(chars=None, /)#
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- split(sep=None, maxsplit=-1)#
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
- splitlines(keepends=False)#
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
- startswith(prefix[, start[, end]]) bool #
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
- strip(chars=None, /)#
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- swapcase()#
Convert uppercase characters to lowercase and lowercase characters to uppercase.
- title()#
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
- translate(table, /)#
Replace each character in the string using the given translation table.
- table
Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
- upper()#
Return a copy of the string converted to uppercase.
- zfill(width, /)#
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.
populationTypes#
- class neuroml.nml.nml.populationTypes(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)#
Bases:
str
,Enum
- POPULATION = 'population'#
- POPULATION_LIST = 'populationList'#
- capitalize()#
Return a capitalized version of the string.
More specifically, make the first character have upper case and the rest lower case.
- casefold()#
Return a version of the string suitable for caseless comparisons.
- center(width, fillchar=' ', /)#
Return a centered string of length width.
Padding is done using the specified fill character (default is a space).
- count(sub[, start[, end]]) int #
Return the number of non-overlapping occurrences of substring sub in string S[start:end]. Optional arguments start and end are interpreted as in slice notation.
- encode(encoding='utf-8', errors='strict')#
Encode the string using the codec registered for encoding.
- encoding
The encoding in which to encode the string.
- errors
The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.
- endswith(suffix[, start[, end]]) bool #
Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.
- expandtabs(tabsize=8)#
Return a copy where all tab characters are expanded using spaces.
If tabsize is not given, a tab size of 8 characters is assumed.
- find(sub[, start[, end]]) int #
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- format(*args, **kwargs) str #
Return a formatted version of S, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).
- format_map(mapping) str #
Return a formatted version of S, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).
- index(sub[, start[, end]]) int #
Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- isalnum()#
Return True if the string is an alpha-numeric string, False otherwise.
A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.
- isalpha()#
Return True if the string is an alphabetic string, False otherwise.
A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.
- isascii()#
Return True if all characters in the string are ASCII, False otherwise.
ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.
- isdecimal()#
Return True if the string is a decimal string, False otherwise.
A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.
- isdigit()#
Return True if the string is a digit string, False otherwise.
A string is a digit string if all characters in the string are digits and there is at least one character in the string.
- isidentifier()#
Return True if the string is a valid Python identifier, False otherwise.
Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.
- islower()#
Return True if the string is a lowercase string, False otherwise.
A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.
- isnumeric()#
Return True if the string is a numeric string, False otherwise.
A string is numeric if all characters in the string are numeric and there is at least one character in the string.
- isprintable()#
Return True if the string is printable, False otherwise.
A string is printable if all of its characters are considered printable in repr() or if it is empty.
- isspace()#
Return True if the string is a whitespace string, False otherwise.
A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.
- istitle()#
Return True if the string is a title-cased string, False otherwise.
In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.
- isupper()#
Return True if the string is an uppercase string, False otherwise.
A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.
- join(iterable, /)#
Concatenate any number of strings.
The string whose method is called is inserted in between each given string. The result is returned as a new string.
Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’
- ljust(width, fillchar=' ', /)#
Return a left-justified string of length width.
Padding is done using the specified fill character (default is a space).
- lower()#
Return a copy of the string converted to lowercase.
- lstrip(chars=None, /)#
Return a copy of the string with leading whitespace removed.
If chars is given and not None, remove characters in chars instead.
- static maketrans()#
Return a translation table usable for str.translate().
If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.
- partition(sep, /)#
Partition the string into three parts using the given separator.
This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing the original string and two empty strings.
- removeprefix(prefix, /)#
Return a str with the given prefix string removed if present.
If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.
- removesuffix(suffix, /)#
Return a str with the given suffix string removed if present.
If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.
- replace(old, new, count=-1, /)#
Return a copy with all occurrences of substring old replaced by new.
- count
Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.
If the optional argument count is given, only the first count occurrences are replaced.
- rfind(sub[, start[, end]]) int #
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Return -1 on failure.
- rindex(sub[, start[, end]]) int #
Return the highest index in S where substring sub is found, such that sub is contained within S[start:end]. Optional arguments start and end are interpreted as in slice notation.
Raises ValueError when the substring is not found.
- rjust(width, fillchar=' ', /)#
Return a right-justified string of length width.
Padding is done using the specified fill character (default is a space).
- rpartition(sep, /)#
Partition the string into three parts using the given separator.
This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.
If the separator is not found, returns a 3-tuple containing two empty strings and the original string.
- rsplit(sep=None, maxsplit=-1)#
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the end of the string and works to the front.
- rstrip(chars=None, /)#
Return a copy of the string with trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- split(sep=None, maxsplit=-1)#
Return a list of the substrings in the string, using sep as the separator string.
- sep
The separator used to split the string.
When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.
- maxsplit
Maximum number of splits. -1 (the default value) means no limit.
Splitting starts at the front of the string and works to the end.
Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.
- splitlines(keepends=False)#
Return a list of the lines in the string, breaking at line boundaries.
Line breaks are not included in the resulting list unless keepends is given and true.
- startswith(prefix[, start[, end]]) bool #
Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.
- strip(chars=None, /)#
Return a copy of the string with leading and trailing whitespace removed.
If chars is given and not None, remove characters in chars instead.
- swapcase()#
Convert uppercase characters to lowercase and lowercase characters to uppercase.
- title()#
Return a version of the string where each word is titlecased.
More specifically, words start with uppercased characters and all remaining cased characters have lower case.
- translate(table, /)#
Replace each character in the string using the given translation table.
- table
Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.
The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.
- upper()#
Return a copy of the string converted to uppercase.
- zfill(width, /)#
Pad a numeric string with zeros on the left, to fill a field of the given width.
The string is never truncated.