file_path
stringlengths 21
207
| content
stringlengths 5
1.02M
| size
int64 5
1.02M
| lang
stringclasses 9
values | avg_line_length
float64 1.33
100
| max_line_length
int64 4
993
| alphanum_fraction
float64 0.27
0.93
|
---|---|---|---|---|---|---|
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBlendVariants.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBlendVariantsDatabase import OgnBlendVariantsDatabase
test_file_name = "OgnBlendVariantsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BlendVariants")
database = OgnBlendVariantsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:blend"))
attribute = test_node.get_attribute("inputs:blend")
db_value = database.inputs.blend
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:setVariant"))
attribute = test_node.get_attribute("inputs:setVariant")
db_value = database.inputs.setVariant
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantNameA"))
attribute = test_node.get_attribute("inputs:variantNameA")
db_value = database.inputs.variantNameA
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantNameB"))
attribute = test_node.get_attribute("inputs:variantNameB")
db_value = database.inputs.variantNameB
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 4,431 | Python | 49.942528 | 92 | 0.69262 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantString.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantStringDatabase import OgnConstantStringDatabase
test_file_name = "OgnConstantStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantString")
database = OgnConstantStringDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,937 | Python | 48.692306 | 93 | 0.700052 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetVariantNames.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetVariantNamesDatabase import OgnGetVariantNamesDatabase
test_file_name = "OgnGetVariantNamesTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetVariantNames")
database = OgnGetVariantNamesDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:variantNames"))
attribute = test_node.get_attribute("outputs:variantNames")
db_value = database.outputs.variantNames
| 2,338 | Python | 48.765956 | 94 | 0.702737 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimRelationship.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadPrimRelationshipDatabase import OgnReadPrimRelationshipDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_ReadPrimRelationship", "omni.graph.nodes.ReadPrimRelationship")
})
database = OgnReadPrimRelationshipDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:name"))
attribute = test_node.get_attribute("state:name")
db_value = database.state.name
self.assertTrue(test_node.get_attribute_exists("state:prim"))
attribute = test_node.get_attribute("state:prim")
db_value = database.state.prim
| 2,430 | Python | 45.749999 | 136 | 0.696708 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCopyAttr.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCopyAttrDatabase import OgnCopyAttrDatabase
test_file_name = "OgnCopyAttrTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CopyAttribute")
database = OgnCopyAttrDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:fullData"))
attribute = test_node.get_attribute("inputs:fullData")
db_value = database.inputs.fullData
self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames"))
attribute = test_node.get_attribute("inputs:inputAttrNames")
db_value = database.inputs.inputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames"))
attribute = test_node.get_attribute("inputs:outputAttrNames")
db_value = database.inputs.outputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_data"))
attribute = test_node.get_attribute("outputs_data")
db_value = database.outputs.data
| 2,751 | Python | 49.036363 | 92 | 0.696838 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrims.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadPrimsDatabase import OgnReadPrimsDatabase
test_file_name = "OgnReadPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrims")
database = OgnReadPrimsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:applySkelBinding"))
attribute = test_node.get_attribute("inputs:applySkelBinding")
db_value = database.inputs.applySkelBinding
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox"))
attribute = test_node.get_attribute("inputs:computeBoundingBox")
db_value = database.inputs.computeBoundingBox
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useFindPrims"))
attribute = test_node.get_attribute("inputs:useFindPrims")
db_value = database.inputs.useFindPrims
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primsBundle"))
attribute = test_node.get_attribute("outputs_primsBundle")
db_value = database.outputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("state:applySkelBinding"))
attribute = test_node.get_attribute("state:applySkelBinding")
db_value = database.state.applySkelBinding
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:primPaths"))
attribute = test_node.get_attribute("state:primPaths")
db_value = database.state.primPaths
self.assertTrue(test_node.get_attribute_exists("state:typePattern"))
attribute = test_node.get_attribute("state:typePattern")
db_value = database.state.typePattern
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
self.assertTrue(test_node.get_attribute_exists("state:useFindPrims"))
attribute = test_node.get_attribute("state:useFindPrims")
db_value = database.state.useFindPrims
| 6,424 | Python | 51.235772 | 92 | 0.700187 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadStageSelection.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadStageSelectionDatabase import OgnReadStageSelectionDatabase
test_file_name = "OgnReadStageSelectionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadStageSelection")
database = OgnReadStageSelectionDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:selectedPrims"))
attribute = test_node.get_attribute("outputs:selectedPrims")
db_value = database.outputs.selectedPrims
| 1,733 | Python | 48.542856 | 100 | 0.71206 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDivide.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'int64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 42.0}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 42.0}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'uint64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 42}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 42}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 42}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 42}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 42}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 42}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 42}, False],
['inputs:b', {'type': 'uint64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 42}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 42}, False],
['inputs:b', {'type': 'int64', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 21.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'half', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[]', 'value': [1.0, 2.0, 3.0]}, False],
['inputs:b', {'type': 'uint64[]', 'value': [2, 4, 6]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[]', 'value': [0.5, 0.5, 0.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'int[]', 'value': [2, 4, 6, 8]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[]', 'value': [0.5, 0.5, 0.5, 0.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
['inputs:b', {'type': 'int[]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[1.0, 2.0], [1.5, 2.0]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:b', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 9.223372036854776e+18}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 3}, False],
['inputs:b', {'type': 'uint', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 3}, False],
['inputs:b', {'type': 'half', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'int', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'half[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 10}, False],
['inputs:b', {'type': 'uchar', 'value': 2}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 5.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Divide", "omni.graph.nodes.Divide", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Divide","omni.graph.nodes.Divide", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Divide", "omni.graph.nodes.Divide", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Divide User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnDivideDatabase import OgnDivideDatabase
test_file_name = "OgnDivideTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Divide")
database = OgnDivideDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 15,695 | Python | 37.660098 | 185 | 0.409685 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantToken.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantTokenDatabase import OgnConstantTokenDatabase
test_file_name = "OgnConstantTokenTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantToken")
database = OgnConstantTokenDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,932 | Python | 48.564101 | 92 | 0.699275 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnClamp.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'int', 'value': 51038}, False],
['inputs:lower', {'type': 'int', 'value': -20}, False],
['inputs:upper', {'type': 'int', 'value': 5}, False],
],
'outputs': [
['outputs:result', {'type': 'int', 'value': 5}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [3.1415, -20.432, 50.762, -80.9, 5, 124]}, False],
['inputs:lower', {'type': 'float', 'value': -20}, False],
['inputs:upper', {'type': 'float', 'value': 50.4}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [3.1415, -20, 50.4, -20, 5, 50.4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [1, 5, -2.5, 62]}, False],
['inputs:lower', {'type': 'double[]', 'value': [3, -10, -5, -10]}, False],
['inputs:upper', {'type': 'double[]', 'value': [5, 3.5, -5, 2]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[]', 'value': [3, 3.5, -5, 2]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Clamp", "omni.graph.nodes.Clamp", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Clamp","omni.graph.nodes.Clamp", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Clamp", "omni.graph.nodes.Clamp", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Clamp User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnClampDatabase import OgnClampDatabase
test_file_name = "OgnClampTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Clamp")
database = OgnClampDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,046 | Python | 48 | 183 | 0.588783 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector4.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:tuple', {'type': 'float[4]', 'value': [42.0, 1.0, 2.0, 3.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 2.0}, False],
['outputs:w', {'type': 'float', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[4]', 'value': [42, -42, 5, -5]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
['outputs:z', {'type': 'int', 'value': 5}, False],
['outputs:w', {'type': 'int', 'value': -5}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'quatd[4]', 'value': [42.0, 1.0, 2.0, 3.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'double', 'value': 42.0}, False],
['outputs:y', {'type': 'double', 'value': 1.0}, False],
['outputs:z', {'type': 'double', 'value': 2.0}, False],
['outputs:w', {'type': 'double', 'value': 3.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector4", "omni.graph.nodes.BreakVector4", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector4","omni.graph.nodes.BreakVector4", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BreakVector4", "omni.graph.nodes.BreakVector4", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BreakVector4 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector4Database import OgnBreakVector4Database
test_file_name = "OgnBreakVector4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BreakVector4")
database = OgnBreakVector4Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,249 | Python | 48.528301 | 197 | 0.589065 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCrossProduct.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'half[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'half[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'half[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'float[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'float[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'double[3]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[3]', 'value': [-4, 8, -4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3][]', 'value': [[1, 2, 3], [10.2, 3.5, 7]]}, False],
['inputs:b', {'type': 'double[3][]', 'value': [[5, 6, 7], [5, 6.1, 4.2]]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[3][]', 'value': [[-4, 8, -4], [-28, -7.84, 44.72]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CrossProduct", "omni.graph.nodes.CrossProduct", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CrossProduct","omni.graph.nodes.CrossProduct", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_CrossProduct", "omni.graph.nodes.CrossProduct", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.CrossProduct User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCrossProductDatabase import OgnCrossProductDatabase
test_file_name = "OgnCrossProductTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CrossProduct")
database = OgnCrossProductDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,276 | Python | 47.412844 | 197 | 0.579416 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetMatrix4Quaternion.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False],
],
'outputs': [
['outputs:quaternion', {'type': 'quatd[4]', 'value': [0.38268481, 0, 0, 0.9238804]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:quaternion', {'type': 'quatd[4][]', 'value': [[0.38268481, 0, 0, 0.9238804], [0.38268481, 0, 0, 0.9238804]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Quaternion", "omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Quaternion","omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_GetMatrix4Quaternion", "omni.graph.nodes.GetMatrix4Quaternion", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.GetMatrix4Quaternion User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetMatrix4QuaternionDatabase import OgnGetMatrix4QuaternionDatabase
test_file_name = "OgnGetMatrix4QuaternionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetMatrix4Quaternion")
database = OgnGetMatrix4QuaternionDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,777 | Python | 52.685393 | 235 | 0.637429 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMoveToTarget.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMoveToTargetDatabase import OgnMoveToTargetDatabase
test_file_name = "OgnMoveToTargetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MoveToTarget")
database = OgnMoveToTargetDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:useSourcePath"))
attribute = test_node.get_attribute("inputs:useSourcePath")
db_value = database.inputs.useSourcePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useTargetPath"))
attribute = test_node.get_attribute("inputs:useTargetPath")
db_value = database.inputs.useTargetPath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
| 3,801 | Python | 49.693333 | 92 | 0.694028 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCreateTubeTopology.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:rows', [1, 2, 3], False],
['inputs:cols', [2, 3, 4], False],
],
'outputs': [
['outputs:faceVertexCounts', [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4], False],
['outputs:faceVertexIndices', [0, 1, 3, 2, 1, 0, 2, 3, 4, 5, 8, 7, 5, 6, 9, 8, 6, 4, 7, 9, 7, 8, 11, 10, 8, 9, 12, 11, 9, 7, 10, 12, 13, 14, 18, 17, 14, 15, 19, 18, 15, 16, 20, 19, 16, 13, 17, 20, 17, 18, 22, 21, 18, 19, 23, 22, 19, 20, 24, 23, 20, 17, 21, 24, 21, 22, 26, 25, 22, 23, 27, 26, 23, 24, 28, 27, 24, 21, 25, 28], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CreateTubeTopology", "omni.graph.nodes.CreateTubeTopology", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_CreateTubeTopology","omni.graph.nodes.CreateTubeTopology", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_CreateTubeTopology", "omni.graph.nodes.CreateTubeTopology", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.CreateTubeTopology User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCreateTubeTopologyDatabase import OgnCreateTubeTopologyDatabase
test_file_name = "OgnCreateTubeTopologyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CreateTubeTopology")
database = OgnCreateTubeTopologyDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:cols"))
attribute = test_node.get_attribute("inputs:cols")
db_value = database.inputs.cols
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:rows"))
attribute = test_node.get_attribute("inputs:rows")
db_value = database.inputs.rows
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:faceVertexCounts"))
attribute = test_node.get_attribute("outputs:faceVertexCounts")
db_value = database.outputs.faceVertexCounts
self.assertTrue(test_node.get_attribute_exists("outputs:faceVertexIndices"))
attribute = test_node.get_attribute("outputs:faceVertexIndices")
db_value = database.outputs.faceVertexIndices
| 5,763 | Python | 52.869158 | 349 | 0.661635 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEndsWith.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', "", False],
['inputs:suffix', "", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "a", False],
['inputs:suffix', "", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "", False],
['inputs:suffix', "a", False],
],
'outputs': [
['outputs:isSuffix', False, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:suffix', "a", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "ab", False],
['inputs:suffix', "ab", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:suffix', "aaa", False],
],
'outputs': [
['outputs:isSuffix', False, False],
],
},
{
'inputs': [
['inputs:value', "aba", False],
['inputs:suffix', "ba", False],
],
'outputs': [
['outputs:isSuffix', True, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EndsWith", "omni.graph.nodes.EndsWith", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EndsWith","omni.graph.nodes.EndsWith", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_EndsWith", "omni.graph.nodes.EndsWith", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.EndsWith User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnEndsWithDatabase import OgnEndsWithDatabase
test_file_name = "OgnEndsWithTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_EndsWith")
database = OgnEndsWithDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:suffix"))
attribute = test_node.get_attribute("inputs:suffix")
db_value = database.inputs.suffix
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:isSuffix"))
attribute = test_node.get_attribute("outputs:isSuffix")
db_value = database.outputs.isSuffix
| 6,455 | Python | 40.384615 | 189 | 0.58141 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnScaleToSize.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnScaleToSizeDatabase import OgnScaleToSizeDatabase
test_file_name = "OgnScaleToSizeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ScaleToSize")
database = OgnScaleToSizeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:target"))
attribute = test_node.get_attribute("inputs:target")
db_value = database.inputs.target
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
| 3,767 | Python | 49.239999 | 92 | 0.688877 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantTexCoord2h.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantTexCoord2hDatabase import OgnConstantTexCoord2hDatabase
test_file_name = "OgnConstantTexCoord2hTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantTexCoord2h")
database = OgnConstantTexCoord2hDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,965 | Python | 49.410255 | 100 | 0.70229 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomNumeric.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6649909271, False],
['inputs:min', {'type': 'uint', 'value': 0}, False],
['inputs:max', {'type': 'uint', 'value': 4294967295}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6159018942, False],
['inputs:min', {'type': 'uint[]', 'value': [0, 100]}, False],
['inputs:max', {'type': 'uint', 'value': 4294967295}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint[]', 'value': [2147483648, 2160101208]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 3280530163, False],
['inputs:min', {'type': 'uint', 'value': 0}, False],
['inputs:max', {'type': 'uint[]', 'value': [4294967295, 199]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint[]', 'value': [4294967295, 19]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6159018942, False],
['inputs:min', {'type': 'int', 'value': -2147483648}, False],
['inputs:max', {'type': 'int', 'value': 2147483647}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 6649909271, False],
['inputs:min', {'type': 'int[2]', 'value': [-2147483648, -100]}, False],
['inputs:max', {'type': 'int', 'value': 2147483647}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int[2]', 'value': [-2147483648, 1629773655]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 3280530163, False],
['inputs:min', {'type': 'int', 'value': -2147483648}, False],
['inputs:max', {'type': 'int[2]', 'value': [2147483647, 99]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'int[2]', 'value': [2147483647, -2146948710]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 8280086, False],
['inputs:min', {'type': 'float', 'value': 0}, False],
['inputs:max', {'type': 'float', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 17972581, False],
['inputs:min', {'type': 'float[]', 'value': [0, -10]}, False],
['inputs:max', {'type': 'float', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [0.5, -6.7663326]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 15115159, False],
['inputs:min', {'type': 'float', 'value': 0}, False],
['inputs:max', {'type': 'float[]', 'value': [1, 10]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [0.9999999403953552, 4.0452986]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 14092058508772706262, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 9302349107990861236, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 9223372036854775808}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 1955209015103813879, False],
['inputs:min', {'type': 'uint64', 'value': 0}, False],
['inputs:max', {'type': 'uint64', 'value': 18446744073709551615}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 18446744073709551615}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:min', {'type': 'uint64', 'value': 1099511627776}, False],
['inputs:max', {'type': 'uint64', 'value': 1125899906842624}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uint64', 'value': 923489197424953}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 1955209015103813879, False],
['inputs:min', {'type': 'double[2][]', 'value': [[0, -10], [10, 0]]}, False],
['inputs:max', {'type': 'double', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double[2][]', 'value': [[0, 0.28955788], [7.98645811, 0.09353537]]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:min', {'type': 'half[]', 'value': [0, -100]}, False],
['inputs:max', {'type': 'half[]', 'value': [1, 100]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'half[]', 'value': [0.17993164, -76.375]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 0, False],
['inputs:min', {'type': 'uchar[]', 'value': [0, 100]}, False],
['inputs:max', {'type': 'uchar[]', 'value': [255, 200]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'uchar[]', 'value': [153, 175]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 9302349107990861236, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double', 'value': 0.5}, False],
['outputs:execOut', 1, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomNumeric", "omni.graph.nodes.RandomNumeric", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomNumeric","omni.graph.nodes.RandomNumeric", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomNumeric", "omni.graph.nodes.RandomNumeric", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomNumeric User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomNumericDatabase import OgnRandomNumericDatabase
test_file_name = "OgnRandomNumericTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomNumeric")
database = OgnRandomNumericDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:isNoise"))
attribute = test_node.get_attribute("inputs:isNoise")
db_value = database.inputs.isNoise
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useSeed"))
attribute = test_node.get_attribute("inputs:useSeed")
db_value = database.inputs.useSeed
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:gen"))
attribute = test_node.get_attribute("state:gen")
db_value = database.state.gen
| 15,030 | Python | 43.602374 | 199 | 0.499135 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMagnitude.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'double', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half', 'value': -10.0}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int', 'value': -10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64', 'value': -10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uchar', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64', 'value': 10}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[2]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 5.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3]', 'value': [1.0, 2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[4]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float', 'value': 4.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[2]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half', 'value': 5.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float[]', 'value': [2.0, 2.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half[]', 'value': [3.0, 4.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'int64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[3][]', 'value': [[1, 2, 2], [4, 2, 6], [3, 2, 4], [1, -4, 2]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [3.0, 7.483314773547883, 5.385164807134504, 4.58257569495584]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'double[]', 'value': [3.0, 7.483314773547883, 5.385164807134504, 4.58257569495584]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'float[]', 'value': [3.0, 7.483315, 5.3851647, 4.582576]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:magnitude', {'type': 'half[]', 'value': [3.0, 7.484375, 5.3867188, 4.5820312]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Magnitude", "omni.graph.nodes.Magnitude", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Magnitude","omni.graph.nodes.Magnitude", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Magnitude", "omni.graph.nodes.Magnitude", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Magnitude User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMagnitudeDatabase import OgnMagnitudeDatabase
test_file_name = "OgnMagnitudeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Magnitude")
database = OgnMagnitudeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 10,491 | Python | 38.592453 | 191 | 0.455152 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGatherByPath.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
import os
class TestOgn(ogts.OmniGraphTestCase):
async def test_generated(self):
test_data = [{'inputs': [['inputs:primPaths', ['/Xform1', '/Xform2'], False], ['inputs:attributes', '_translate', False], ['inputs:allAttributes', False, False]], 'outputs': [['outputs:gatheredPaths', ['/Xform1', '/Xform2'], False], ['outputs:gatherId', 1, False]], 'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.GatherByPath']], 'create_prims': [['Empty', {}], ['Xform1', {'_translate': ['pointd[3]', [1, 2, 3]]}], ['Xform2', {'_translate': ['pointd[3]', [4, 5, 6]]}], ['XformTagged1', {'foo': ['token', ''], '_translate': ['pointd[3]', [1, 2, 3]]}], ['Tagged1', {'foo': ['token', '']}]]}}, {'inputs': [['inputs:primPaths', ['/XformTagged1', '/Xform2', '/Xform1'], False], ['inputs:attributes', '_translate', False], ['inputs:allAttributes', False, False]], 'outputs': [['outputs:gatheredPaths', ['/XformTagged1', '/Xform1', '/Xform2'], False]], 'setup': {}}]
test_node = None
test_graph = None
for i, test_run in enumerate(test_data):
inputs = test_run.get('inputs', [])
outputs = test_run.get('outputs', [])
state_set = test_run.get('state_set', [])
state_get = test_run.get('state_get', [])
setup = test_run.get('setup', None)
if setup is None or setup:
await omni.usd.get_context().new_stage_async()
test_graph = None
elif not setup:
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test is misconfigured - empty setup cannot be in the first test")
if setup:
(test_graph, test_nodes, _, _) = og.Controller.edit("/TestGraph", setup)
self.assertTrue(test_nodes)
test_node = test_nodes[0]
elif setup is None:
if test_graph is None:
test_graph = og.Controller.create_graph("/TestGraph")
self.assertTrue(test_graph is not None and test_graph.is_valid())
test_node = og.Controller.create_node(
("TestNode_omni_graph_nodes_GatherByPath", test_graph), "omni.graph.nodes.GatherByPath"
)
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test graph invalid")
self.assertTrue(test_node is not None and test_node.is_valid(), "Test node invalid")
await og.Controller.evaluate(test_graph)
values_to_set = inputs + state_set
if values_to_set:
for attribute_name, attribute_value, _ in inputs + state_set:
og.Controller((attribute_name, test_node)).set(attribute_value)
await og.Controller.evaluate(test_graph)
for attribute_name, expected_value, _ in outputs + state_get:
attribute = og.Controller.attribute(attribute_name, test_node)
actual_output = og.Controller.get(attribute)
expected_type = None
if isinstance(expected_value, dict):
expected_type = expected_value["type"]
expected_value = expected_value["value"]
ogts.verify_values(expected_value, actual_output, f"omni.graph.nodes.GatherByPath User test case #{i+1}: {attribute_name} attribute value error")
if expected_type:
tp = og.AttributeType.type_from_ogn_type_name(expected_type)
actual_type = attribute.get_resolved_type()
if tp != actual_type:
raise ValueError(f"omni.graph.nodes.GatherByPath User tests - {attribute_name}: Expected {expected_type}, saw {actual_type.get_ogn_type_name()}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGatherByPathDatabase import OgnGatherByPathDatabase
test_file_name = "OgnGatherByPathTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GatherByPath")
database = OgnGatherByPathDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:allAttributes"))
attribute = test_node.get_attribute("inputs:allAttributes")
db_value = database.inputs.allAttributes
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attributes"))
attribute = test_node.get_attribute("inputs:attributes")
db_value = database.inputs.attributes
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:checkResyncAttributes"))
attribute = test_node.get_attribute("inputs:checkResyncAttributes")
db_value = database.inputs.checkResyncAttributes
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:forceExportToHistory"))
attribute = test_node.get_attribute("inputs:forceExportToHistory")
db_value = database.inputs.forceExportToHistory
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:hydraFastPath"))
attribute = test_node.get_attribute("inputs:hydraFastPath")
db_value = database.inputs.hydraFastPath
expected_value = "Disabled"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primPaths"))
attribute = test_node.get_attribute("inputs:primPaths")
db_value = database.inputs.primPaths
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:shouldWriteBack"))
attribute = test_node.get_attribute("inputs:shouldWriteBack")
db_value = database.inputs.shouldWriteBack
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:gatherId"))
attribute = test_node.get_attribute("outputs:gatherId")
db_value = database.outputs.gatherId
self.assertTrue(test_node.get_attribute_exists("outputs:gatheredPaths"))
attribute = test_node.get_attribute("outputs:gatheredPaths")
db_value = database.outputs.gatheredPaths
| 8,500 | Python | 60.158273 | 879 | 0.639529 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPoint3d.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantPoint3dDatabase import OgnConstantPoint3dDatabase
test_file_name = "OgnConstantPoint3dTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPoint3d")
database = OgnConstantPoint3dDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,955 | Python | 49.153845 | 94 | 0.699233 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnModulo.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 4}, False],
['inputs:b', {'type': 'uint64', 'value': 3}, False],
],
'outputs': [
['outputs:result', {'type': 'uint64', 'value': 1}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 4}, False],
['inputs:b', {'type': 'int', 'value': 0}, False],
],
'outputs': [
['outputs:result', {'type': 'int', 'value': 0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Modulo", "omni.graph.nodes.Modulo", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Modulo","omni.graph.nodes.Modulo", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Modulo", "omni.graph.nodes.Modulo", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Modulo User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnModuloDatabase import OgnModuloDatabase
test_file_name = "OgnModuloTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Modulo")
database = OgnModuloDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,358 | Python | 46.901098 | 185 | 0.621156 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantDoubleDatabase import OgnConstantDoubleDatabase
test_file_name = "OgnConstantDoubleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble")
database = OgnConstantDoubleDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,938 | Python | 48.717947 | 93 | 0.700722 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrims.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWritePrimsDatabase import OgnWritePrimsDatabase
test_file_name = "OgnWritePrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrims")
database = OgnWritePrimsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToExport"))
attribute = test_node.get_attribute("inputs:attrNamesToExport")
db_value = database.inputs.attrNamesToExport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primsBundle"))
attribute = test_node.get_attribute("inputs:primsBundle")
db_value = database.inputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 3,843 | Python | 50.253333 | 92 | 0.69555 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetParentPrims.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetParentPrimsDatabase import OgnGetParentPrimsDatabase
test_file_name = "OgnGetParentPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetParentPrims")
database = OgnGetParentPrimsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("outputs:parentPrims"))
attribute = test_node.get_attribute("outputs:parentPrims")
db_value = database.outputs.parentPrims
| 1,881 | Python | 47.256409 | 93 | 0.704413 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
['inputs:y', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2]', 'value': [42.0, 1.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2]', 'value': [42.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False],
['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[2][]', 'value': [[42, 0], [1, 1], [0, 2]]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'int', 'value': 42}, False],
['inputs:y', {'type': 'int', 'value': -42}, False],
],
'outputs': [
['outputs:tuple', {'type': 'int[2]', 'value': [42, -42]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector2", "omni.graph.nodes.MakeVector2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector2","omni.graph.nodes.MakeVector2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector2", "omni.graph.nodes.MakeVector2", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector2 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeVector2Database import OgnMakeVector2Database
test_file_name = "OgnMakeVector2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector2")
database = OgnMakeVector2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,071 | Python | 45.962963 | 195 | 0.586866 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimer.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTimerDatabase import OgnTimerDatabase
test_file_name = "OgnTimerTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Timer")
database = OgnTimerDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:duration"))
attribute = test_node.get_attribute("inputs:duration")
db_value = database.inputs.duration
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:endValue"))
attribute = test_node.get_attribute("inputs:endValue")
db_value = database.inputs.endValue
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:play"))
attribute = test_node.get_attribute("inputs:play")
db_value = database.inputs.play
self.assertTrue(test_node.get_attribute_exists("inputs:startValue"))
attribute = test_node.get_attribute("inputs:startValue")
db_value = database.inputs.startValue
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
self.assertTrue(test_node.get_attribute_exists("outputs:updated"))
attribute = test_node.get_attribute("outputs:updated")
db_value = database.outputs.updated
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
| 3,495 | Python | 48.239436 | 92 | 0.689843 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimRelationship.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWritePrimRelationshipDatabase import OgnWritePrimRelationshipDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_WritePrimRelationship", "omni.graph.nodes.WritePrimRelationship")
})
database = OgnWritePrimRelationshipDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = True
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:name"))
attribute = test_node.get_attribute("state:name")
db_value = database.state.name
self.assertTrue(test_node.get_attribute_exists("state:prim"))
attribute = test_node.get_attribute("state:prim")
db_value = database.state.prim
| 3,101 | Python | 45.999999 | 138 | 0.694937 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimsV2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadPrimsV2Database import OgnReadPrimsV2Database
test_file_name = "OgnReadPrimsV2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrimsV2")
database = OgnReadPrimsV2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:_debugStamp"))
attribute = test_node.get_attribute("inputs:_debugStamp")
db_value = database.inputs._debugStamp
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:applySkelBinding"))
attribute = test_node.get_attribute("inputs:applySkelBinding")
db_value = database.inputs.applySkelBinding
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:computeBoundingBox"))
attribute = test_node.get_attribute("inputs:computeBoundingBox")
db_value = database.inputs.computeBoundingBox
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:enableBundleChangeTracking"))
attribute = test_node.get_attribute("inputs:enableBundleChangeTracking")
db_value = database.inputs.enableBundleChangeTracking
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:enableChangeTracking"))
attribute = test_node.get_attribute("inputs:enableChangeTracking")
db_value = database.inputs.enableChangeTracking
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primsBundle"))
attribute = test_node.get_attribute("outputs_primsBundle")
db_value = database.outputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("state:applySkelBinding"))
attribute = test_node.get_attribute("state:applySkelBinding")
db_value = database.state.applySkelBinding
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
self.assertTrue(test_node.get_attribute_exists("state:enableBundleChangeTracking"))
attribute = test_node.get_attribute("state:enableBundleChangeTracking")
db_value = database.state.enableBundleChangeTracking
self.assertTrue(test_node.get_attribute_exists("state:enableChangeTracking"))
attribute = test_node.get_attribute("state:enableChangeTracking")
db_value = database.state.enableChangeTracking
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:typePattern"))
attribute = test_node.get_attribute("state:typePattern")
db_value = database.state.typePattern
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
| 7,639 | Python | 52.426573 | 92 | 0.70415 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveFrame.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCurveFrameDatabase import OgnCurveFrameDatabase
test_file_name = "OgnCurveFrameTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CurveToFrame")
database = OgnCurveFrameDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:out"))
attribute = test_node.get_attribute("outputs:out")
db_value = database.outputs.out
self.assertTrue(test_node.get_attribute_exists("outputs:tangent"))
attribute = test_node.get_attribute("outputs:tangent")
db_value = database.outputs.tangent
self.assertTrue(test_node.get_attribute_exists("outputs:up"))
attribute = test_node.get_attribute("outputs:up")
db_value = database.outputs.up
| 3,381 | Python | 49.477611 | 92 | 0.695356 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantFloat2Database import OgnConstantFloat2Database
test_file_name = "OgnConstantFloat2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat2")
database = OgnConstantFloat2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,945 | Python | 48.897435 | 93 | 0.699229 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimAttribute.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadPrimAttributeDatabase import OgnReadPrimAttributeDatabase
(_, (test_node,), _, _) = og.Controller.edit("/TestGraph", {
og.Controller.Keys.CREATE_NODES: ("Template_omni_graph_nodes_ReadPrimAttribute", "omni.graph.nodes.ReadPrimAttribute")
})
database = OgnReadPrimAttributeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:importPath"))
attribute = test_node.get_attribute("state:importPath")
db_value = database.state.importPath
self.assertTrue(test_node.get_attribute_exists("state:srcAttrib"))
attribute = test_node.get_attribute("state:srcAttrib")
db_value = database.state.srcAttrib
self.assertTrue(test_node.get_attribute_exists("state:srcPath"))
attribute = test_node.get_attribute("state:srcPath")
db_value = database.state.srcPath
self.assertTrue(test_node.get_attribute_exists("state:srcPathAsToken"))
attribute = test_node.get_attribute("state:srcPathAsToken")
db_value = database.state.srcPathAsToken
self.assertTrue(test_node.get_attribute_exists("state:time"))
attribute = test_node.get_attribute("state:time")
db_value = database.state.time
| 3,252 | Python | 46.838235 | 130 | 0.696187 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayIndex.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [42]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 42}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'float[2][]', 'value': [[1.0, 2.0]]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:value', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', -1, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 3}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', -2, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [1, 2, 3]}, False],
['inputs:index', 2, False],
],
'outputs': [
['outputs:value', {'type': 'int', 'value': 3}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['foo', 'bar']}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'token', 'value': 'bar'}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, False, False]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'pointd[3][]', 'value': [[1, 2, 3], [4, 5, 6]]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:value', {'type': 'pointd[3]', 'value': [4, 5, 6]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayIndex", "omni.graph.nodes.ArrayIndex", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayIndex","omni.graph.nodes.ArrayIndex", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayIndex", "omni.graph.nodes.ArrayIndex", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayIndex User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayIndexDatabase import OgnArrayIndexDatabase
test_file_name = "OgnArrayIndexTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayIndex")
database = OgnArrayIndexDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:index"))
attribute = test_node.get_attribute("inputs:index")
db_value = database.inputs.index
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 6,931 | Python | 41.790123 | 193 | 0.536863 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTranslateToTarget.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTranslateToTargetDatabase import OgnTranslateToTargetDatabase
test_file_name = "OgnTranslateToTargetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_TranslateToTarget")
database = OgnTranslateToTargetDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:stop"))
attribute = test_node.get_attribute("inputs:stop")
db_value = database.inputs.stop
self.assertTrue(test_node.get_attribute_exists("inputs:useSourcePath"))
attribute = test_node.get_attribute("inputs:useSourcePath")
db_value = database.inputs.useSourcePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useTargetPath"))
attribute = test_node.get_attribute("inputs:useTargetPath")
db_value = database.inputs.useTargetPath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:finished"))
attribute = test_node.get_attribute("outputs:finished")
db_value = database.outputs.finished
| 3,826 | Python | 50.026666 | 98 | 0.696027 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector3.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
['inputs:y', {'type': 'float', 'value': 1.0}, False],
['inputs:z', {'type': 'float', 'value': 0.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3]', 'value': [42.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False],
['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False],
['inputs:z', {'type': 'float[]', 'value': [0, 2, 4]}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[3][]', 'value': [[42, 0, 0], [1, 1, 2], [0, 2, 4]]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'int', 'value': 42}, False],
['inputs:y', {'type': 'int', 'value': -42}, False],
['inputs:z', {'type': 'int', 'value': 5}, False],
],
'outputs': [
['outputs:tuple', {'type': 'int[3]', 'value': [42, -42, 5]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'double', 'value': 42.0}, False],
['inputs:y', {'type': 'double', 'value': 1.0}, False],
['inputs:z', {'type': 'double', 'value': 0.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'pointd[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.MakeVector3'], ['ConstPoint3d', 'omni.graph.nodes.ConstantPoint3d']], 'connect': [['TestNode.outputs:tuple', 'ConstPoint3d.inputs:value']]} },
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector3", "omni.graph.nodes.MakeVector3", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector3","omni.graph.nodes.MakeVector3", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector3", "omni.graph.nodes.MakeVector3", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector3 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeVector3Database import OgnMakeVector3Database
test_file_name = "OgnMakeVector3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector3")
database = OgnMakeVector3Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,922 | Python | 47.950413 | 219 | 0.565181 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWriteVariable.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWriteVariableDatabase import OgnWriteVariableDatabase
test_file_name = "OgnWriteVariableTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_core_WriteVariable")
database = OgnWriteVariableDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:variableName"))
attribute = test_node.get_attribute("inputs:variableName")
db_value = database.inputs.variableName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,312 | Python | 48.212765 | 92 | 0.699394 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayFindValue.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOO'}, False],
],
'outputs': [
['outputs:index', -1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOOD'}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int64', 'value': 41}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uchar', 'value': 41}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint64', 'value': 42}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:value', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, False],
['inputs:value', {'type': 'double[3]', 'value': [3, 4, 5]}, False],
],
'outputs': [
['outputs:index', 1, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False],
['inputs:value', {'type': 'int[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:index', 0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFindValue", "omni.graph.nodes.ArrayFindValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayFindValue","omni.graph.nodes.ArrayFindValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayFindValue", "omni.graph.nodes.ArrayFindValue", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayFindValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayFindValueDatabase import OgnArrayFindValueDatabase
test_file_name = "OgnArrayFindValueTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayFindValue")
database = OgnArrayFindValueDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:index"))
attribute = test_node.get_attribute("outputs:index")
db_value = database.outputs.index
| 7,755 | Python | 40.924324 | 201 | 0.50922 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMultiply.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:product', {'type': 'float', 'value': 84.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double[2]', 'value': [2.0, 1.0]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2]', 'value': [2.0, 42.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [1.0, 42.0]}, False],
['inputs:b', {'type': 'double', 'value': 2.0}, False],
],
'outputs': [
['outputs:product', {'type': 'double[]', 'value': [2.0, 84.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double[2]', 'value': [5, 5]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2][]', 'value': [[50, 25], [5, 5]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double', 'value': 2}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2][]', 'value': [[20, 10], [2, 2]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2]', 'value': [10, 5]}, False],
['inputs:b', {'type': 'double', 'value': 2}, False],
],
'outputs': [
['outputs:product', {'type': 'double[2]', 'value': [20, 10]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Multiply", "omni.graph.nodes.Multiply", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Multiply","omni.graph.nodes.Multiply", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Multiply", "omni.graph.nodes.Multiply", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Multiply User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMultiplyDatabase import OgnMultiplyDatabase
test_file_name = "OgnMultiplyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Multiply")
database = OgnMultiplyDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,835 | Python | 44.952756 | 189 | 0.5515 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineLoop.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTimelineLoopDatabase import OgnTimelineLoopDatabase
test_file_name = "OgnTimelineLoopTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_LoopTimeline")
database = OgnTimelineLoopDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:loop"))
attribute = test_node.get_attribute("inputs:loop")
db_value = database.inputs.loop
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,287 | Python | 47.68085 | 92 | 0.696983 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:tuple', {'type': 'float[2]', 'value': [42.0, 1.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[2]', 'value': [42, -42]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector2", "omni.graph.nodes.BreakVector2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BreakVector2","omni.graph.nodes.BreakVector2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BreakVector2", "omni.graph.nodes.BreakVector2", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BreakVector2 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector2Database import OgnBreakVector2Database
test_file_name = "OgnBreakVector2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BreakVector2")
database = OgnBreakVector2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,471 | Python | 48.142857 | 197 | 0.626705 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSelectIf.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 1.0}, False],
['inputs:ifFalse', {'type': 'float', 'value': 3.0}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 1.0}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 1.0}, False],
['inputs:ifFalse', {'type': 'float', 'value': 3.0}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[]', 'value': [10.0, 20.0]}, False],
['inputs:ifFalse', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [10.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[]', 'value': [10.0, 20.0]}, False],
['inputs:ifFalse', {'type': 'float', 'value': 99}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [10.0, 99]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float', 'value': 99}, False],
['inputs:ifFalse', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [99, 2.0]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'float[2][]', 'value': [[1, 1], [2, 2]]}, False],
['inputs:ifFalse', {'type': 'float[2][]', 'value': [[3, 3], [4, 4]]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[1, 1], [4, 4]]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'string', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'string', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'string', 'value': 'abc'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'string', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'string', 'value': 'efg'}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'string', 'value': 'efg'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'uchar[]', 'value': [61, 62, 63]}, False],
['inputs:ifFalse', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'uchar[]', 'value': [61, 62, 63]}, False],
['inputs:ifFalse', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False, True]}, False],
],
'outputs': [
['outputs:result', {'type': 'uchar[]', 'value': [61, 66, 63]}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'token', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', {'type': 'token', 'value': 'abc'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token', 'value': 'abc'}, False],
['inputs:ifFalse', {'type': 'token', 'value': 'efghi'}, False],
['inputs:condition', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', {'type': 'token', 'value': 'efghi'}, False],
],
},
{
'inputs': [
['inputs:ifTrue', {'type': 'token[]', 'value': ['ab', 'cd']}, False],
['inputs:ifFalse', {'type': 'token[]', 'value': ['ef', 'gh']}, False],
['inputs:condition', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:result', {'type': 'token[]', 'value': ['ab', 'gh']}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SelectIf", "omni.graph.nodes.SelectIf", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SelectIf","omni.graph.nodes.SelectIf", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SelectIf", "omni.graph.nodes.SelectIf", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SelectIf User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSelectIfDatabase import OgnSelectIfDatabase
test_file_name = "OgnSelectIfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SelectIf")
database = OgnSelectIfDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 9,366 | Python | 45.142857 | 189 | 0.493701 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCos.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 45.0}, False],
],
'outputs': [
['outputs:value', {'type': 'float', 'value': 0.707107}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 120.0}, False],
],
'outputs': [
['outputs:value', {'type': 'double', 'value': -0.5}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Cos", "omni.graph.nodes.Cos", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Cos","omni.graph.nodes.Cos", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Cos", "omni.graph.nodes.Cos", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Cos User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCosDatabase import OgnCosDatabase
test_file_name = "OgnCosTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Cos")
database = OgnCosDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,208 | Python | 46.292134 | 179 | 0.625951 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantDouble2Database import OgnConstantDouble2Database
test_file_name = "OgnConstantDouble2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantDouble2")
database = OgnConstantDouble2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,950 | Python | 49.02564 | 94 | 0.7 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeTransform.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:rotationXYZ', [0, 0, 0], False],
['inputs:translation', [0, 0, 0], False],
],
'outputs': [
['outputs:transform', [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], False],
],
},
{
'inputs': [
['inputs:rotationXYZ', [0, 0, 0], False],
['inputs:translation', [1, 2, 3], False],
],
'outputs': [
['outputs:transform', [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 2, 3, 1], False],
],
},
{
'inputs': [
['inputs:rotationXYZ', [20, 0, 30], False],
['inputs:translation', [1, -2, 3], False],
],
'outputs': [
['outputs:transform', [0.866025404, 0.5, 4.16333634e-17, 0.0, -0.46984631, 0.813797681, 0.342020143, 0.0, 0.171010072, -0.296198133, 0.939692621, 0.0, 1.0, -2.0, 3.0, 1.0], False],
],
},
{
'inputs': [
['inputs:scale', [10, 5, 2], False],
],
'outputs': [
['outputs:transform', [10, 0, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1], False],
],
},
{
'inputs': [
['inputs:translation', [1, -2, 3], False],
['inputs:rotationXYZ', [20, 0, 30], False],
['inputs:scale', [10, 5, 2], False],
],
'outputs': [
['outputs:transform', [8.66025404, 5.0, 0.0, 0.0, -2.34923155, 4.06898841, 1.71010072, 0.0, 0.34202014, -0.59239627, 1.87938524, 0.0, 1.0, -2.0, 3.0, 1.0], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransform", "omni.graph.nodes.MakeTransform", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeTransform","omni.graph.nodes.MakeTransform", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeTransform", "omni.graph.nodes.MakeTransform", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeTransform User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeTransformDatabase import OgnMakeTransformDatabase
test_file_name = "OgnMakeTransformTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeTransform")
database = OgnMakeTransformDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:rotationXYZ"))
attribute = test_node.get_attribute("inputs:rotationXYZ")
db_value = database.inputs.rotationXYZ
expected_value = [0, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:scale"))
attribute = test_node.get_attribute("inputs:scale")
db_value = database.inputs.scale
expected_value = [1, 1, 1]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:translation"))
attribute = test_node.get_attribute("inputs:translation")
db_value = database.inputs.translation
expected_value = [0, 0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:transform"))
attribute = test_node.get_attribute("outputs:transform")
db_value = database.outputs.transform
| 7,006 | Python | 46.99315 | 199 | 0.611476 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWriteSetting.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWriteSettingDatabase import OgnWriteSettingDatabase
test_file_name = "OgnWriteSettingTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WriteSetting")
database = OgnWriteSettingDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:settingPath"))
attribute = test_node.get_attribute("inputs:settingPath")
db_value = database.inputs.settingPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,305 | Python | 48.063829 | 92 | 0.698482 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToString.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:converted', "True", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', "2.1", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', "42", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[3]', 'value': [1.5, 2, 3]}, False],
],
'outputs': [
['outputs:converted', "[1.5, 2, 3]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3.5, 4]}, False],
],
'outputs': [
['outputs:converted', "[2, 3.5, 4]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', "[[1, 2], [3, 4]]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uint64', 'value': 42}, False],
],
'outputs': [
['outputs:converted', "42", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uchar', 'value': 65}, False],
],
'outputs': [
['outputs:converted', "A", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uchar[]', 'value': [65, 66, 67]}, False],
],
'outputs': [
['outputs:converted', "[A, B, C]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'string', 'value': 'ABC'}, False],
],
'outputs': [
['outputs:converted', "ABC", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token', 'value': 'Foo'}, False],
],
'outputs': [
['outputs:converted', "Foo", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token', 'value': ''}, False],
],
'outputs': [
['outputs:converted', "", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token[]', 'value': ['Foo', 'Bar']}, False],
],
'outputs': [
['outputs:converted', "[\"Foo\", \"Bar\"]", False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToString", "omni.graph.nodes.ToString", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToString","omni.graph.nodes.ToString", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToString", "omni.graph.nodes.ToString", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToString User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToStringDatabase import OgnToStringDatabase
test_file_name = "OgnToStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToString")
database = OgnToStringDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:converted"))
attribute = test_node.get_attribute("outputs:converted")
db_value = database.outputs.converted
| 7,004 | Python | 37.701657 | 189 | 0.511565 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsEmpty.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int', 'value': 0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double', 'value': 0.0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar', 'value': 0}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2]', 'value': [0.0, 0.0]}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [0.0]}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2][]', 'value': []}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': 'hello'}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': 'hello'}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': ' '}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': ' '}, False],
],
'outputs': [
['outputs:isEmpty', False, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'string', 'value': ''}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'token', 'value': ''}, False],
],
'outputs': [
['outputs:isEmpty', True, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsEmpty", "omni.graph.nodes.IsEmpty", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_IsEmpty","omni.graph.nodes.IsEmpty", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_IsEmpty", "omni.graph.nodes.IsEmpty", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.IsEmpty User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnIsEmptyDatabase import OgnIsEmptyDatabase
test_file_name = "OgnIsEmptyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsEmpty")
database = OgnIsEmptyDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:isEmpty"))
attribute = test_node.get_attribute("outputs:isEmpty")
db_value = database.outputs.isEmpty
| 7,319 | Python | 36.15736 | 187 | 0.502254 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveTubePositions.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCurveTubePositionsDatabase import OgnCurveTubePositionsDatabase
test_file_name = "OgnCurveTubePositionsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_CurveTubePositions")
database = OgnCurveTubePositionsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:cols"))
attribute = test_node.get_attribute("inputs:cols")
db_value = database.inputs.cols
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:out"))
attribute = test_node.get_attribute("inputs:out")
db_value = database.inputs.out
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:tubePointStarts"))
attribute = test_node.get_attribute("inputs:tubePointStarts")
db_value = database.inputs.tubePointStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:up"))
attribute = test_node.get_attribute("inputs:up")
db_value = database.inputs.up
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:width"))
attribute = test_node.get_attribute("inputs:width")
db_value = database.inputs.width
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:points"))
attribute = test_node.get_attribute("outputs:points")
db_value = database.outputs.points
| 5,214 | Python | 51.676767 | 100 | 0.691024 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineSet.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTimelineSetDatabase import OgnTimelineSetDatabase
test_file_name = "OgnTimelineSetTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetTimeline")
database = OgnTimelineSetDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:propName"))
attribute = test_node.get_attribute("inputs:propName")
db_value = database.inputs.propName
expected_value = "Frame"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:propValue"))
attribute = test_node.get_attribute("inputs:propValue")
db_value = database.inputs.propValue
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:clamped"))
attribute = test_node.get_attribute("outputs:clamped")
db_value = database.outputs.clamped
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,917 | Python | 48.457626 | 92 | 0.694892 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadTime.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadTimeDatabase import OgnReadTimeDatabase
test_file_name = "OgnReadTimeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadTime")
database = OgnReadTimeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:absoluteSimTime"))
attribute = test_node.get_attribute("outputs:absoluteSimTime")
db_value = database.outputs.absoluteSimTime
self.assertTrue(test_node.get_attribute_exists("outputs:deltaSeconds"))
attribute = test_node.get_attribute("outputs:deltaSeconds")
db_value = database.outputs.deltaSeconds
self.assertTrue(test_node.get_attribute_exists("outputs:frame"))
attribute = test_node.get_attribute("outputs:frame")
db_value = database.outputs.frame
self.assertTrue(test_node.get_attribute_exists("outputs:isPlaying"))
attribute = test_node.get_attribute("outputs:isPlaying")
db_value = database.outputs.isPlaying
self.assertTrue(test_node.get_attribute_exists("outputs:time"))
attribute = test_node.get_attribute("outputs:time")
db_value = database.outputs.time
self.assertTrue(test_node.get_attribute_exists("outputs:timeSinceStart"))
attribute = test_node.get_attribute("outputs:timeSinceStart")
db_value = database.outputs.timeSinceStart
| 2,631 | Python | 46.854545 | 92 | 0.702014 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAnd.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, False, True, True]}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True, False, True]}, False],
],
'outputs': [
['outputs:result', [False, False, False, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanAnd", "omni.graph.nodes.BooleanAnd", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanAnd","omni.graph.nodes.BooleanAnd", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BooleanAnd", "omni.graph.nodes.BooleanAnd", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BooleanAnd User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAndDatabase import OgnAndDatabase
test_file_name = "OgnAndTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanAnd")
database = OgnAndDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,042 | Python | 45.266055 | 193 | 0.590837 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayInsertValue.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [1, 41, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 1, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:index', 2, False],
['inputs:value', {'type': 'int', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 42, 1]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOO', 'BAR']}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'token', 'value': 'BAZ'}, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['FOO', 'BAZ', 'BAR']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[]', 'value': [41, 42]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'half', 'value': 1}, False],
],
'outputs': [
['outputs:array', {'type': 'half[]', 'value': [41, 1, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[41, 1], [42, 2]]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[41, 1], [1, 2], [42, 2]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[41, 1], [42, 2]]}, False],
['inputs:index', 1, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
],
'outputs': [
['outputs:array', {'type': 'double[2][]', 'value': [[41, 1], [1, 2], [42, 2]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayInsertValue", "omni.graph.nodes.ArrayInsertValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ArrayInsertValue","omni.graph.nodes.ArrayInsertValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ArrayInsertValue", "omni.graph.nodes.ArrayInsertValue", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ArrayInsertValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayInsertValueDatabase import OgnArrayInsertValueDatabase
test_file_name = "OgnArrayInsertValueTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayInsertValue")
database = OgnArrayInsertValueDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:index"))
attribute = test_node.get_attribute("inputs:index")
db_value = database.inputs.index
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 7,028 | Python | 45.549669 | 205 | 0.549089 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMatrixMultiply.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'matrixd[3]', 'value': [1, 2, 3, 4, 5, 6, 7, 8, 9]}, False],
['inputs:b', {'type': 'matrixd[3]', 'value': [10, 11, 12, 13, 14, 15, 16, 17, 18]}, False],
],
'outputs': [
['outputs:output', {'type': 'matrixd[3]', 'value': [84, 90, 96, 201, 216, 231, 318, 342, 366]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'matrixd[4]', 'value': [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'matrixd[4]', 'value': [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
['inputs:b', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
],
'outputs': [
['outputs:output', {'type': 'double', 'value': 30}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
['inputs:b', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
['inputs:b', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MatrixMultiply", "omni.graph.nodes.MatrixMultiply", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MatrixMultiply","omni.graph.nodes.MatrixMultiply", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MatrixMultiply", "omni.graph.nodes.MatrixMultiply", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MatrixMultiply User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMatrixMultiplyDatabase import OgnMatrixMultiplyDatabase
test_file_name = "OgnMatrixMultiplyTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MatrixMultiply")
database = OgnMatrixMultiplyDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 7,246 | Python | 48.97931 | 201 | 0.515733 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat4.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantFloat4Database import OgnConstantFloat4Database
test_file_name = "OgnConstantFloat4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat4")
database = OgnConstantFloat4Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,955 | Python | 49.153845 | 93 | 0.697698 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetGatheredAttribute.py | import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
import os
class TestOgn(ogts.OmniGraphTestCase):
async def test_generated(self):
test_data = [{'inputs': [['inputs:name', '_translate', False]], 'outputs': [['outputs:value', {'type': 'pointd[3][]', 'value': [[1, 2, 3], [4, 5, 6]]}, False]], 'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.GetGatheredAttribute'], ['GatherByPath', 'omni.graph.nodes.GatherByPath']], 'create_prims': [['Empty', {}], ['Xform1', {'_translate': ['pointd[3]', [1, 2, 3]]}], ['Xform2', {'_translate': ['pointd[3]', [4, 5, 6]]}], ['XformTagged1', {'foo': ['token', ''], '_translate': ['pointd[3]', [1, 2, 3]]}], ['Tagged1', {'foo': ['token', '']}]], 'connect': [['GatherByPath.outputs:gatherId', 'TestNode.inputs:gatherId']], 'set_values': [['GatherByPath.inputs:primPaths', ['/Xform1', '/Xform2']], ['GatherByPath.inputs:attributes', '_translate'], ['GatherByPath.inputs:allAttributes', False]]}}]
test_node = None
test_graph = None
for i, test_run in enumerate(test_data):
inputs = test_run.get('inputs', [])
outputs = test_run.get('outputs', [])
state_set = test_run.get('state_set', [])
state_get = test_run.get('state_get', [])
setup = test_run.get('setup', None)
if setup is None or setup:
await omni.usd.get_context().new_stage_async()
test_graph = None
elif not setup:
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test is misconfigured - empty setup cannot be in the first test")
if setup:
(test_graph, test_nodes, _, _) = og.Controller.edit("/TestGraph", setup)
self.assertTrue(test_nodes)
test_node = test_nodes[0]
elif setup is None:
if test_graph is None:
test_graph = og.Controller.create_graph("/TestGraph")
self.assertTrue(test_graph is not None and test_graph.is_valid())
test_node = og.Controller.create_node(
("TestNode_omni_graph_nodes_GetGatheredAttribute", test_graph), "omni.graph.nodes.GetGatheredAttribute"
)
self.assertTrue(test_graph is not None and test_graph.is_valid(), "Test graph invalid")
self.assertTrue(test_node is not None and test_node.is_valid(), "Test node invalid")
await og.Controller.evaluate(test_graph)
values_to_set = inputs + state_set
if values_to_set:
for attribute_name, attribute_value, _ in inputs + state_set:
og.Controller((attribute_name, test_node)).set(attribute_value)
await og.Controller.evaluate(test_graph)
for attribute_name, expected_value, _ in outputs + state_get:
attribute = og.Controller.attribute(attribute_name, test_node)
actual_output = og.Controller.get(attribute)
expected_type = None
if isinstance(expected_value, dict):
expected_type = expected_value["type"]
expected_value = expected_value["value"]
ogts.verify_values(expected_value, actual_output, f"omni.graph.nodes.GetGatheredAttribute User test case #{i+1}: {attribute_name} attribute value error")
if expected_type:
tp = og.AttributeType.type_from_ogn_type_name(expected_type)
actual_type = attribute.get_resolved_type()
if tp != actual_type:
raise ValueError(f"omni.graph.nodes.GetGatheredAttribute User tests - {attribute_name}: Expected {expected_type}, saw {actual_type.get_ogn_type_name()}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetGatheredAttributeDatabase import OgnGetGatheredAttributeDatabase
test_file_name = "OgnGetGatheredAttributeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetGatheredAttribute")
database = OgnGetGatheredAttributeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:gatherId"))
attribute = test_node.get_attribute("inputs:gatherId")
db_value = database.inputs.gatherId
expected_value = 0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 5,780 | Python | 62.527472 | 811 | 0.614879 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat3.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantFloat3Database import OgnConstantFloat3Database
test_file_name = "OgnConstantFloat3Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantFloat3")
database = OgnConstantFloat3Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,950 | Python | 49.02564 | 93 | 0.698462 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExtractBundle.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnExtractBundleDatabase import OgnExtractBundleDatabase
test_file_name = "OgnExtractBundleTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ExtractBundle")
database = OgnExtractBundleDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
self.assertTrue(test_node.get_attribute_exists("outputs_passThrough"))
attribute = test_node.get_attribute("outputs_passThrough")
db_value = database.outputs.passThrough
| 1,879 | Python | 47.205127 | 92 | 0.704098 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToDeg.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:radians', {'type': 'double', 'value': -1.0}, False],
],
'outputs': [
['outputs:degrees', {'type': 'double', 'value': -57.2958}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDeg", "omni.graph.nodes.ToDeg", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToDeg","omni.graph.nodes.ToDeg", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToDeg", "omni.graph.nodes.ToDeg", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToDeg User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToDegDatabase import OgnToDegDatabase
test_file_name = "OgnToDegTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToDeg")
database = OgnToDegDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 3,988 | Python | 48.246913 | 183 | 0.647944 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantHalfDatabase import OgnConstantHalfDatabase
test_file_name = "OgnConstantHalfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantHalf")
database = OgnConstantHalfDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,928 | Python | 48.461537 | 92 | 0.69917 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnLengthAlongCurve.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:curveVertexStarts', [0], False],
['inputs:curveVertexCounts', [4], False],
['inputs:curvePoints', [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 4.0, 4.0], [12.0, 13.0, 4.0]], False],
['inputs:normalize', False, False],
],
'outputs': [
['outputs:length', [0.0, 1.0, 6.0, 21.0], False],
],
},
{
'inputs': [
['inputs:curveVertexStarts', [0], False],
['inputs:curveVertexCounts', [3], False],
['inputs:curvePoints', [[0.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 1.0, 1.0]], False],
['inputs:normalize', True, False],
],
'outputs': [
['outputs:length', [0.0, 0.5, 1.0], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_LengthAlongCurve", "omni.graph.nodes.LengthAlongCurve", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_LengthAlongCurve","omni.graph.nodes.LengthAlongCurve", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_LengthAlongCurve", "omni.graph.nodes.LengthAlongCurve", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.LengthAlongCurve User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnLengthAlongCurveDatabase import OgnLengthAlongCurveDatabase
test_file_name = "OgnLengthAlongCurveTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_LengthAlongCurve")
database = OgnLengthAlongCurveDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:curvePoints"))
attribute = test_node.get_attribute("inputs:curvePoints")
db_value = database.inputs.curvePoints
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexCounts"))
attribute = test_node.get_attribute("inputs:curveVertexCounts")
db_value = database.inputs.curveVertexCounts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:curveVertexStarts"))
attribute = test_node.get_attribute("inputs:curveVertexStarts")
db_value = database.inputs.curveVertexStarts
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:normalize"))
attribute = test_node.get_attribute("inputs:normalize")
db_value = database.inputs.normalize
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:length"))
attribute = test_node.get_attribute("outputs:length")
db_value = database.outputs.length
| 6,622 | Python | 49.557252 | 205 | 0.657505 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetVariantSelection.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSetVariantSelectionDatabase import OgnSetVariantSelectionDatabase
test_file_name = "OgnSetVariantSelectionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetVariantSelection")
database = OgnSetVariantSelectionDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:setVariant"))
attribute = test_node.get_attribute("inputs:setVariant")
db_value = database.inputs.setVariant
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantName"))
attribute = test_node.get_attribute("inputs:variantName")
db_value = database.inputs.variantName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:variantSetName"))
attribute = test_node.get_attribute("inputs:variantSetName")
db_value = database.inputs.variantSetName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 3,406 | Python | 49.850746 | 102 | 0.69818 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimsV2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWritePrimsV2Database import OgnWritePrimsV2Database
test_file_name = "OgnWritePrimsV2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrimsV2")
database = OgnWritePrimsV2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToExport"))
attribute = test_node.get_attribute("inputs:attrNamesToExport")
db_value = database.inputs.attrNamesToExport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:layerIdentifier"))
attribute = test_node.get_attribute("inputs:layerIdentifier")
db_value = database.inputs.layerIdentifier
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("inputs:primsBundle"))
attribute = test_node.get_attribute("inputs:primsBundle")
db_value = database.inputs.primsBundle
self.assertTrue(test_node.get_attribute_exists("inputs:scatterUnderTargets"))
attribute = test_node.get_attribute("inputs:scatterUnderTargets")
db_value = database.inputs.scatterUnderTargets
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToExport"))
attribute = test_node.get_attribute("state:attrNamesToExport")
db_value = database.state.attrNamesToExport
self.assertTrue(test_node.get_attribute_exists("state:layerIdentifier"))
attribute = test_node.get_attribute("state:layerIdentifier")
db_value = database.state.layerIdentifier
self.assertTrue(test_node.get_attribute_exists("state:pathPattern"))
attribute = test_node.get_attribute("state:pathPattern")
db_value = database.state.pathPattern
self.assertTrue(test_node.get_attribute_exists("state:primBundleDirtyId"))
attribute = test_node.get_attribute("state:primBundleDirtyId")
db_value = database.state.primBundleDirtyId
self.assertTrue(test_node.get_attribute_exists("state:scatterUnderTargets"))
attribute = test_node.get_attribute("state:scatterUnderTargets")
db_value = database.state.scatterUnderTargets
self.assertTrue(test_node.get_attribute_exists("state:typePattern"))
attribute = test_node.get_attribute("state:typePattern")
db_value = database.state.typePattern
self.assertTrue(test_node.get_attribute_exists("state:usdWriteBack"))
attribute = test_node.get_attribute("state:usdWriteBack")
db_value = database.state.usdWriteBack
| 6,349 | Python | 50.626016 | 92 | 0.700425 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantQuatf.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantQuatfDatabase import OgnConstantQuatfDatabase
test_file_name = "OgnConstantQuatfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantQuatf")
database = OgnConstantQuatfDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,950 | Python | 49.02564 | 92 | 0.696923 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrimAttribute.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWritePrimAttributeDatabase import OgnWritePrimAttributeDatabase
test_file_name = "OgnWritePrimAttributeTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrimAttribute")
database = OgnWritePrimAttributeDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:name"))
attribute = test_node.get_attribute("inputs:name")
db_value = database.inputs.name
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primPath"))
attribute = test_node.get_attribute("inputs:primPath")
db_value = database.inputs.primPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("state:correctlySetup"))
attribute = test_node.get_attribute("state:correctlySetup")
db_value = database.state.correctlySetup
self.assertTrue(test_node.get_attribute_exists("state:destAttrib"))
attribute = test_node.get_attribute("state:destAttrib")
db_value = database.state.destAttrib
self.assertTrue(test_node.get_attribute_exists("state:destPath"))
attribute = test_node.get_attribute("state:destPath")
db_value = database.state.destPath
self.assertTrue(test_node.get_attribute_exists("state:destPathToken"))
attribute = test_node.get_attribute("state:destPathToken")
db_value = database.state.destPathToken
| 4,389 | Python | 49.45977 | 100 | 0.695603 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeVector4.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
['inputs:y', {'type': 'float', 'value': 1.0}, False],
['inputs:z', {'type': 'float', 'value': 0}, False],
['inputs:w', {'type': 'float', 'value': 0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[4]', 'value': [42.0, 1.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float', 'value': 42.0}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[4]', 'value': [42.0, 0.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'float[]', 'value': [42, 1, 0]}, False],
['inputs:y', {'type': 'float[]', 'value': [0, 1, 2]}, False],
['inputs:z', {'type': 'float[]', 'value': [0, 2, 4]}, False],
['inputs:w', {'type': 'float[]', 'value': [5, 6, 7]}, False],
],
'outputs': [
['outputs:tuple', {'type': 'float[4][]', 'value': [[42, 0, 0, 5], [1, 1, 2, 6], [0, 2, 4, 7]]}, False],
],
},
{
'inputs': [
['inputs:x', {'type': 'int', 'value': 42}, False],
['inputs:y', {'type': 'int', 'value': -42}, False],
['inputs:z', {'type': 'int', 'value': 5}, False],
['inputs:w', {'type': 'int', 'value': 6}, False],
],
'outputs': [
['outputs:tuple', {'type': 'int[4]', 'value': [42, -42, 5, 6]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector4", "omni.graph.nodes.MakeVector4", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_MakeVector4","omni.graph.nodes.MakeVector4", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_MakeVector4", "omni.graph.nodes.MakeVector4", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.MakeVector4 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeVector4Database import OgnMakeVector4Database
test_file_name = "OgnMakeVector4Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_MakeVector4")
database = OgnMakeVector4Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,539 | Python | 47.596491 | 195 | 0.569417 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Quaternion.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1]}, False],
['inputs:quaternion', {'type': 'quatd[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False],
['inputs:quaternion', {'type': 'quatd[4][]', 'value': [[0.3826834, 0, 0, 0.9238795], [0.3826834, 0, 0, 0.9238795]]}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Quaternion", "omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Quaternion","omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Quaternion", "omni.graph.nodes.SetMatrix4Quaternion", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Quaternion User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSetMatrix4QuaternionDatabase import OgnSetMatrix4QuaternionDatabase
test_file_name = "OgnSetMatrix4QuaternionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Quaternion")
database = OgnSetMatrix4QuaternionDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,090 | Python | 54.945054 | 236 | 0.622004 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimDirectionVector.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetPrimDirectionVectorDatabase import OgnGetPrimDirectionVectorDatabase
test_file_name = "OgnGetPrimDirectionVectorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetPrimDirectionVector")
database = OgnGetPrimDirectionVectorDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:primPath"))
attribute = test_node.get_attribute("inputs:primPath")
db_value = database.inputs.primPath
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:backwardVector"))
attribute = test_node.get_attribute("outputs:backwardVector")
db_value = database.outputs.backwardVector
self.assertTrue(test_node.get_attribute_exists("outputs:downVector"))
attribute = test_node.get_attribute("outputs:downVector")
db_value = database.outputs.downVector
self.assertTrue(test_node.get_attribute_exists("outputs:forwardVector"))
attribute = test_node.get_attribute("outputs:forwardVector")
db_value = database.outputs.forwardVector
self.assertTrue(test_node.get_attribute_exists("outputs:leftVector"))
attribute = test_node.get_attribute("outputs:leftVector")
db_value = database.outputs.leftVector
self.assertTrue(test_node.get_attribute_exists("outputs:rightVector"))
attribute = test_node.get_attribute("outputs:rightVector")
db_value = database.outputs.rightVector
self.assertTrue(test_node.get_attribute_exists("outputs:upVector"))
attribute = test_node.get_attribute("outputs:upVector")
db_value = database.outputs.upVector
| 3,589 | Python | 49.56338 | 108 | 0.704653 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTrig.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 120.0}, False],
['inputs:operation', "COS", False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': -57.2958}, False],
['inputs:operation', "RADIANS", False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': -1.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': -1.0}, False],
['inputs:operation', "ARCCOS", False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 180.0}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 45.0}, False],
['inputs:operation', "SIN", False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.707107}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Trig", "omni.graph.nodes.Trig", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Trig","omni.graph.nodes.Trig", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Trig", "omni.graph.nodes.Trig", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Trig User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTrigDatabase import OgnTrigDatabase
test_file_name = "OgnTrigTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Trig")
database = OgnTrigDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:operation"))
attribute = test_node.get_attribute("inputs:operation")
db_value = database.inputs.operation
expected_value = "SIN"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 5,346 | Python | 44.700854 | 181 | 0.598578 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGpuInteropRenderProductEntry.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGpuInteropRenderProductEntryDatabase import OgnGpuInteropRenderProductEntryDatabase
test_file_name = "OgnGpuInteropRenderProductEntryTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GpuInteropRenderProductEntry")
database = OgnGpuInteropRenderProductEntryDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:exec"))
attribute = test_node.get_attribute("outputs:exec")
db_value = database.outputs.exec
self.assertTrue(test_node.get_attribute_exists("outputs:gpu"))
attribute = test_node.get_attribute("outputs:gpu")
db_value = database.outputs.gpu
self.assertTrue(test_node.get_attribute_exists("outputs:hydraTime"))
attribute = test_node.get_attribute("outputs:hydraTime")
db_value = database.outputs.hydraTime
self.assertTrue(test_node.get_attribute_exists("outputs:rp"))
attribute = test_node.get_attribute("outputs:rp")
db_value = database.outputs.rp
self.assertTrue(test_node.get_attribute_exists("outputs:simTime"))
attribute = test_node.get_attribute("outputs:simTime")
db_value = database.outputs.simTime
| 2,467 | Python | 47.392156 | 120 | 0.70531 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDistance3D.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'float[3]', 'value': [4, 6, 8]}, False],
],
'outputs': [
['outputs:distance', {'type': 'float', 'value': 7.07107}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[3][]', 'value': [[1, 2, 3], [1, 2, 3]]}, False],
['inputs:b', {'type': 'float[3][]', 'value': [[1, 2, 3], [4, 6, 8]]}, False],
],
'outputs': [
['outputs:distance', {'type': 'float[]', 'value': [0, 7.07107]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half[3][]', 'value': [[1, 2, 3], [4, 6, 8]]}, False],
['inputs:b', {'type': 'half[3]', 'value': [1, 2, 3]}, False],
],
'outputs': [
['outputs:distance', {'type': 'half[]', 'value': [0, 7.0703125]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3]', 'value': [1, 2, 3]}, False],
['inputs:b', {'type': 'double[3]', 'value': [4, 6, 8]}, False],
],
'outputs': [
['outputs:distance', {'type': 'double', 'value': 7.07107}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Distance3D", "omni.graph.nodes.Distance3D", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Distance3D","omni.graph.nodes.Distance3D", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Distance3D", "omni.graph.nodes.Distance3D", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Distance3D User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnDistance3DDatabase import OgnDistance3DDatabase
test_file_name = "OgnDistance3DTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Distance3D")
database = OgnDistance3DDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,218 | Python | 46.880734 | 193 | 0.580874 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Translation.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False],
['inputs:translation', {'type': 'vectord[3]', 'value': [1, 2, 3]}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 1, 2, 3, 1]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 10, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 15, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False],
['inputs:translation', {'type': 'vectord[3][]', 'value': [[45, 10, 10], [3, 2, 1]]}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 10, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 45, 10, 10, 1], [1.0, 15, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 3, 2, 1, 1]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Translation", "omni.graph.nodes.SetMatrix4Translation", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Translation","omni.graph.nodes.SetMatrix4Translation", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Translation", "omni.graph.nodes.SetMatrix4Translation", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Translation User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSetMatrix4TranslationDatabase import OgnSetMatrix4TranslationDatabase
test_file_name = "OgnSetMatrix4TranslationTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Translation")
database = OgnSetMatrix4TranslationDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,986 | Python | 53.802197 | 215 | 0.619735 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadVariable.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadVariableDatabase import OgnReadVariableDatabase
test_file_name = "OgnReadVariableTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_core_ReadVariable")
database = OgnReadVariableDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:variableName"))
attribute = test_node.get_attribute("inputs:variableName")
db_value = database.inputs.variableName
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,947 | Python | 48.948717 | 92 | 0.701592 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsPrimActive.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnIsPrimActiveDatabase import OgnIsPrimActiveDatabase
test_file_name = "OgnIsPrimActiveTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_IsPrimActive")
database = OgnIsPrimActiveDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:primTarget"))
attribute = test_node.get_attribute("inputs:primTarget")
db_value = database.inputs.primTarget
self.assertTrue(test_node.get_attribute_exists("outputs:active"))
attribute = test_node.get_attribute("outputs:active")
db_value = database.outputs.active
| 2,293 | Python | 47.80851 | 92 | 0.696904 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAdd.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
'outputs': [
['outputs:sum', {'type': 'float[2]', 'value': [1.5, 3.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 10}, False],
['inputs:b', {'type': 'int64', 'value': 6}, False],
],
'outputs': [
['outputs:sum', {'type': 'int64', 'value': 16}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double[2]', 'value': [5, 5]}, False],
],
'outputs': [
['outputs:sum', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:b', {'type': 'double', 'value': 5}, False],
],
'outputs': [
['outputs:sum', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Add", "omni.graph.nodes.Add", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Add","omni.graph.nodes.Add", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Add", "omni.graph.nodes.Add", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Add User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAddDatabase import OgnAddDatabase
test_file_name = "OgnAddTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Add")
database = OgnAddDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,065 | Python | 45.477064 | 179 | 0.572557 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPrims.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantPrimsDatabase import OgnConstantPrimsDatabase
test_file_name = "OgnConstantPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantPrims")
database = OgnConstantPrimsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
| 1,681 | Python | 47.057142 | 92 | 0.703153 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNor.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, False, True, True]}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True, False, True]}, False],
],
'outputs': [
['outputs:result', [True, False, False, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [True, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', [True, False], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanNor", "omni.graph.nodes.BooleanNor", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BooleanNor","omni.graph.nodes.BooleanNor", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BooleanNor", "omni.graph.nodes.BooleanNor", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BooleanNor User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNorDatabase import OgnNorDatabase
test_file_name = "OgnNorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BooleanNor")
database = OgnNorDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,040 | Python | 45.247706 | 193 | 0.590675 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBundleInspector.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'outputs': [
['outputs:count', 0, False],
['outputs:names', [], False],
['outputs:types', [], False],
['outputs:roles', [], False],
['outputs:arrayDepths', [], False],
['outputs:tupleCounts', [], False],
['outputs:values', [], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BundleInspector", "omni.graph.nodes.BundleInspector", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BundleInspector User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BundleInspector","omni.graph.nodes.BundleInspector", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BundleInspector User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBundleInspectorDatabase import OgnBundleInspectorDatabase
test_file_name = "OgnBundleInspectorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BundleInspector")
database = OgnBundleInspectorDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
self.assertTrue(test_node.get_attribute_exists("inputs:inspectDepth"))
attribute = test_node.get_attribute("inputs:inspectDepth")
db_value = database.inputs.inspectDepth
expected_value = 1
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:print"))
attribute = test_node.get_attribute("inputs:print")
db_value = database.inputs.print
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:arrayDepths"))
attribute = test_node.get_attribute("outputs:arrayDepths")
db_value = database.outputs.arrayDepths
self.assertTrue(test_node.get_attribute_exists("outputs:attributeCount"))
attribute = test_node.get_attribute("outputs:attributeCount")
db_value = database.outputs.attributeCount
self.assertTrue(test_node.get_attribute_exists("outputs_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
self.assertTrue(test_node.get_attribute_exists("outputs:childCount"))
attribute = test_node.get_attribute("outputs:childCount")
db_value = database.outputs.childCount
self.assertTrue(test_node.get_attribute_exists("outputs:count"))
attribute = test_node.get_attribute("outputs:count")
db_value = database.outputs.count
self.assertTrue(test_node.get_attribute_exists("outputs:names"))
attribute = test_node.get_attribute("outputs:names")
db_value = database.outputs.names
self.assertTrue(test_node.get_attribute_exists("outputs:roles"))
attribute = test_node.get_attribute("outputs:roles")
db_value = database.outputs.roles
self.assertTrue(test_node.get_attribute_exists("outputs:tupleCounts"))
attribute = test_node.get_attribute("outputs:tupleCounts")
db_value = database.outputs.tupleCounts
self.assertTrue(test_node.get_attribute_exists("outputs:types"))
attribute = test_node.get_attribute("outputs:types")
db_value = database.outputs.types
self.assertTrue(test_node.get_attribute_exists("outputs:values"))
attribute = test_node.get_attribute("outputs:values")
db_value = database.outputs.values
| 6,031 | Python | 48.04065 | 184 | 0.666556 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSetMatrix4Rotation.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1]}, False],
['inputs:fixedRotationAxis', "X", False],
['inputs:rotationAngle', {'type': 'double', 'value': 45}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4]', 'value': [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 100, 0, 0, 1]]}, False],
['inputs:fixedRotationAxis', "X", False],
['inputs:rotationAngle', {'type': 'double[]', 'value': [45, 45]}, False],
],
'outputs': [
['outputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Rotation", "omni.graph.nodes.SetMatrix4Rotation", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_SetMatrix4Rotation","omni.graph.nodes.SetMatrix4Rotation", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_SetMatrix4Rotation", "omni.graph.nodes.SetMatrix4Rotation", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.SetMatrix4Rotation User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSetMatrix4RotationDatabase import OgnSetMatrix4RotationDatabase
test_file_name = "OgnSetMatrix4RotationTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_SetMatrix4Rotation")
database = OgnSetMatrix4RotationDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:fixedRotationAxis"))
attribute = test_node.get_attribute("inputs:fixedRotationAxis")
db_value = database.inputs.fixedRotationAxis
expected_value = "Y"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 5,536 | Python | 53.821782 | 236 | 0.628071 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEachZero.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 6}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': -3}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 0}, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 42.5}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': -7.1}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 0.0}, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 0.01}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': -0.01}, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 42.5}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': -7.1}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 0.0}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 0.01}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float', 'value': -0.01}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 6}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': -3}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 0}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 6}, False],
['inputs:tolerance', 10.0, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': -3}, False],
['inputs:tolerance', 10.0, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 0}, False],
['inputs:tolerance', 10.0, False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2]', 'value': [0, 0]}, False],
],
'outputs': [
['outputs:result', [True, True], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2]', 'value': [0, 3]}, False],
],
'outputs': [
['outputs:result', [True, False], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2]', 'value': [3, 0]}, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2]', 'value': [3, 5]}, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[3]', 'value': [1.7, 0.05, -4.3]}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', [False, True, False], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.0, -0.1, 0.3]]}, False],
['inputs:tolerance', 0.1, False],
],
'outputs': [
['outputs:result', [False, False], False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[3][]', 'value': [[1.7, 0.05, -4.3], [0.0, -0.1, 0.3]]}, False],
['inputs:tolerance', 0.5, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EachZero", "omni.graph.nodes.EachZero", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_EachZero","omni.graph.nodes.EachZero", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_EachZero", "omni.graph.nodes.EachZero", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.EachZero User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnEachZeroDatabase import OgnEachZeroDatabase
test_file_name = "OgnEachZeroTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_EachZero")
database = OgnEachZeroDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:tolerance"))
attribute = test_node.get_attribute("inputs:tolerance")
db_value = database.inputs.tolerance
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 10,849 | Python | 34.808581 | 189 | 0.455987 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrims.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetPrimsDatabase import OgnGetPrimsDatabase
test_file_name = "OgnGetPrimsTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetPrims")
database = OgnGetPrimsDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:bundle"))
attribute = test_node.get_attribute("inputs:bundle")
db_value = database.inputs.bundle
self.assertTrue(test_node.get_attribute_exists("inputs:inverse"))
attribute = test_node.get_attribute("inputs:inverse")
db_value = database.inputs.inverse
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:pathPattern"))
attribute = test_node.get_attribute("inputs:pathPattern")
db_value = database.inputs.pathPattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:typePattern"))
attribute = test_node.get_attribute("inputs:typePattern")
db_value = database.inputs.typePattern
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_bundle"))
attribute = test_node.get_attribute("outputs_bundle")
db_value = database.outputs.bundle
| 3,161 | Python | 49.190475 | 92 | 0.692186 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTan.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float', 'value': 45.0}, False],
],
'outputs': [
['outputs:value', {'type': 'float', 'value': 1.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Tan", "omni.graph.nodes.Tan", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Tan","omni.graph.nodes.Tan", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Tan", "omni.graph.nodes.Tan", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Tan User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnTanDatabase import OgnTanDatabase
test_file_name = "OgnTanTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Tan")
database = OgnTanDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 3,949 | Python | 47.765432 | 179 | 0.644973 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAbsolute.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:input', {'type': 'double', 'value': -10.0}, False],
],
'outputs': [
['outputs:absolute', {'type': 'double', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float', 'value': -10.0}, False],
],
'outputs': [
['outputs:absolute', {'type': 'float', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half', 'value': -10.0}, False],
],
'outputs': [
['outputs:absolute', {'type': 'half', 'value': 10.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int', 'value': -10}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64', 'value': -10}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar', 'value': 10}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uchar', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint', 'value': 10}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uint', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64', 'value': 10}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uint64', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3]', 'value': [-1.0, -2.0, -3.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'double[3]', 'value': [1.0, 2.0, 3.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[4]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'float[4]', 'value': [2.0, 2.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[2]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int[2]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[2]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'half[2]', 'value': [3.0, 4.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [-1.0, -2.0, -2.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'double[]', 'value': [1.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [-2.0, 2.0, -2.0, 2.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'float[]', 'value': [2.0, 2.0, 2.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[]', 'value': [3.0, -4.0]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'half[]', 'value': [3.0, 4.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64[]', 'value': [3, -4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uchar[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uint[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'uint64[]', 'value': [3, 4]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[3][]', 'value': [[1, -2, -2], [-4, 2, 6], [3, -2, 4], [1, -4, 2]]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'int[3][]', 'value': [[1, 2, 2], [4, 2, 6], [3, 2, 4], [1, 4, 2]]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'double[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'float[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[3][]', 'value': [[1.0, -2.0, -2.0], [-4.0, 2.0, 6.0], [3.0, -2.0, 4.0], [1.0, -4.0, 2.0]]}, False],
],
'outputs': [
['outputs:absolute', {'type': 'half[3][]', 'value': [[1.0, 2.0, 2.0], [4.0, 2.0, 6.0], [3.0, 2.0, 4.0], [1.0, 4.0, 2.0]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Absolute", "omni.graph.nodes.Absolute", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Absolute","omni.graph.nodes.Absolute", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Absolute", "omni.graph.nodes.Absolute", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Absolute User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAbsoluteDatabase import OgnAbsoluteDatabase
test_file_name = "OgnAbsoluteTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Absolute")
database = OgnAbsoluteDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 10,585 | Python | 38.94717 | 189 | 0.442891 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayLength.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayLengthDatabase import OgnArrayLengthDatabase
test_file_name = "OgnArrayLengthTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ArrayLength")
database = OgnArrayLengthDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:attrName"))
attribute = test_node.get_attribute("inputs:attrName")
db_value = database.inputs.attrName
expected_value = "points"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:data"))
attribute = test_node.get_attribute("inputs:data")
db_value = database.inputs.data
self.assertTrue(test_node.get_attribute_exists("outputs:length"))
attribute = test_node.get_attribute("outputs:length")
db_value = database.outputs.length
| 2,288 | Python | 47.702127 | 92 | 0.696241 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomUnitQuaternion.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', [0.02489632, -0.05617058, 0.23986788, 0.9688594], False],
['outputs:execOut', 1, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitQuaternion", "omni.graph.nodes.RandomUnitQuaternion", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RandomUnitQuaternion","omni.graph.nodes.RandomUnitQuaternion", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RandomUnitQuaternion", "omni.graph.nodes.RandomUnitQuaternion", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RandomUnitQuaternion User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomUnitQuaternionDatabase import OgnRandomUnitQuaternionDatabase
test_file_name = "OgnRandomUnitQuaternionTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RandomUnitQuaternion")
database = OgnRandomUnitQuaternionDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:isNoise"))
attribute = test_node.get_attribute("inputs:isNoise")
db_value = database.inputs.isNoise
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:useSeed"))
attribute = test_node.get_attribute("inputs:useSeed")
db_value = database.inputs.useSeed
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
self.assertTrue(test_node.get_attribute_exists("outputs:random"))
attribute = test_node.get_attribute("outputs:random")
db_value = database.outputs.random
self.assertTrue(test_node.get_attribute_exists("state:gen"))
attribute = test_node.get_attribute("state:gen")
db_value = database.state.gen
| 5,840 | Python | 48.923077 | 213 | 0.676199 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInterpolator.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:knots', [1.0, 2.0], False],
['inputs:values', [3.0, 4.0], False],
['inputs:param', 1.5, False],
],
'outputs': [
['outputs:value', 3.5, False],
],
},
{
'inputs': [
['inputs:knots', [1.0, 2.0], False],
['inputs:values', [3.0, 4.0], False],
['inputs:param', 1.0, False],
],
'outputs': [
['outputs:value', 3.0, False],
],
},
{
'inputs': [
['inputs:knots', [1.0, 2.0], False],
['inputs:values', [3.0, 4.0], False],
['inputs:param', 2.0, False],
],
'outputs': [
['outputs:value', 4.0, False],
],
},
{
'inputs': [
['inputs:knots', [1.0, 2.0], False],
['inputs:values', [3.0, 4.0], False],
['inputs:param', 0.5, False],
],
'outputs': [
['outputs:value', 3.0, False],
],
},
{
'inputs': [
['inputs:knots', [1.0, 2.0], False],
['inputs:values', [3.0, 4.0], False],
['inputs:param', 2.5, False],
],
'outputs': [
['outputs:value', 4.0, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Interpolator", "omni.graph.nodes.Interpolator", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_Interpolator","omni.graph.nodes.Interpolator", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_Interpolator", "omni.graph.nodes.Interpolator", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.Interpolator User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnInterpolatorDatabase import OgnInterpolatorDatabase
test_file_name = "OgnInterpolatorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_Interpolator")
database = OgnInterpolatorDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:knots"))
attribute = test_node.get_attribute("inputs:knots")
db_value = database.inputs.knots
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:param"))
attribute = test_node.get_attribute("inputs:param")
db_value = database.inputs.param
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:values"))
attribute = test_node.get_attribute("inputs:values")
db_value = database.inputs.values
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
| 6,685 | Python | 43.278145 | 197 | 0.603141 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRemoveAttr.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRemoveAttrDatabase import OgnRemoveAttrDatabase
test_file_name = "OgnRemoveAttrTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RemoveAttribute")
database = OgnRemoveAttrDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:allowRemovePrimInternal"))
attribute = test_node.get_attribute("inputs:allowRemovePrimInternal")
db_value = database.inputs.allowRemovePrimInternal
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToRemove"))
attribute = test_node.get_attribute("inputs:attrNamesToRemove")
db_value = database.inputs.attrNamesToRemove
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:data"))
attribute = test_node.get_attribute("inputs:data")
db_value = database.inputs.data
self.assertTrue(test_node.get_attribute_exists("outputs_data"))
attribute = test_node.get_attribute("outputs_data")
db_value = database.outputs.data
| 2,785 | Python | 49.654545 | 94 | 0.701257 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantQuatd.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantQuatdDatabase import OgnConstantQuatdDatabase
test_file_name = "OgnConstantQuatdTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantQuatd")
database = OgnConstantQuatdDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0.0, 0.0, 0.0, 0.0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,950 | Python | 49.02564 | 92 | 0.696923 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToRad.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:degrees', {'type': 'double', 'value': -57.2958}, False],
],
'outputs': [
['outputs:radians', {'type': 'double', 'value': -1.0}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToRad", "omni.graph.nodes.ToRad", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToRad","omni.graph.nodes.ToRad", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToRad", "omni.graph.nodes.ToRad", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToRad User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToRadDatabase import OgnToRadDatabase
test_file_name = "OgnToRadTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToRad")
database = OgnToRadDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 3,988 | Python | 48.246913 | 183 | 0.647944 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnWritePrim.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnWritePrimDatabase import OgnWritePrimDatabase
test_file_name = "OgnWritePrimTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_WritePrim")
database = OgnWritePrimDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:execIn"))
attribute = test_node.get_attribute("inputs:execIn")
db_value = database.inputs.execIn
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:usdWriteBack"))
attribute = test_node.get_attribute("inputs:usdWriteBack")
db_value = database.inputs.usdWriteBack
expected_value = True
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,466 | Python | 47.372548 | 92 | 0.695864 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInterpolateTo.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:current', {'type': 'float', 'value': 0.0}, False],
['inputs:target', {'type': 'float', 'value': 10.0}, False],
['inputs:deltaSeconds', 0.1, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 1.9}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'double[3]', 'value': [0.0, 1.0, 2.0]}, False],
['inputs:target', {'type': 'double[3]', 'value': [10.0, 11.0, 12.0]}, False],
['inputs:deltaSeconds', 0.1, False],
],
'outputs': [
['outputs:result', {'type': 'double[3]', 'value': [1.9, 2.9, 3.9]}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'float[]', 'value': [0.0, 1.0, 2.0]}, False],
['inputs:target', {'type': 'float[]', 'value': [10.0, 11.0, 12.0]}, False],
['inputs:deltaSeconds', 0.1, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [1.9, 2.9, 3.9]}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'double[3][]', 'value': [[0.0, 1.0, 2.0], [0.0, 1.0, 2.0]]}, False],
['inputs:target', {'type': 'double[3][]', 'value': [[10.0, 11.0, 12.0], [10.0, 11.0, 12.0]]}, False],
['inputs:deltaSeconds', 0.1, False],
],
'outputs': [
['outputs:result', {'type': 'double[3][]', 'value': [[1.9, 2.9, 3.9], [1.9, 2.9, 3.9]]}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'quatd[4]', 'value': [0, 0, 0, 1]}, False],
['inputs:target', {'type': 'quatd[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False],
['inputs:deltaSeconds', 0.5, False],
['inputs:exponent', 1, False],
],
'outputs': [
['outputs:result', {'type': 'quatd[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'quatf[4]', 'value': [0, 0, 0, 1]}, False],
['inputs:target', {'type': 'quatf[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False],
['inputs:deltaSeconds', 0.5, False],
['inputs:exponent', 1, False],
],
'outputs': [
['outputs:result', {'type': 'quatf[4]', 'value': [0.3826834, 0, 0, 0.9238795]}, False],
],
},
{
'inputs': [
['inputs:current', {'type': 'float[4]', 'value': [0, 0, 0, 1]}, False],
['inputs:target', {'type': 'float[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False],
['inputs:deltaSeconds', 0.5, False],
['inputs:exponent', 1, False],
],
'outputs': [
['outputs:result', {'type': 'float[4]', 'value': [0.3535534, 0, 0, 0.8535534]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_InterpolateTo", "omni.graph.nodes.InterpolateTo", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_InterpolateTo","omni.graph.nodes.InterpolateTo", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_InterpolateTo", "omni.graph.nodes.InterpolateTo", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.InterpolateTo User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnInterpolateToDatabase import OgnInterpolateToDatabase
test_file_name = "OgnInterpolateToTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_InterpolateTo")
database = OgnInterpolateToDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:deltaSeconds"))
attribute = test_node.get_attribute("inputs:deltaSeconds")
db_value = database.inputs.deltaSeconds
expected_value = 0.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:speed"))
attribute = test_node.get_attribute("inputs:speed")
db_value = database.inputs.speed
expected_value = 1.0
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 8,282 | Python | 47.723529 | 199 | 0.570514 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimAttributes.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnReadPrimAttributesDatabase import OgnReadPrimAttributesDatabase
test_file_name = "OgnReadPrimAttributesTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ReadPrimAttributes")
database = OgnReadPrimAttributesDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 3)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:attrNamesToImport"))
attribute = test_node.get_attribute("inputs:attrNamesToImport")
db_value = database.inputs.attrNamesToImport
expected_value = "*"
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("inputs:usdTimecode"))
attribute = test_node.get_attribute("inputs:usdTimecode")
db_value = database.inputs.usdTimecode
expected_value = float("NaN")
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:usePath"))
attribute = test_node.get_attribute("inputs:usePath")
db_value = database.inputs.usePath
expected_value = False
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_primBundle"))
attribute = test_node.get_attribute("outputs_primBundle")
db_value = database.outputs.primBundle
self.assertTrue(test_node.get_attribute_exists("state:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
self.assertTrue(test_node.get_attribute_exists("state:primPath"))
attribute = test_node.get_attribute("state:primPath")
db_value = database.state.primPath
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
| 3,820 | Python | 49.946666 | 100 | 0.700262 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt2.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnConstantInt2Database import OgnConstantInt2Database
test_file_name = "OgnConstantInt2Template.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ConstantInt2")
database = OgnConstantInt2Database(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:value"))
attribute = test_node.get_attribute("inputs:value")
db_value = database.inputs.value
expected_value = [0, 0]
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
| 1,931 | Python | 48.53846 | 92 | 0.698084 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAppendString.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'token', 'value': '/'}, False],
['inputs:suffix', {'type': 'token', 'value': 'foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'token', 'value': '/foo'}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token[]', 'value': ['/World', '/World2']}, False],
['inputs:suffix', {'type': 'token', 'value': '/foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/foo']}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'token[]', 'value': ['/World', '/World2']}, False],
['inputs:suffix', {'type': 'token[]', 'value': ['/foo', '/bar']}, False],
],
'outputs': [
['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/bar']}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'string', 'value': '/'}, False],
['inputs:suffix', {'type': 'string', 'value': 'foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'string', 'value': '/foo'}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendString", "omni.graph.nodes.AppendString", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_AppendString","omni.graph.nodes.AppendString", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_AppendString", "omni.graph.nodes.AppendString", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.AppendString User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAppendStringDatabase import OgnAppendStringDatabase
test_file_name = "OgnAppendStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_AppendString")
database = OgnAppendStringDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,248 | Python | 47.155963 | 197 | 0.589558 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToHalf.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:value', {'type': 'float[]', 'value': []}, False],
],
'outputs': [
['outputs:converted', {'type': 'half[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.5}, False],
],
'outputs': [
['outputs:converted', {'type': 'half', 'value': 2.5}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'half', 'value': 42.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2]', 'value': [2.5, 2.5]}, False],
],
'outputs': [
['outputs:converted', {'type': 'half[2]', 'value': [2.5, 2.5]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'half[3]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'half[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToHalf", "omni.graph.nodes.ToHalf", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_ToHalf","omni.graph.nodes.ToHalf", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_ToHalf", "omni.graph.nodes.ToHalf", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.ToHalf User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToHalfDatabase import OgnToHalfDatabase
test_file_name = "OgnToHalfTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_ToHalf")
database = OgnToHalfDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,611 | Python | 42.503876 | 185 | 0.551417 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBuildString.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:a', {'type': 'token', 'value': '/'}, False],
['inputs:b', {'type': 'token', 'value': 'foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'token', 'value': '/foo'}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token[]', 'value': ['/World', '/World2']}, False],
['inputs:b', {'type': 'token', 'value': '/foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/foo']}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token[]', 'value': ['/World', '/World2']}, False],
['inputs:b', {'type': 'token[]', 'value': ['/foo', '/bar']}, False],
],
'outputs': [
['outputs:value', {'type': 'token[]', 'value': ['/World/foo', '/World2/bar']}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': '/'}, False],
['inputs:b', {'type': 'string', 'value': 'foo'}, False],
],
'outputs': [
['outputs:value', {'type': 'string', 'value': '/foo'}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BuildString", "omni.graph.nodes.BuildString", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_BuildString","omni.graph.nodes.BuildString", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_BuildString", "omni.graph.nodes.BuildString", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.BuildString User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBuildStringDatabase import OgnBuildStringDatabase
test_file_name = "OgnBuildStringTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_BuildString")
database = OgnBuildStringDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 2)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 5,198 | Python | 46.697247 | 195 | 0.58561 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetGraphTargetId.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetGraphTargetIdDatabase import OgnGetGraphTargetIdDatabase
test_file_name = "OgnGetGraphTargetIdTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetGraphTargetId")
database = OgnGetGraphTargetIdDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("outputs:targetId"))
attribute = test_node.get_attribute("outputs:targetId")
db_value = database.outputs.targetId
| 1,708 | Python | 47.82857 | 96 | 0.707845 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRenameAttr.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRenameAttrDatabase import OgnRenameAttrDatabase
test_file_name = "OgnRenameAttrTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RenameAttribute")
database = OgnRenameAttrDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
self.assertTrue(test_node.get_attribute_exists("inputs:data"))
attribute = test_node.get_attribute("inputs:data")
db_value = database.inputs.data
self.assertTrue(test_node.get_attribute_exists("inputs:inputAttrNames"))
attribute = test_node.get_attribute("inputs:inputAttrNames")
db_value = database.inputs.inputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("inputs:outputAttrNames"))
attribute = test_node.get_attribute("inputs:outputAttrNames")
db_value = database.inputs.outputAttrNames
expected_value = ""
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
ogts.verify_values(expected_value, db_value, _attr_error(attribute, False))
self.assertTrue(test_node.get_attribute_exists("outputs_data"))
attribute = test_node.get_attribute("outputs_data")
db_value = database.outputs.data
| 2,749 | Python | 48.999999 | 94 | 0.696617 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetMatrix4Rotation.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1]}, False],
],
'outputs': [
['outputs:rotation', {'type': 'vectord[3]', 'value': [45, 0, 0]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 50, 0, 0, 1], [1.0, 0, 0, 0, 0, 0.70711, 0.70711, 0, 0, -0.70711, 0.70711, 0, 100, 0, 0, 1]]}, False],
],
'outputs': [
['outputs:rotation', {'type': 'vectord[3][]', 'value': [[45, 0, 0], [45, 0, 0]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Rotation", "omni.graph.nodes.GetMatrix4Rotation", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_GetMatrix4Rotation","omni.graph.nodes.GetMatrix4Rotation", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_GetMatrix4Rotation", "omni.graph.nodes.GetMatrix4Rotation", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.GetMatrix4Rotation User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetMatrix4RotationDatabase import OgnGetMatrix4RotationDatabase
test_file_name = "OgnGetMatrix4RotationTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_GetMatrix4Rotation")
database = OgnGetMatrix4RotationDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 4,692 | Python | 51.730336 | 235 | 0.633419 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRotateVector.py | import os
import omni.kit.test
import omni.graph.core as og
import omni.graph.core.tests as ogts
from omni.graph.core.tests.omnigraph_test_utils import _TestGraphAndNode
from omni.graph.core.tests.omnigraph_test_utils import _test_clear_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_setup_scene
from omni.graph.core.tests.omnigraph_test_utils import _test_verify_scene
class TestOgn(ogts.OmniGraphTestCase):
TEST_DATA = [
{
'inputs': [
['inputs:rotation', {'type': 'matrixd[4]', 'value': [1, 0, 0, 0, 0, 1, 0, 0, 10, 10, 1, 0, 50, 0, 0, 1]}, False],
['inputs:vector', {'type': 'vectord[3]', 'value': [1, 2, 3]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectord[3]', 'value': [31, 32, 3]}, False],
],
},
{
'inputs': [
['inputs:rotation', {'type': 'matrixd[3]', 'value': [1, 0, 0, 0, 0, 1, 0, -1, 0]}, False],
['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectorf[3]', 'value': [0, -1, 0]}, False],
],
},
{
'inputs': [
['inputs:rotation', {'type': 'vectord[3]', 'value': [90, 0, 0]}, False],
['inputs:vector', {'type': 'vectord[3]', 'value': [0, 0, 1]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectord[3]', 'value': [0, -1, 0]}, False],
],
},
{
'inputs': [
['inputs:rotation', {'type': 'quatf[4]', 'value': [0.7071068, 0, 0, 0.7071068]}, False],
['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectorf[3]', 'value': [0, -1, 0]}, False],
],
},
{
'inputs': [
['inputs:rotation', {'type': 'vectorf[3][]', 'value': [[0, 90, 0], [90, 0, 0], [90, 90, 0]]}, False],
['inputs:vector', {'type': 'vectorf[3]', 'value': [0, 0, 1]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectorf[3][]', 'value': [[1, 0, 0], [0, -1, 0], [0, -1, 0]]}, False],
],
},
{
'inputs': [
['inputs:rotation', {'type': 'vectord[3]', 'value': [90, 90, 0]}, False],
['inputs:vector', {'type': 'vectord[3][]', 'value': [[0, 0, 1], [0, 1, 0], [1, 0, 0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'vectord[3][]', 'value': [[0, -1, 0], [1, 0, 0], [0, 0, -1]]}, False],
],
},
]
async def test_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RotateVector", "omni.graph.nodes.RotateVector", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}")
async def test_vectorized_generated(self):
test_info = _TestGraphAndNode()
controller = og.Controller()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
test_info = await _test_setup_scene(self, controller, "/TestGraph", "TestNode_omni_graph_nodes_RotateVector","omni.graph.nodes.RotateVector", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}", 16)
async def test_thread_safety(self):
import omni.kit
# Generate multiple instances of the test setup to run them concurrently
instance_setup = dict()
for n in range(24):
instance_setup[f"/TestGraph_{n}"] = _TestGraphAndNode()
for i, test_run in enumerate(self.TEST_DATA):
await _test_clear_scene(self, test_run)
for (key, test_info) in instance_setup.items():
test_info = await _test_setup_scene(self, og.Controller(allow_exists_prim=True), key, "TestNode_omni_graph_nodes_RotateVector", "omni.graph.nodes.RotateVector", test_run, test_info)
self.assertEqual(len(og.get_all_graphs()), 24)
# We want to evaluate all graphs concurrently. Kick them all.
# Evaluate multiple times to skip 2 serial frames and increase chances for a race condition.
for _ in range(10):
await omni.kit.app.get_app().next_update_async()
for (key, test_instance) in instance_setup.items():
_test_verify_scene(self, og.Controller(), test_run, test_info, f"omni.graph.nodes.RotateVector User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRotateVectorDatabase import OgnRotateVectorDatabase
test_file_name = "OgnRotateVectorTemplate.usda"
usd_path = os.path.join(os.path.dirname(__file__), "usd", test_file_name)
if not os.path.exists(usd_path):
self.assertTrue(False, f"{usd_path} not found for loading test")
(result, error) = await ogts.load_test_file(usd_path)
self.assertTrue(result, f'{error} on {usd_path}')
test_node = og.Controller.node("/TestGraph/Template_omni_graph_nodes_RotateVector")
database = OgnRotateVectorDatabase(test_node)
self.assertTrue(test_node.is_valid())
node_type_name = test_node.get_type_name()
self.assertEqual(og.GraphRegistry().get_node_type_version(node_type_name), 1)
def _attr_error(attribute: og.Attribute, usd_test: bool) -> str:
test_type = "USD Load" if usd_test else "Database Access"
return f"{node_type_name} {test_type} Test - {attribute.get_name()} value error"
| 6,189 | Python | 47.740157 | 197 | 0.55324 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.