How to use io_attr method in autotest

Best Python code snippet using autotest_python

vtree.py

Source:vtree.py Github

copy

Full Screen

1"""2Variable meant to contain a VariableTree of a particular type.3"""4#public symbols5__all__ = ["VarTree"]6from traits.api import Instance7from openmdao.main.variable import Variable, gui_excludes8class VarTree(Variable):9 """ A Variable for a :class:`VariableTree` of a particular type. """10 def __init__(self, default_value, allow_none=True, **metadata):11 from openmdao.main.vartree import VariableTree # Break import loop on VariableTree12 if isinstance(default_value, VariableTree):13 klass = default_value.__class__14 if 'iotype' in metadata:15 default_value._iotype = metadata['iotype']16 else:17 metadata['iotype'] = default_value.iotype18 else:19 raise TypeError('default_value must be an instance of VariableTree'20 ' or subclass')21 metadata.setdefault('copy', 'deep')22 self._allow_none = allow_none23 self.klass = klass24 self._instance = Instance(klass=klass, allow_none=False, factory=None,25 args=None, kw=None, **metadata)26 self._instance.default_value = default_value27 super(VarTree, self).__init__(default_value, **metadata)28 def validate(self, obj, name, value):29 """ Validates that a specified value is valid for this trait. """30 if value is None:31 if self._allow_none:32 return value33 self.validate_failed(obj, name, value)34 try:35 value = self._instance.validate(obj, name, value)36 except Exception:37 obj.raise_exception('%r must be an instance of %s.%s, not %r' %38 (name, self._instance.klass.__module__,39 self._instance.klass.__name__, type(value)),40 TypeError)41 return value42 def post_setattr(self, obj, name, value):43 """ VariableTrees must know their place within the hierarchy, so set44 their parent here. This keeps side effects out of validate(). """45 if value.parent is not obj:46 value.parent = obj47 value.name = name48 value._iotype = self.iotype49 def get_attribute(self, name, value, trait, meta):50 """Return the attribute dictionary for this variable. This dict is51 used by the GUI to populate the edit UI. Slots also return an52 attribute dictionary for the slot pane.53 name: str54 Name of variable55 value: object56 The value of the variable57 trait: CTrait58 The variable's trait59 meta: dict60 Dictionary of metadata for this variable61 """62 io_attr = {}63 io_attr['name'] = name64 io_attr['type'] = trait.trait_type.klass.__name__65 io_attr['ttype'] = 'vartree'66 for field in meta:67 if field not in gui_excludes:68 io_attr[field] = meta[field]...

Full Screen

Full Screen

slot.py

Source:slot.py Github

copy

Full Screen

1"""2Trait for a Slot meant to contain an object of a particular type3or having a particular interface (either a Traits interface or a4zope.interface).5"""6# The regular Instance class that comes with Traits will only check public7# methods on an object if that object is not a HasTraits object, which means8# we get essentially no error checking for things like Case iterators where9# their API doesn't include any public methods. If we use zope.interface we10# don't have this problem.11#public symbols12__all__ = ["Slot"]13# pylint: disable-msg=E0611,F040114from openmdao.main.variable import gui_excludes15from openmdao.main.datatypes.instance import Base16import warnings17class Slot(Base):18 """A trait for an object of a particular type or implementing a particular19 interface. Both Traits Interfaces and zope.interface.Interfaces are20 supported.21 """22 def __init__(self, klass=object, allow_none=True, factory=None,23 args=None, kw=None, **metadata):24 if 'iotype' in metadata:25 warnings.warn(FutureWarning( \26 "The use of 'iotype' as metadata for 'Slot' will no longer be supported.\nUse 'Instance' in place of 'Slot' if you need to use 'iotype'.\n"), stacklevel=2)27 super(Slot, self).__init__(klass, allow_none, factory, args, kw, **metadata)28 def get_attribute(self, name, value, trait, meta):29 """Return the attribute dictionary for this variable. This dict is30 used by the GUI to populate the edit UI. Slots also return an31 attribute dictionary for the slot pane.32 name: str33 Name of variable34 value: object35 The value of the variable36 trait: CTrait37 The variable's trait38 meta: dict39 Dictionary of metadata for this variable40 """41 io_attr = {}42 io_attr['name'] = name43 io_attr['type'] = trait.trait_type.klass.__name__44 io_attr['ttype'] = 'slot'45 slot_attr = {}46 slot_attr['name'] = name47 if value is None:48 slot_attr['filled'] = None49 elif value is []:50 slot_attr['filled'] = []51 else:52 slot_attr['filled'] = type(value).__name__53 slot_attr['klass'] = io_attr['type']54 slot_attr['containertype'] = 'singleton'55 for field in meta:56 if field not in gui_excludes:57 slot_attr[field] = meta[field]58 io_attr[field] = meta[field]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful