neotraits
Package¶
_h5accessors
¶
- class tvb.core.neotraits._h5accessors.Accessor(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
object
- class tvb.core.neotraits._h5accessors.DataSet(trait_attribute: NArray, h5file: H5File, name: str = None, expand_dimension: int = -1)[source]¶
Bases:
Accessor
A dataset in a h5 file that corresponds to a traited NArray.
- append(data: ndarray, close_file: bool = True, grow_dimension: int | None = None) None [source]¶
Method to be called when it is necessary to write slices of data for a large dataset, eg. TimeSeries. Metdata for such datasets is written only at file close time, see H5File.close method.
- get_cached_metadata()[source]¶
Returns cached properties of this dataset, like min max mean etc. This cache is useful for large, expanding datasets, when we want to avoid loading the whole dataset just to compute a max.
- property shape: Tuple[int]¶
- class tvb.core.neotraits._h5accessors.DataSetMetaData(min, max, mean, is_finite=True, has_complex=False)[source]¶
Bases:
object
simple container for dataset metadata Useful as a cache of global min max values. Viewers rely on these for colorbars.
- class tvb.core.neotraits._h5accessors.Enum(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Scalar
- class tvb.core.neotraits._h5accessors.EquationScalar(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Accessor
An attribute in a h5 file that corresponds to a traited Equation.
- KEY_PARAMETERS = 'parameters'¶
- KEY_TYPE = 'type'¶
- class tvb.core.neotraits._h5accessors.Json(trait_attribute, h5file, name=None, json_encoder=None, json_decoder=None)[source]¶
Bases:
Scalar
A python json like data structure accessor This works with simple Attr(list) Attr(dict) List(of=…)
- class tvb.core.neotraits._h5accessors.JsonFinal(trait_attribute, h5file, name=None)[source]¶
Bases:
Json
A python json like data structure accessor meant to be used with Final(dict)
- class StateVariablesEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶
Bases:
JSONEncoder
- default(o)[source]¶
Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
- class tvb.core.neotraits._h5accessors.JsonRange(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Scalar
Stores and loads a Range in the form of a json in h5.
- class tvb.core.neotraits._h5accessors.Reference(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Uuid
A reference to another h5 file Corresponds to a contained datatype
- class tvb.core.neotraits._h5accessors.ReferenceList(trait_attribute, h5file, name=None, json_encoder=None, json_decoder=None)[source]¶
Bases:
Json
- class tvb.core.neotraits._h5accessors.Scalar(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Accessor
A scalar in a h5 file that corresponds to a traited attribute. Serialized as a global h5 attribute
- class tvb.core.neotraits._h5accessors.SparseMatrix(trait_attribute: Attr, h5file: H5File, name: str = None)[source]¶
Bases:
Accessor
Stores and loads a scipy.sparse csc or csr matrix in h5.
- constructors = {'csc': <class 'scipy.sparse._csc.csc_matrix'>, 'csr': <class 'scipy.sparse._csr.csr_matrix'>}¶
- class tvb.core.neotraits._h5accessors.SparseMatrixMetaData(minimum, maximum, mean, format, dtype, shape)[source]¶
Bases:
DataSetMetaData
Essential metadata for interpreting a sparse matrix stored in h5
_h5core
¶
- class tvb.core.neotraits._h5core.H5File(path: str)[source]¶
Bases:
object
A H5 based file format. This class implements reading and writing to a specific h5 based file format. A subclass of this defines a new file format.
- KEY_WRITTEN_BY = 'written_by'¶
- is_new_file = False¶
- load_generic_attributes() GenericAttributes [source]¶
- store(datatype: HasTraits, scalars_only: bool = False, store_references: bool = True) None [source]¶
- store_generic_attributes(generic_attributes: GenericAttributes, create: bool = True) None [source]¶
- class tvb.core.neotraits._h5core.ViewModelH5(path, view_model)[source]¶
Bases:
H5File
- gather_datatypes_references()[source]¶
Mind that ViewModelH5 stores references towards ViewModel objects (eg. Coupling) as Reference attributes, and references towards existent Datatypes (eg. Connectivity) as Uuid. Thus, the method gather_references will return only references towards other ViewModels, and we need this method to gather also datatypes references.
db
¶
forms
¶
- class tvb.core.neotraits.forms.ArrayField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
TraitField
- template = 'form_fields/str_field.html'¶
- property value¶
- class tvb.core.neotraits.forms.BoolField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
TraitField
- template = 'form_fields/bool_field.html'¶
- class tvb.core.neotraits.forms.DynamicSelectField(trait_attribute, name=None, disabled=False, choices=None, display_none_choice=True, subform=None, display_subform=True, ui_values=None)[source]¶
Bases:
TraitField
- missing_value = 'explicit-None-value'¶
- subform_prefix = 'subform_'¶
- template = 'form_fields/radio_field.html'¶
- property value¶
- class tvb.core.neotraits.forms.Field(name: str, disabled: bool = False, required: bool = False, label: str = '', doc: str = '', default: object | None = None)[source]¶
Bases:
object
- template = None¶
- property value¶
- class tvb.core.neotraits.forms.FloatField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
TraitField
- max = None¶
- min = None¶
- step = 'any'¶
- template = 'form_fields/number_field.html'¶
- class tvb.core.neotraits.forms.Form[source]¶
Bases:
object
- property fields¶
- fill_from_trait(trait)[source]¶
Sets data for all traited fields from a trait instance. Note that FormFields are not TraitFields, so this does not work recursively Override to fill in sub-forms
- fill_trait(datatype)[source]¶
Copies the value of the TraitFields to the corresponding Attr-ibutes of the given trait instance Note that FormFields are not TraitFields, so this does not work recursively Override to fill in sub-forms
- static get_subform_key()[source]¶
If the current form can be used as subform, this method should return the proper value.
- property trait_fields¶
- class tvb.core.neotraits.forms.FormField(form_class, name, label='', doc='')[source]¶
Bases:
Field
- template = 'form_fields/form_field.html'¶
- class tvb.core.neotraits.forms.HiddenField(trait_attribute, name=None, disabled=False)[source]¶
Bases:
TraitField
- template = 'form_fields/hidden_field.html'¶
- class tvb.core.neotraits.forms.IntField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
TraitField
- max = None¶
- min = None¶
- template = 'form_fields/number_field.html'¶
- class tvb.core.neotraits.forms.LabelField(trait_attribute, label_message=None, name=None)[source]¶
Bases:
TraitField
- template = 'form_fields/label_field.html'¶
- class tvb.core.neotraits.forms.MultiSelectField(trait_attribute, name=None, disabled=False)[source]¶
Bases:
TraitField
- template = 'form_fields/checkbox_field.html'¶
- class tvb.core.neotraits.forms.Option(id, value, label, checked)¶
Bases:
tuple
- checked¶
Alias for field number 3
- id¶
Alias for field number 0
- label¶
Alias for field number 2
- value¶
Alias for field number 1
- class tvb.core.neotraits.forms.SelectField(trait_attribute, name=None, disabled=False, display_none_choice=True, subform=None, display_subform=True, ui_values=None, session_key=None, form_key=None)[source]¶
Bases:
TraitField
- missing_value = 'explicit-None-value'¶
- subform_prefix = 'subform_'¶
- template = 'form_fields/radio_field.html'¶
- property value¶
- class tvb.core.neotraits.forms.StrField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
TraitField
- template = 'form_fields/str_field.html'¶
- class tvb.core.neotraits.forms.TraitDataTypeSelectField(trait_attribute, name=None, conditions=None, draw_dynamic_conditions_buttons=True, has_all_option=False, show_only_all_option=False)[source]¶
Bases:
TraitField
- property get_dynamic_filters¶
- property get_form_filters¶
- missing_value = 'explicit-None-value'¶
- template = 'form_fields/datatype_select_field.html'¶
- class tvb.core.neotraits.forms.TraitField(trait_attribute: Attr, name: str | None = None, disabled: bool = False)[source]¶
Bases:
Field
- class tvb.core.neotraits.forms.TraitUploadField(traited_attribute, required_type, name, disabled=False)[source]¶
Bases:
TraitField
- template = 'form_fields/upload_field.html'¶
- class tvb.core.neotraits.forms.UserSessionStrField(trait_attribute: Attr, name: str | None = None, disabled: bool = False, key: str | None = None)[source]¶
Bases:
TraitField
- template = 'form_fields/str_field.html'¶
h5
¶
spatial_model
¶
uploader_view_model
¶
- class tvb.core.neotraits.uploader_view_model.UploaderViewModel(**kwargs)[source]¶
Bases:
ViewModel
Traited class [tvb.core.neotraits.uploader_view_model.UploaderViewModel]¶
Attributes declared¶
data_subject : tvb.core.neotraits.uploader_view_model.UploaderViewModel.data_subject = Str(field_type=<class ‘str’>, default=’John Doe’, required=True)
- encrypted_aes_keytvb.core.neotraits.uploader_view_model.UploaderViewModel.encrypted_aes_key = Str(field_type=<class ‘str’>, default=None, required=False)
Check our demo notebook on how to produce this key and how we expect your files to be encrypted
operation_group_gid : tvb.core.neotraits.view_model.ViewModel.operation_group_gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=False)
ranges : tvb.core.neotraits.view_model.ViewModel.ranges = Attr(field_type=<class ‘str’>, default=None, required=False)
range_values : tvb.core.neotraits.view_model.ViewModel.range_values = Attr(field_type=<class ‘str’>, default=None, required=False)
is_metric_operation : tvb.core.neotraits.view_model.ViewModel.is_metric_operation = Attr(field_type=<class ‘bool’>, default=False, required=True)
gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)
- REQUIRED_TYPE = None¶
- data_subject¶
- encrypted_aes_key¶
view_model
¶
- class tvb.core.neotraits.view_model.DataTypeGidAttr(linked_datatype, field_type=<class 'uuid.UUID'>, filters=None, default=None, doc='', label='', required=True, final=False, choices=None)[source]¶
Bases:
Attr
Keep a GID but also link the type of DataType it should point to
- class tvb.core.neotraits.view_model.EquationAttr(field_type: type, default: Any | None = None, doc: str = '', label: str = '', required: bool = True, final: bool = False, choices: tuple | None = None)[source]¶
Bases:
Attr
# TODO: there are places where we need eq params as a nested form. Figure out a proper model
- class tvb.core.neotraits.view_model.Str(field_type=<class 'str'>, default=None, doc='', label='', required=True, final=False, choices=None)[source]¶
Bases:
Attr
- class tvb.core.neotraits.view_model.ViewModel(**kwargs)[source]¶
Bases:
HasTraits
Traited class [tvb.core.neotraits.view_model.ViewModel]¶
Attributes declared¶
operation_group_gid : tvb.core.neotraits.view_model.ViewModel.operation_group_gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=False)
ranges : tvb.core.neotraits.view_model.ViewModel.ranges = Attr(field_type=<class ‘str’>, default=None, required=False)
range_values : tvb.core.neotraits.view_model.ViewModel.range_values = Attr(field_type=<class ‘str’>, default=None, required=False)
is_metric_operation : tvb.core.neotraits.view_model.ViewModel.is_metric_operation = Attr(field_type=<class ‘bool’>, default=False, required=True)
gid : tvb.basic.neotraits._core.HasTraits.gid = Attr(field_type=<class ‘uuid.UUID’>, default=None, required=True)
- is_metric_operation¶
An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.
- operation_group_gid¶
An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.
- range_values¶
An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.
- ranges¶
An Attr declares the following about the attribute it describes: * the type * a default value shared by all instances * if the value might be missing * documentation It will resolve to attributes on the instance.