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/nodes/animation/OgnTimelineSet.cpp | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include "TimelineCommon.h"
#include <omni/timeline/ITimeline.h>
#include <OgnTimelineSetDatabase.h>
namespace omni
{
namespace graph
{
namespace nodes
{
class OgnTimelineSet
{
public:
static bool compute(OgnTimelineSetDatabase& db)
{
auto handler = [&db](timeline::TimelinePtr const& timeline)
{
auto const value = db.inputs.propValue();
bool clamped = false;
auto setTime = [&timeline](double desiredTime) -> bool
{
auto const startTime = timeline->getStartTime();
auto const endTime = timeline->getEndTime();
auto const clampedTime = std::clamp(desiredTime, startTime, endTime);
timeline->setCurrentTime(clampedTime);
return clampedTime != desiredTime; // NOLINT(clang-diagnostic-float-equal)
};
auto const propName = db.inputs.propName();
if (propName == OgnTimelineSetDatabase::tokens.Time)
clamped = setTime(value);
else if (propName == OgnTimelineSetDatabase::tokens.StartTime)
timeline->setStartTime(value);
else if (propName == OgnTimelineSetDatabase::tokens.EndTime)
timeline->setEndTime(value);
else if (propName == OgnTimelineSetDatabase::tokens.FramesPerSecond)
timeline->setTimeCodesPerSecond(value);
else
{
// The property to set is frame-based, convert to time in seconds.
auto const time = timeline->timeCodeToTime(value);
if (propName == OgnTimelineSetDatabase::tokens.Frame)
clamped = setTime(time);
else if (propName == OgnTimelineSetDatabase::tokens.StartFrame)
timeline->setStartTime(time);
else if (propName == OgnTimelineSetDatabase::tokens.EndFrame)
timeline->setEndTime(time);
}
db.outputs.clamped() = clamped;
return true;
};
return timelineNodeExecute(db, handler);
}
};
REGISTER_OGN_NODE()
}
}
}
| 2,579 | C++ | 32.947368 | 90 | 0.621559 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/nodes/animation/OgnTimelineLoop.cpp | // Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
//
// NVIDIA CORPORATION and its licensors retain all intellectual property
// and proprietary rights in and to this software, related documentation
// and any modifications thereto. Any use, reproduction, disclosure or
// distribution of this software and related documentation without an express
// license agreement from NVIDIA CORPORATION is strictly prohibited.
//
#include "TimelineCommon.h"
#include <omni/timeline/ITimeline.h>
#include <OgnTimelineLoopDatabase.h>
namespace omni
{
namespace graph
{
namespace nodes
{
class OgnTimelineLoop
{
public:
static bool compute(OgnTimelineLoopDatabase& db)
{
auto handler = [&db](timeline::TimelinePtr const& timeline)
{
auto const loop = db.inputs.loop();
timeline->setLooping(loop);
return true;
};
return timelineNodeExecute(db, handler);
}
};
REGISTER_OGN_NODE()
}
}
}
| 973 | C++ | 22.190476 | 77 | 0.707091 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayResize.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:newSize', 0, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': []}, False],
['inputs:newSize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'int64[]', 'value': [0]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42]}, False],
['inputs:newSize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, True]}, False],
['inputs:newSize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'bool[]', 'value': [True]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:newSize', 3, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4], [0, 0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': []}, False],
['inputs:newSize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[0, 0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'float[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:newSize', 3, False],
],
'outputs': [
['outputs:array', {'type': 'float[2][]', 'value': [[1, 2], [3, 4], [0, 0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:newSize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['41']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:newSize', 2, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['41', '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_ArrayResize", "omni.graph.nodes.ArrayResize", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayResize 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_ArrayResize","omni.graph.nodes.ArrayResize", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayResize 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_ArrayResize", "omni.graph.nodes.ArrayResize", 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.ArrayResize User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayResizeDatabase import OgnArrayResizeDatabase
test_file_name = "OgnArrayResizeTemplate.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_ArrayResize")
database = OgnArrayResizeDatabase(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:newSize"))
attribute = test_node.get_attribute("inputs:newSize")
db_value = database.inputs.newSize
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,031 | Python | 42.407407 | 195 | 0.534917 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNand.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', True, 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, True, True, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [True, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:result', [True, 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_BooleanNand", "omni.graph.nodes.BooleanNand", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNand 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_BooleanNand","omni.graph.nodes.BooleanNand", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNand 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_BooleanNand", "omni.graph.nodes.BooleanNand", 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.BooleanNand User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNandDatabase import OgnNandDatabase
test_file_name = "OgnNandTemplate.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_BooleanNand")
database = OgnNandDatabase(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,049 | Python | 45.330275 | 195 | 0.591404 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnStopSound.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.OgnStopSoundDatabase import OgnStopSoundDatabase
test_file_name = "OgnStopSoundTemplate.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_StopSound")
database = OgnStopSoundDatabase(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:soundId"))
attribute = test_node.get_attribute("inputs:soundId")
db_value = database.inputs.soundId
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("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,277 | Python | 47.468084 | 92 | 0.695652 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExtractPrim.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.OgnExtractPrimDatabase import OgnExtractPrimDatabase
test_file_name = "OgnExtractPrimTemplate.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_ExtractPrim")
database = OgnExtractPrimDatabase(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
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:prims"))
attribute = test_node.get_attribute("inputs:prims")
db_value = database.inputs.prims
self.assertTrue(test_node.get_attribute_exists("outputs_primBundle"))
attribute = test_node.get_attribute("outputs_primBundle")
db_value = database.outputs.primBundle
| 2,468 | Python | 47.411764 | 92 | 0.6953 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArraySetIndex.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': 0}, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [0, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'int64', 'value': 0}, False],
],
'outputs': [
['outputs:array', {'type': 'int64[]', 'value': [0, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'uchar', 'value': 0}, False],
],
'outputs': [
['outputs:array', {'type': 'uchar[]', 'value': [0, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'uint', 'value': 0}, False],
],
'outputs': [
['outputs:array', {'type': 'uint[]', 'value': [0, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'uint64', 'value': 0}, False],
],
'outputs': [
['outputs:array', {'type': 'uint64[]', 'value': [0, 42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, True]}, False],
['inputs:index', 0, False],
['inputs:value', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:array', {'type': 'bool[]', 'value': [False, True]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:index', -1, False],
['inputs:value', {'type': 'token', 'value': ''}, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['41', '']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
['inputs:index', 3, False],
['inputs:resizeToFit', True, False],
['inputs:value', {'type': 'half[2]', 'value': [5.0, 6.0]}, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[1.0, 2.0], [3.0, 4.0], [0.0, 0.0], [5.0, 6.0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'float[2][]', 'value': [[1.0, 2.0], [3.0, 4.0]]}, False],
['inputs:index', 3, False],
['inputs:resizeToFit', True, False],
['inputs:value', {'type': 'float[2]', 'value': [5.0, 6.0]}, False],
],
'outputs': [
['outputs:array', {'type': 'float[2][]', 'value': [[1.0, 2.0], [3.0, 4.0], [0.0, 0.0], [5.0, 6.0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[3][]', 'value': [[1.0, 2.0, 3.0], [3.0, 4.0, 5.0]]}, False],
['inputs:index', 3, False],
['inputs:resizeToFit', True, False],
['inputs:value', {'type': 'double[3]', 'value': [5.0, 6.0, 7.0]}, False],
],
'outputs': [
['outputs:array', {'type': 'double[3][]', 'value': [[1.0, 2.0, 3.0], [3.0, 4.0, 5.0], [0.0, 0.0, 0.0], [5.0, 6.0, 7.0]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6]]}, False],
['inputs:index', 3, False],
['inputs:resizeToFit', True, False],
['inputs:value', {'type': 'int[4]', 'value': [5, 6, 7, 8]}, False],
],
'outputs': [
['outputs:array', {'type': 'int[4][]', 'value': [[1, 2, 3, 4], [3, 4, 5, 6], [0, 0, 0, 0], [5, 6, 7, 8]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:index', 3, False],
['inputs:resizeToFit', True, False],
['inputs:value', {'type': 'token', 'value': '43'}, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['41', '42', '', '43']}, 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_ArraySetIndex", "omni.graph.nodes.ArraySetIndex", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArraySetIndex 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_ArraySetIndex","omni.graph.nodes.ArraySetIndex", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArraySetIndex 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_ArraySetIndex", "omni.graph.nodes.ArraySetIndex", 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.ArraySetIndex User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArraySetIndexDatabase import OgnArraySetIndexDatabase
test_file_name = "OgnArraySetIndexTemplate.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_ArraySetIndex")
database = OgnArraySetIndexDatabase(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))
self.assertTrue(test_node.get_attribute_exists("inputs:resizeToFit"))
attribute = test_node.get_attribute("inputs:resizeToFit")
db_value = database.inputs.resizeToFit
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))
| 9,833 | Python | 44.953271 | 199 | 0.507373 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRound.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': 'float', 'value': 1.3}, False],
['inputs:decimals', 0, False],
],
'outputs': [
['outputs:output', {'type': 'float', 'value': 1}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double', 'value': 1.3}, False],
['inputs:decimals', 0, False],
],
'outputs': [
['outputs:output', {'type': 'double', 'value': 1}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half', 'value': 1.3}, False],
['inputs:decimals', 0, False],
],
'outputs': [
['outputs:output', {'type': 'half', 'value': 1}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2]', 'value': [-3.5352, 4.341]}, False],
['inputs:decimals', 2, False],
],
'outputs': [
['outputs:output', {'type': 'float[2]', 'value': [-3.54, 4.34]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[3]', 'value': [-3.5352, 4.341, -3.5352]}, False],
['inputs:decimals', 2, False],
],
'outputs': [
['outputs:output', {'type': 'double[3]', 'value': [-3.54, 4.34, -3.54]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[4]', 'value': [-3.5352, 4.341, -3.5352, 4.341]}, False],
['inputs:decimals', 2, False],
],
'outputs': [
['outputs:output', {'type': 'half[4]', 'value': [-3.5390625, 4.3398438, -3.5390625, 4.3398438]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[]', 'value': [132, 22221.2, 5.531]}, False],
['inputs:decimals', -1, False],
],
'outputs': [
['outputs:output', {'type': 'double[]', 'value': [130, 22220, 10]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[]', 'value': [132]}, False],
['inputs:decimals', -1, False],
],
'outputs': [
['outputs:output', {'type': 'float[]', 'value': [130]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[2][]', 'value': [[132, 22221.2], [5.531, 132]]}, False],
['inputs:decimals', -1, False],
],
'outputs': [
['outputs:output', {'type': 'half[2][]', 'value': [[130.0, 22224.0], [10.0, 130.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_Round", "omni.graph.nodes.Round", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Round 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_Round","omni.graph.nodes.Round", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Round 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_Round", "omni.graph.nodes.Round", 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.Round User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRoundDatabase import OgnRoundDatabase
test_file_name = "OgnRoundTemplate.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_Round")
database = OgnRoundDatabase(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:decimals"))
attribute = test_node.get_attribute("inputs:decimals")
db_value = database.inputs.decimals
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,064 | Python | 42.611111 | 183 | 0.539921 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRotateToOrientation.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.OgnRotateToOrientationDatabase import OgnRotateToOrientationDatabase
test_file_name = "OgnRotateToOrientationTemplate.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_RotateToOrientation")
database = OgnRotateToOrientationDatabase(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,807 | Python | 49.773333 | 102 | 0.692146 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimPath.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.OgnGetPrimPathDatabase import OgnGetPrimPathDatabase
test_file_name = "OgnGetPrimPathTemplate.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_GetPrimPath")
database = OgnGetPrimPathDatabase(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:prim"))
attribute = test_node.get_attribute("inputs:prim")
db_value = database.inputs.prim
self.assertTrue(test_node.get_attribute_exists("outputs:path"))
attribute = test_node.get_attribute("outputs:path")
db_value = database.outputs.path
self.assertTrue(test_node.get_attribute_exists("outputs:primPath"))
attribute = test_node.get_attribute("outputs:primPath")
db_value = database.outputs.primPath
| 2,028 | Python | 46.186045 | 92 | 0.697732 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantUChar.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.OgnConstantUCharDatabase import OgnConstantUCharDatabase
test_file_name = "OgnConstantUCharTemplate.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_ConstantUChar")
database = OgnConstantUCharDatabase(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
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.700155 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetVariantSelection.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.OgnGetVariantSelectionDatabase import OgnGetVariantSelectionDatabase
test_file_name = "OgnGetVariantSelectionTemplate.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_GetVariantSelection")
database = OgnGetVariantSelectionDatabase(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:variantName"))
attribute = test_node.get_attribute("outputs:variantName")
db_value = database.outputs.variantName
| 2,355 | Python | 49.127659 | 102 | 0.704883 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadGamepadState.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.OgnReadGamepadStateDatabase import OgnReadGamepadStateDatabase
test_file_name = "OgnReadGamepadStateTemplate.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_ReadGamepadState")
database = OgnReadGamepadStateDatabase(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:deadzone"))
attribute = test_node.get_attribute("inputs:deadzone")
db_value = database.inputs.deadzone
expected_value = 0.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:gamepadElement"))
attribute = test_node.get_attribute("inputs:gamepadElement")
db_value = database.inputs.gamepadElement
expected_value = "Left Stick X Axis"
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:gamepadId"))
attribute = test_node.get_attribute("inputs:gamepadId")
db_value = database.inputs.gamepadId
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("outputs:isPressed"))
attribute = test_node.get_attribute("outputs:isPressed")
db_value = database.outputs.isPressed
self.assertTrue(test_node.get_attribute_exists("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
| 3,228 | Python | 50.253967 | 96 | 0.698575 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGraphTarget.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.OgnGraphTargetDatabase import OgnGraphTargetDatabase
test_file_name = "OgnGraphTargetTemplate.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_GraphTarget")
database = OgnGraphTargetDatabase(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:targetPath"))
attribute = test_node.get_attribute("inputs:targetPath")
db_value = database.inputs.targetPath
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:primPath"))
attribute = test_node.get_attribute("outputs:primPath")
db_value = database.outputs.primPath
| 2,123 | Python | 48.395348 | 92 | 0.699482 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInsertAttr.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.OgnInsertAttrDatabase import OgnInsertAttrDatabase
test_file_name = "OgnInsertAttrTemplate.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_InsertAttribute")
database = OgnInsertAttrDatabase(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:outputAttrName"))
attribute = test_node.get_attribute("inputs:outputAttrName")
db_value = database.inputs.outputAttrName
expected_value = "attr0"
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,299 | Python | 47.936169 | 94 | 0.697695 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSin.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': 30.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_Sin", "omni.graph.nodes.Sin", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Sin 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_Sin","omni.graph.nodes.Sin", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Sin 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_Sin", "omni.graph.nodes.Sin", 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.Sin User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSinDatabase import OgnSinDatabase
test_file_name = "OgnSinTemplate.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_Sin")
database = OgnSinDatabase(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,206 | Python | 46.269662 | 179 | 0.62601 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimPaths.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.OgnGetPrimPathsDatabase import OgnGetPrimPathsDatabase
test_file_name = "OgnGetPrimPathsTemplate.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_GetPrimPaths")
database = OgnGetPrimPathsDatabase(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:primPaths"))
attribute = test_node.get_attribute("outputs:primPaths")
db_value = database.outputs.primPaths
| 1,865 | Python | 46.846153 | 92 | 0.701877 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetAttrNames.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.OgnGetAttrNamesDatabase import OgnGetAttrNamesDatabase
test_file_name = "OgnGetAttrNamesTemplate.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_GetAttributeNames")
database = OgnGetAttrNamesDatabase(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:sort"))
attribute = test_node.get_attribute("inputs:sort")
db_value = database.inputs.sort
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:output"))
attribute = test_node.get_attribute("outputs:output")
db_value = database.outputs.output
| 2,282 | Python | 47.574467 | 96 | 0.696319 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomBoolean.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', 14092058508772706262, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', False, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 5527295704097554033, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', False, 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', True, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 1955209015103813879, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', True, 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_RandomBoolean", "omni.graph.nodes.RandomBoolean", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomBoolean 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_RandomBoolean","omni.graph.nodes.RandomBoolean", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomBoolean 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_RandomBoolean", "omni.graph.nodes.RandomBoolean", 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.RandomBoolean User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomBooleanDatabase import OgnRandomBooleanDatabase
test_file_name = "OgnRandomBooleanTemplate.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_RandomBoolean")
database = OgnRandomBooleanDatabase(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
| 6,911 | Python | 44.17647 | 199 | 0.620171 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantTexCoord3h.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.OgnConstantTexCoord3hDatabase import OgnConstantTexCoord3hDatabase
test_file_name = "OgnConstantTexCoord3hTemplate.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_ConstantTexCoord3h")
database = OgnConstantTexCoord3hDatabase(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,970 | Python | 49.53846 | 100 | 0.701523 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnOr.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', True, 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, True, True, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, 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_BooleanOr", "omni.graph.nodes.BooleanOr", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanOr 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_BooleanOr","omni.graph.nodes.BooleanOr", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanOr 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_BooleanOr", "omni.graph.nodes.BooleanOr", 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.BooleanOr User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnOrDatabase import OgnOrDatabase
test_file_name = "OgnOrTemplate.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_BooleanOr")
database = OgnOrDatabase(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,023 | Python | 45.091743 | 191 | 0.589289 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadOmniGraphValue.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.OgnReadOmniGraphValueDatabase import OgnReadOmniGraphValueDatabase
test_file_name = "OgnReadOmniGraphValueTemplate.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_ReadOmniGraphValue")
database = OgnReadOmniGraphValueDatabase(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 = ""
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:path"))
attribute = test_node.get_attribute("inputs:path")
db_value = database.inputs.path
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))
| 2,376 | Python | 49.574467 | 100 | 0.69697 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNoise.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:seed', 5, False],
['inputs:position', {'type': 'float', 'value': 1.4}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.03438323736190796}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float', 'value': -1.4}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.03764888644218445}, False],
],
},
{
'inputs': [
['inputs:seed', 23, False],
['inputs:position', {'type': 'float', 'value': 1.4}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.1955927014350891}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[2]', 'value': [1.7, -0.4]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.10021606087684631}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[2]', 'value': [-0.4, 1.7]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.4338015019893646}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [1.4, -0.8, 0.5]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.14821206033229828}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [1.5, -0.8, 0.5]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.11368121206760406}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [1.4, -0.9, 0.5]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.16395819187164307}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [1.4, -0.8, 0.8]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.00016325712203979492}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [1.5, -0.9, 0.8]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.03829096257686615}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3]', 'value': [2.5, -0.9, 0.8]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.034046247601509094}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[4]', 'value': [2.5, -0.9, 0.8, 0.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.009762797504663467}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[4]', 'value': [2.5, -0.9, 0.8, 0.1]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -0.07352154701948166}, False],
],
},
{
'inputs': [
['inputs:seed', 6, False],
['inputs:position', {'type': 'float[4]', 'value': [2.5, -0.9, 0.8, 0.1]}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.2615857422351837}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[]', 'value': [-1.4]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [-0.03764889]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[]', 'value': [0.5, -1.4]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.18699697, -0.03764889]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[2][]', 'value': [[1.5, -0.8]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.16450586915016174]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[2][]', 'value': [[1.5, -0.8], [2.5, -0.9]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.16450587, 0.08753645]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3][]', 'value': [[1.5, -0.8, 0.5]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [-0.11368121206760406]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3][]', 'value': [[1.5, -0.8, 0.5], [1.4, -0.8, 0.5]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [-0.11368121206760406, -0.14821206033229828]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[3][]', 'value': [[2.5, -0.9, 0.8], [1.5, -0.8, 0.5], [1.4, -0.8, 0.5]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.034046247601509094, -0.11368121206760406, -0.14821206033229828]}, False],
],
},
{
'inputs': [
['inputs:seed', 5, False],
['inputs:position', {'type': 'float[4][]', 'value': [[2.5, -0.9, 0.8, 0.0], [2.5, -0.9, 0.8, 0.1]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [-0.009762797504663467, -0.07352154701948166]}, 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_Noise", "omni.graph.nodes.Noise", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Noise 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_Noise","omni.graph.nodes.Noise", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Noise 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_Noise", "omni.graph.nodes.Noise", 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.Noise User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNoiseDatabase import OgnNoiseDatabase
test_file_name = "OgnNoiseTemplate.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_Noise")
database = OgnNoiseDatabase(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:seed"))
attribute = test_node.get_attribute("inputs:seed")
db_value = database.inputs.seed
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))
| 11,523 | Python | 40.304659 | 183 | 0.474963 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstructArray.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.OgnConstructArrayDatabase import OgnConstructArrayDatabase
test_file_name = "OgnConstructArrayTemplate.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_ConstructArray")
database = OgnConstructArrayDatabase(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:arraySize"))
attribute = test_node.get_attribute("inputs:arraySize")
db_value = database.inputs.arraySize
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:arrayType"))
attribute = test_node.get_attribute("inputs:arrayType")
db_value = database.inputs.arrayType
expected_value = "auto"
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))
| 2,389 | Python | 49.851063 | 93 | 0.699456 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrimsBundle.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.OgnReadPrimsBundleDatabase import OgnReadPrimsBundleDatabase
test_file_name = "OgnReadPrimsBundleTemplate.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_ReadPrimsBundle")
database = OgnReadPrimsBundleDatabase(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: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:usePaths"))
attribute = test_node.get_attribute("inputs:usePaths")
db_value = database.inputs.usePaths
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:attrNamesToImport"))
attribute = test_node.get_attribute("state:attrNamesToImport")
db_value = database.state.attrNamesToImport
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:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
self.assertTrue(test_node.get_attribute_exists("state:usePaths"))
attribute = test_node.get_attribute("state:usePaths")
db_value = database.state.usePaths
| 3,823 | Python | 49.986666 | 94 | 0.700497 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnInvertMatrix.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[3]', 'value': [1, 0, 0, 0, 1, 0, 0, 0, 1]}, False],
],
'outputs': [
['outputs:invertedMatrix', {'type': 'matrixd[3]', 'value': [1, 0, 0, 0, 1, 0, 0, 0, 1]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [5, 6, 6, 8, 2, 2, 2, 8, 6, 6, 2, 8, 2, 3, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]]}, False],
],
'outputs': [
['outputs:invertedMatrix', {'type': 'matrixd[4][]', 'value': [[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [-17, -9, 12, 16, 17, 8.75, -11.75, -16, -4, -2.25, 2.75, 4, 1, 0.75, -0.75, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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_OgnInvertMatrix", "omni.graph.nodes.OgnInvertMatrix", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.OgnInvertMatrix 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_OgnInvertMatrix","omni.graph.nodes.OgnInvertMatrix", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.OgnInvertMatrix 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_OgnInvertMatrix", "omni.graph.nodes.OgnInvertMatrix", 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.OgnInvertMatrix User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnInvertMatrixDatabase import OgnInvertMatrixDatabase
test_file_name = "OgnInvertMatrixTemplate.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_OgnInvertMatrix")
database = OgnInvertMatrixDatabase(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,778 | Python | 52.696629 | 269 | 0.615948 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExponent.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:base', {'type': 'float', 'value': 2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 4.0}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'double', 'value': 0.5}, False],
['inputs:exponent', 3, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 0.125}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'half[2]', 'value': [5.0, 0.5]}, False],
['inputs:exponent', 3, False],
],
'outputs': [
['outputs:result', {'type': 'half[2]', 'value': [125.0, 0.125]}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'float[]', 'value': [1.0, 3.0]}, False],
['inputs:exponent', 3, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [1.0, 27.0]}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'float[2][]', 'value': [[1.0, 0.3], [0.5, 3.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[1.0, 0.09], [0.25, 9.0]]}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'int', 'value': 2147483647}, False],
['inputs:exponent', 0, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.0}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:exponent', 1, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 9.223372036854776e+18}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'int', 'value': 5}, False],
['inputs:exponent', -1, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 0.2}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'float', 'value': -2.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 4.0}, False],
],
},
{
'inputs': [
['inputs:base', {'type': 'float', 'value': -2.0}, False],
['inputs:exponent', 3, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': -8.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_Exponent", "omni.graph.nodes.Exponent", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Exponent 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_Exponent","omni.graph.nodes.Exponent", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Exponent 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_Exponent", "omni.graph.nodes.Exponent", 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.Exponent User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnExponentDatabase import OgnExponentDatabase
test_file_name = "OgnExponentTemplate.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_Exponent")
database = OgnExponentDatabase(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:exponent"))
attribute = test_node.get_attribute("inputs:exponent")
db_value = database.inputs.exponent
expected_value = 2
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,134 | Python | 41.470238 | 189 | 0.536445 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetRelativePath.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:anchor', "/World", False],
['inputs:path', {'type': 'token', 'value': '/World'}, False],
],
'outputs': [
['outputs:relativePath', {'type': 'token', 'value': '.'}, False],
],
},
{
'inputs': [
['inputs:anchor', "/World", False],
['inputs:path', {'type': 'token', 'value': '/World/foo'}, False],
],
'outputs': [
['outputs:relativePath', {'type': 'token', 'value': 'foo'}, False],
],
},
{
'inputs': [
['inputs:anchor', "/World", False],
['inputs:path', {'type': 'token', 'value': '/World/foo/bar'}, False],
],
'outputs': [
['outputs:relativePath', {'type': 'token', 'value': 'foo/bar'}, False],
],
},
{
'inputs': [
['inputs:anchor', "/World", False],
['inputs:path', {'type': 'token', 'value': '/World/foo/bar.attrib'}, False],
],
'outputs': [
['outputs:relativePath', {'type': 'token', 'value': 'foo/bar.attrib'}, False],
],
},
{
'inputs': [
['inputs:anchor', "/World", False],
['inputs:path', {'type': 'token[]', 'value': ['/World/foo', '/World/bar']}, False],
],
'outputs': [
['outputs:relativePath', {'type': 'token[]', 'value': ['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_GetRelativePath", "omni.graph.nodes.GetRelativePath", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetRelativePath 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_GetRelativePath","omni.graph.nodes.GetRelativePath", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetRelativePath 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_GetRelativePath", "omni.graph.nodes.GetRelativePath", 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.GetRelativePath User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetRelativePathDatabase import OgnGetRelativePathDatabase
test_file_name = "OgnGetRelativePathTemplate.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_GetRelativePath")
database = OgnGetRelativePathDatabase(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:anchor"))
attribute = test_node.get_attribute("inputs:anchor")
db_value = database.inputs.anchor
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("state:anchor"))
attribute = test_node.get_attribute("state:anchor")
db_value = database.state.anchor
self.assertTrue(test_node.get_attribute_exists("state:path"))
attribute = test_node.get_attribute("state:path")
db_value = database.state.path
| 6,228 | Python | 45.485074 | 203 | 0.601638 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetLocationAtDistanceOnCurve.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:curve', [[1, 2, 3]], False],
['inputs:distance', [0.5], False],
],
'outputs': [
['outputs:location', [[1, 2, 3]], False],
],
},
{
'inputs': [
['inputs:curve', [[0, 0, 0], [0, 0, 1]], False],
['inputs:distance', [0.75, 0], False],
['inputs:forwardAxis', "X", False],
['inputs:upAxis', "Y", False],
],
'outputs': [
['outputs:location', [[0, 0, 0.5], [0, 0, 0]], False],
['outputs:rotateXYZ', [[0, 90, 0], [0, -90, 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_GetLocationAtDistanceOnCurve", "omni.graph.nodes.GetLocationAtDistanceOnCurve", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLocationAtDistanceOnCurve 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_GetLocationAtDistanceOnCurve","omni.graph.nodes.GetLocationAtDistanceOnCurve", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLocationAtDistanceOnCurve 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_GetLocationAtDistanceOnCurve", "omni.graph.nodes.GetLocationAtDistanceOnCurve", 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.GetLocationAtDistanceOnCurve User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetLocationAtDistanceOnCurveDatabase import OgnGetLocationAtDistanceOnCurveDatabase
test_file_name = "OgnGetLocationAtDistanceOnCurveTemplate.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_GetLocationAtDistanceOnCurve")
database = OgnGetLocationAtDistanceOnCurveDatabase(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:curve"))
attribute = test_node.get_attribute("inputs:curve")
db_value = database.inputs.curve
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:distance"))
attribute = test_node.get_attribute("inputs:distance")
db_value = database.inputs.distance
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:forwardAxis"))
attribute = test_node.get_attribute("inputs:forwardAxis")
db_value = database.inputs.forwardAxis
expected_value = "X"
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:upAxis"))
attribute = test_node.get_attribute("inputs:upAxis")
db_value = database.inputs.upAxis
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))
self.assertTrue(test_node.get_attribute_exists("outputs:location"))
attribute = test_node.get_attribute("outputs:location")
db_value = database.outputs.location
self.assertTrue(test_node.get_attribute_exists("outputs:orientation"))
attribute = test_node.get_attribute("outputs:orientation")
db_value = database.outputs.orientation
self.assertTrue(test_node.get_attribute_exists("outputs:rotateXYZ"))
attribute = test_node.get_attribute("outputs:rotateXYZ")
db_value = database.outputs.rotateXYZ
| 6,929 | Python | 49.217391 | 229 | 0.66734 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToToken.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.8, 2.2, 3]}, False],
],
'outputs': [
['outputs:converted', "[1.8, 2.2, 3]", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4.5]}, False],
],
'outputs': [
['outputs:converted', "[2, 3, 4.5]", 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': 'token', 'value': 'Foo'}, False],
],
'outputs': [
['outputs:converted', "Foo", False],
],
},
{
'inputs': [
['inputs:value', {'type': 'string', 'value': 'Foo'}, False],
],
'outputs': [
['outputs:converted', "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_ToToken", "omni.graph.nodes.ToToken", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToToken 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_ToToken","omni.graph.nodes.ToToken", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToToken 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_ToToken", "omni.graph.nodes.ToToken", 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.ToToken User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToTokenDatabase import OgnToTokenDatabase
test_file_name = "OgnToTokenTemplate.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_ToToken")
database = OgnToTokenDatabase(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
| 6,048 | Python | 39.597315 | 187 | 0.544147 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTranslateToLocation.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.OgnTranslateToLocationDatabase import OgnTranslateToLocationDatabase
test_file_name = "OgnTranslateToLocationTemplate.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_TranslateToLocation")
database = OgnTranslateToLocationDatabase(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,807 | Python | 49.773333 | 102 | 0.692146 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeArray.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': 1}, False],
['inputs:b', {'type': 'float', 'value': 1}, False],
['inputs:c', {'type': 'float', 'value': 1}, False],
['inputs:d', {'type': 'float', 'value': 1}, False],
['inputs:e', {'type': 'float', 'value': 1}, False],
['inputs:arraySize', 1, False],
],
'outputs': [
['outputs:array', {'type': 'float[]', 'value': [1]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [1, 2]}, False],
['inputs:b', {'type': 'float[2]', 'value': [1, 3]}, False],
['inputs:c', {'type': 'float[2]', 'value': [1, 4]}, False],
['inputs:d', {'type': 'float[2]', 'value': [1, 5]}, False],
['inputs:e', {'type': 'float[2]', 'value': [1, 6]}, False],
['inputs:arraySize', 5, False],
],
'outputs': [
['outputs:array', {'type': 'float[2][]', 'value': [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'foo'}, False],
['inputs:b', {'type': 'token', 'value': 'foo'}, False],
['inputs:c', {'type': 'token', 'value': 'foo'}, False],
['inputs:d', {'type': 'token', 'value': 'foo'}, False],
['inputs:e', {'type': 'token', 'value': 'foo'}, False],
['inputs:arraySize', 5, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['foo', 'foo', 'foo', 'foo', 'foo']}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 42}, False],
['inputs:b', {'type': 'uchar', 'value': 42}, False],
['inputs:c', {'type': 'uchar', 'value': 42}, False],
['inputs:d', {'type': 'uchar', 'value': 42}, False],
['inputs:e', {'type': 'uchar', 'value': 42}, False],
['inputs:arraySize', 5, False],
],
'outputs': [
['outputs:array', {'type': 'uchar[]', 'value': [42, 42, 42, 42, 42]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:b', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:c', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:d', {'type': 'double[4]', 'value': [1, 2, 3, 4]}, False],
['inputs:e', {'type': 'double[4]', 'value': [1, 2, 3, 5]}, False],
['inputs:arraySize', 6, False],
],
'outputs': [
['outputs:array', {'type': 'double[4][]', 'value': [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 3, 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_MakeArray", "omni.graph.nodes.MakeArray", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeArray 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_MakeArray","omni.graph.nodes.MakeArray", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeArray User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeArrayDatabase import OgnMakeArrayDatabase
test_file_name = "OgnMakeArrayTemplate.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_MakeArray")
database = OgnMakeArrayDatabase(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:arraySize"))
attribute = test_node.get_attribute("inputs:arraySize")
db_value = database.inputs.arraySize
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,241 | Python | 48.936 | 172 | 0.516424 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNot.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:valueIn', {'type': 'bool', 'value': True}, False],
],
'outputs': [
['outputs:valueOut', False, False],
],
},
{
'inputs': [
['inputs:valueIn', {'type': 'bool', 'value': False}, False],
],
'outputs': [
['outputs:valueOut', True, False],
],
},
{
'inputs': [
['inputs:valueIn', {'type': 'bool[]', 'value': [True, False, True, False]}, False],
],
'outputs': [
['outputs:valueOut', [False, True, 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_BooleanNot", "omni.graph.nodes.BooleanNot", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNot 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_BooleanNot","omni.graph.nodes.BooleanNot", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanNot 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_BooleanNot", "omni.graph.nodes.BooleanNot", 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.BooleanNot User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNotDatabase import OgnNotDatabase
test_file_name = "OgnNotTemplate.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_BooleanNot")
database = OgnNotDatabase(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,498 | Python | 45.381443 | 193 | 0.618942 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimLocalToWorldTransform.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.OgnGetPrimLocalToWorldTransformDatabase import OgnGetPrimLocalToWorldTransformDatabase
test_file_name = "OgnGetPrimLocalToWorldTransformTemplate.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_GetPrimLocalToWorldTransform")
database = OgnGetPrimLocalToWorldTransformDatabase(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:localToWorldTransform"))
attribute = test_node.get_attribute("outputs:localToWorldTransform")
db_value = database.outputs.localToWorldTransform
| 2,674 | Python | 51.450979 | 120 | 0.710172 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToFloat.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': 'float[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', {'type': 'float', 'value': 2.1}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'float', 'value': 42.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2]', 'value': [2.1, 2.1]}, False],
],
'outputs': [
['outputs:converted', {'type': 'float[2]', 'value': [2.1, 2.1]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'float[3]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'float[3][]', 'value': [[2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'float[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_ToFloat", "omni.graph.nodes.ToFloat", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToFloat 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_ToFloat","omni.graph.nodes.ToFloat", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToFloat 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_ToFloat", "omni.graph.nodes.ToFloat", 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.ToFloat User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToFloatDatabase import OgnToFloatDatabase
test_file_name = "OgnToFloatTemplate.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_ToFloat")
database = OgnToFloatDatabase(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,632 | Python | 42.666666 | 187 | 0.553089 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantTexCoord3f.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.OgnConstantTexCoord3fDatabase import OgnConstantTexCoord3fDatabase
test_file_name = "OgnConstantTexCoord3fTemplate.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_ConstantTexCoord3f")
database = OgnConstantTexCoord3fDatabase(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,970 | Python | 49.53846 | 100 | 0.701523 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetPrimRelationship.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.OgnGetPrimRelationshipDatabase import OgnGetPrimRelationshipDatabase
test_file_name = "OgnGetPrimRelationshipTemplate.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_GetPrimRelationship")
database = OgnGetPrimRelationshipDatabase(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 = ""
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:paths"))
attribute = test_node.get_attribute("outputs:paths")
db_value = database.outputs.paths
| 2,570 | Python | 49.411764 | 102 | 0.698444 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantTexCoord2f.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.OgnConstantTexCoord2fDatabase import OgnConstantTexCoord2fDatabase
test_file_name = "OgnConstantTexCoord2fTemplate.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_ConstantTexCoord2f")
database = OgnConstantTexCoord2fDatabase(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/TestOgnNthRoot.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': 36.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 6.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 27.0}, False],
['inputs:nthRoot', 3, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 3.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[2]', 'value': [0.25, 4.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [0.5, 2.0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[]', 'value': [1.331, 8.0]}, False],
['inputs:nthRoot', 3, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [1.1, 2.0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[2][]', 'value': [[4.0, 16.0], [2.25, 64.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[2.0, 4.0], [1.5, 8.0]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:nthRoot', 1, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 9.223372036854776e+18}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 256}, False],
['inputs:nthRoot', 4, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 4.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uint64', 'value': 8}, False],
['inputs:nthRoot', 3, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 2.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[2]', 'value': [0.125, 1.0]}, False],
['inputs:nthRoot', 3, False],
],
'outputs': [
['outputs:result', {'type': 'half[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uchar', 'value': 25}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 5.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64', 'value': 16}, False],
['inputs:nthRoot', -2, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 0.25}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 0.125}, False],
['inputs:nthRoot', -3, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 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_NthRoot", "omni.graph.nodes.NthRoot", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.NthRoot 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_NthRoot","omni.graph.nodes.NthRoot", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.NthRoot 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_NthRoot", "omni.graph.nodes.NthRoot", 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.NthRoot User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNthRootDatabase import OgnNthRootDatabase
test_file_name = "OgnNthRootTemplate.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_NthRoot")
database = OgnNthRootDatabase(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:nthRoot"))
attribute = test_node.get_attribute("inputs:nthRoot")
db_value = database.inputs.nthRoot
expected_value = 2
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,684 | Python | 40.54054 | 187 | 0.520432 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDeformedPointsToHydra.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.OgnDeformedPointsToHydraDatabase import OgnDeformedPointsToHydraDatabase
test_file_name = "OgnDeformedPointsToHydraTemplate.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_DeformedPointsToHydra")
database = OgnDeformedPointsToHydraDatabase(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:points"))
attribute = test_node.get_attribute("inputs:points")
expected_value = []
actual_value = og.Controller.get(attribute)
ogts.verify_values(expected_value, actual_value, _attr_error(attribute, True))
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:sendToHydra"))
attribute = test_node.get_attribute("inputs:sendToHydra")
db_value = database.inputs.sendToHydra
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:stream"))
attribute = test_node.get_attribute("inputs:stream")
db_value = database.inputs.stream
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:verbose"))
attribute = test_node.get_attribute("inputs:verbose")
db_value = database.inputs.verbose
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:reload"))
attribute = test_node.get_attribute("outputs:reload")
db_value = database.outputs.reload
| 3,770 | Python | 50.657534 | 106 | 0.695491 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToUint64.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': 'uint64[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half', 'value': 2.9}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64', 'value': 2}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64', 'value': 42}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64', 'value': 42}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64[]', 'value': [1, 0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64[]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'uint[]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64[]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64[]', 'value': [2, 3, -4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'uint64[]', 'value': [2, 3, 18446744073709551612]}, 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_ToUint64", "omni.graph.nodes.ToUint64", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToUint64 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_ToUint64","omni.graph.nodes.ToUint64", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToUint64 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_ToUint64", "omni.graph.nodes.ToUint64", 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.ToUint64 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToUint64Database import OgnToUint64Database
test_file_name = "OgnToUint64Template.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_ToUint64")
database = OgnToUint64Database(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,129 | Python | 41.275862 | 189 | 0.539403 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEase.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:start', {'type': 'float', 'value': 0}, False],
['inputs:end', {'type': 'float', 'value': 10}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float', 'value': 0.5}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 5}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float[]', 'value': [0, 1]}, False],
['inputs:end', {'type': 'float[]', 'value': [10, 11]}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float[]', 'value': [0.5, 0.6]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [5, 7]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float[]', 'value': [0, 0]}, False],
['inputs:end', {'type': 'float', 'value': 10}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float[]', 'value': [0.5, 0.6]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [5, 6]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float', 'value': 0}, False],
['inputs:end', {'type': 'float', 'value': 10}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float[]', 'value': [0.5, 0.6]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [5, 6]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float[2]', 'value': [0, 0]}, False],
['inputs:end', {'type': 'float[2]', 'value': [10, 10]}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float[]', 'value': [0.5, 0.6]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[5, 5], [6, 6]]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float[2][]', 'value': [[0, 0], [10, 10]]}, False],
['inputs:end', {'type': 'float[2]', 'value': [10, 20]}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float[]', 'value': [0.5, 0.5]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2][]', 'value': [[5, 10], [10, 15]]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'double', 'value': 0.0}, False],
['inputs:end', {'type': 'double', 'value': 10.0}, False],
['inputs:easeFunc', "EaseInOut", False],
['inputs:alpha', {'type': 'float', 'value': 0.25}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.25}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'double', 'value': 0.0}, False],
['inputs:end', {'type': 'double', 'value': 10.0}, False],
['inputs:easeFunc', "SinOut", False],
['inputs:alpha', {'type': 'float', 'value': 0.75}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 9.238795}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float[2]', 'value': [0, 1]}, False],
['inputs:end', {'type': 'float[2]', 'value': [10.0, 11.0]}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float', 'value': 0.5}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [5.0, 6.0]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'half[3]', 'value': [0, 1, 2]}, False],
['inputs:end', {'type': 'half[3]', 'value': [10.0, 11.0, 12.0]}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float', 'value': 0.5}, False],
],
'outputs': [
['outputs:result', {'type': 'half[3]', 'value': [5.0, 6.0, 7.0]}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float', 'value': 0}, False],
['inputs:end', {'type': 'float', 'value': 10}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float', 'value': 1.524}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 10}, False],
],
},
{
'inputs': [
['inputs:start', {'type': 'float', 'value': 0}, False],
['inputs:end', {'type': 'float', 'value': 10}, False],
['inputs:easeFunc', "Linear", False],
['inputs:alpha', {'type': 'float', 'value': -20}, False],
],
'outputs': [
['outputs:result', {'type': 'float', '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_Ease", "omni.graph.nodes.Ease", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Ease 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_Ease","omni.graph.nodes.Ease", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Ease 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_Ease", "omni.graph.nodes.Ease", 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.Ease User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnEaseDatabase import OgnEaseDatabase
test_file_name = "OgnEaseTemplate.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_Ease")
database = OgnEaseDatabase(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:blendExponent"))
attribute = test_node.get_attribute("inputs:blendExponent")
db_value = database.inputs.blendExponent
expected_value = 2
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:easeFunc"))
attribute = test_node.get_attribute("inputs:easeFunc")
db_value = database.inputs.easeFunc
expected_value = "EaseInOut"
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,176 | Python | 45.049774 | 181 | 0.506879 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantUInt.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.OgnConstantUIntDatabase import OgnConstantUIntDatabase
test_file_name = "OgnConstantUIntTemplate.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_ConstantUInt")
database = OgnConstantUIntDatabase(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
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,926 | Python | 48.410255 | 92 | 0.699377 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnClearVariantSelection.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.OgnClearVariantSelectionDatabase import OgnClearVariantSelectionDatabase
test_file_name = "OgnClearVariantSelectionTemplate.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_ClearVariantSelection")
database = OgnClearVariantSelectionDatabase(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: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
| 2,973 | Python | 49.406779 | 106 | 0.700975 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAsin.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': 0.707107}, False],
],
'outputs': [
['outputs:value', {'type': 'float', 'value': 45.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 0.5}, False],
],
'outputs': [
['outputs:value', {'type': 'double', 'value': 30.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_Asin", "omni.graph.nodes.Asin", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Asin 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_Asin","omni.graph.nodes.Asin", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Asin 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_Asin", "omni.graph.nodes.Asin", 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.Asin User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAsinDatabase import OgnAsinDatabase
test_file_name = "OgnAsinTemplate.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_Asin")
database = OgnAsinDatabase(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,220 | Python | 46.426966 | 181 | 0.627251 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetMatrix4Translation.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],
],
'outputs': [
['outputs:translation', {'type': 'vectord[3]', 'value': [50, 0, 0]}, False],
],
},
{
'inputs': [
['inputs:matrix', {'type': 'matrixd[4][]', 'value': [[1.0, 0, 3, 0, 0, 1, 0, 1, 0, 0, 1, 0, 50, 0, 0, 1], [1.0, 0, 0, 3, 0, 1, 0, 1, 0, 0, 1, 0, 1, 100, 4, 1]]}, False],
],
'outputs': [
['outputs:translation', {'type': 'vectord[3][]', 'value': [[50, 0, 0], [1, 100, 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_GetMatrix4Translation", "omni.graph.nodes.GetMatrix4Translation", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Translation 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_GetMatrix4Translation","omni.graph.nodes.GetMatrix4Translation", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetMatrix4Translation 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_GetMatrix4Translation", "omni.graph.nodes.GetMatrix4Translation", 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.GetMatrix4Translation User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetMatrix4TranslationDatabase import OgnGetMatrix4TranslationDatabase
test_file_name = "OgnGetMatrix4TranslationTemplate.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_GetMatrix4Translation")
database = OgnGetMatrix4TranslationDatabase(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,668 | Python | 51.460674 | 215 | 0.634533 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCeil.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': 4.1}, False],
],
'outputs': [
['outputs:result', 5, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': -4.9}, False],
],
'outputs': [
['outputs:result', -4, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3]', 'value': [1.3, 2.4, -3.7]}, False],
],
'outputs': [
['outputs:result', [2, 3, -3], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [1.3, 2.4, -3.7, 4.5]}, False],
],
'outputs': [
['outputs:result', [2, 3, -3, 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_Ceil", "omni.graph.nodes.Ceil", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Ceil 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_Ceil","omni.graph.nodes.Ceil", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Ceil 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_Ceil", "omni.graph.nodes.Ceil", 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.Ceil User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCeilDatabase import OgnCeilDatabase
test_file_name = "OgnCeilTemplate.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_Ceil")
database = OgnCeilDatabase(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,637 | Python | 43.171428 | 181 | 0.590684 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnATan2.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': 5.0}, False],
['inputs:b', {'type': 'float', 'value': 3.0}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 59.0362434679}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double', 'value': 70.0}, False],
['inputs:b', {'type': 'double', 'value': 10.0}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 81.8698976458}, 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_ATan2", "omni.graph.nodes.ATan2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ATan2 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_ATan2","omni.graph.nodes.ATan2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ATan2 User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnATan2Database import OgnATan2Database
test_file_name = "OgnATan2Template.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_ATan2")
database = OgnATan2Database(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,279 | Python | 45.857142 | 164 | 0.609332 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnPartialSum.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', [1, 2, 3, 4, 5], False],
],
'outputs': [
['outputs:partialSum', [0, 1, 3, 6, 10, 15], 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_PartialSum", "omni.graph.nodes.PartialSum", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.PartialSum 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_PartialSum","omni.graph.nodes.PartialSum", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.PartialSum 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_PartialSum", "omni.graph.nodes.PartialSum", 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.PartialSum User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnPartialSumDatabase import OgnPartialSumDatabase
test_file_name = "OgnPartialSumTemplate.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_PartialSum")
database = OgnPartialSumDatabase(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:array"))
attribute = test_node.get_attribute("inputs:array")
db_value = database.inputs.array
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:partialSum"))
attribute = test_node.get_attribute("outputs:partialSum")
db_value = database.outputs.partialSum
| 4,601 | Python | 48.48387 | 193 | 0.663117 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadKeyboardState.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.OgnReadKeyboardStateDatabase import OgnReadKeyboardStateDatabase
test_file_name = "OgnReadKeyboardStateTemplate.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_ReadKeyboardState")
database = OgnReadKeyboardStateDatabase(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:key"))
attribute = test_node.get_attribute("inputs:key")
db_value = database.inputs.key
expected_value = "A"
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:altOut"))
attribute = test_node.get_attribute("outputs:altOut")
db_value = database.outputs.altOut
self.assertTrue(test_node.get_attribute_exists("outputs:ctrlOut"))
attribute = test_node.get_attribute("outputs:ctrlOut")
db_value = database.outputs.ctrlOut
self.assertTrue(test_node.get_attribute_exists("outputs:isPressed"))
attribute = test_node.get_attribute("outputs:isPressed")
db_value = database.outputs.isPressed
self.assertTrue(test_node.get_attribute_exists("outputs:shiftOut"))
attribute = test_node.get_attribute("outputs:shiftOut")
db_value = database.outputs.shiftOut
| 2,685 | Python | 47.836363 | 98 | 0.698696 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineStop.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.OgnTimelineStopDatabase import OgnTimelineStopDatabase
test_file_name = "OgnTimelineStopTemplate.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_StopTimeline")
database = OgnTimelineStopDatabase(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("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 1,862 | Python | 46.76923 | 92 | 0.701396 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetLocationAtDistanceOnCurve2.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:curve', [[1, 2, 3]], False],
['inputs:distance', 0.5, False],
],
'outputs': [
['outputs:location', [1, 2, 3], False],
],
},
{
'inputs': [
['inputs:curve', [[0, 0, 0], [0, 0, 1]], False],
['inputs:distance', 0.75, False],
['inputs:forwardAxis', "X", False],
['inputs:upAxis', "Y", False],
],
'outputs': [
['outputs:location', [0, 0, 0.5], False],
['outputs:rotateXYZ', [0, 90, 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_GetLocationAtDistanceOnCurve2", "omni.graph.nodes.GetLocationAtDistanceOnCurve2", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLocationAtDistanceOnCurve2 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_GetLocationAtDistanceOnCurve2","omni.graph.nodes.GetLocationAtDistanceOnCurve2", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLocationAtDistanceOnCurve2 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_GetLocationAtDistanceOnCurve2", "omni.graph.nodes.GetLocationAtDistanceOnCurve2", 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.GetLocationAtDistanceOnCurve2 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetLocationAtDistanceOnCurve2Database import OgnGetLocationAtDistanceOnCurve2Database
test_file_name = "OgnGetLocationAtDistanceOnCurve2Template.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_GetLocationAtDistanceOnCurve2")
database = OgnGetLocationAtDistanceOnCurve2Database(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:curve"))
attribute = test_node.get_attribute("inputs:curve")
db_value = database.inputs.curve
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:distance"))
attribute = test_node.get_attribute("inputs:distance")
db_value = database.inputs.distance
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:forwardAxis"))
attribute = test_node.get_attribute("inputs:forwardAxis")
db_value = database.inputs.forwardAxis
expected_value = "X"
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:upAxis"))
attribute = test_node.get_attribute("inputs:upAxis")
db_value = database.inputs.upAxis
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))
self.assertTrue(test_node.get_attribute_exists("outputs:location"))
attribute = test_node.get_attribute("outputs:location")
db_value = database.outputs.location
self.assertTrue(test_node.get_attribute_exists("outputs:orientation"))
attribute = test_node.get_attribute("outputs:orientation")
db_value = database.outputs.orientation
self.assertTrue(test_node.get_attribute_exists("outputs:rotateXYZ"))
attribute = test_node.get_attribute("outputs:rotateXYZ")
db_value = database.outputs.rotateXYZ
| 6,907 | Python | 49.057971 | 231 | 0.670624 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf4.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.OgnConstantHalf4Database import OgnConstantHalf4Database
test_file_name = "OgnConstantHalf4Template.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_ConstantHalf4")
database = OgnConstantHalf4Database(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/TestOgnPauseSound.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.OgnPauseSoundDatabase import OgnPauseSoundDatabase
test_file_name = "OgnPauseSoundTemplate.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_PauseSound")
database = OgnPauseSoundDatabase(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:soundId"))
attribute = test_node.get_attribute("inputs:soundId")
db_value = database.inputs.soundId
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("outputs:execOut"))
attribute = test_node.get_attribute("outputs:execOut")
db_value = database.outputs.execOut
| 2,282 | Python | 47.574467 | 92 | 0.696319 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt64.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.OgnConstantInt64Database import OgnConstantInt64Database
test_file_name = "OgnConstantInt64Template.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_ConstantInt64")
database = OgnConstantInt64Database(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
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.700155 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantFloat.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.OgnConstantFloatDatabase import OgnConstantFloatDatabase
test_file_name = "OgnConstantFloatTemplate.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_ConstantFloat")
database = OgnConstantFloatDatabase(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,933 | Python | 48.589742 | 92 | 0.699948 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnAtan.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': 1}, False],
],
'outputs': [
['outputs:value', {'type': 'float', 'value': 45.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_Atan", "omni.graph.nodes.Atan", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Atan 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_Atan","omni.graph.nodes.Atan", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Atan 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_Atan", "omni.graph.nodes.Atan", 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.Atan User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnAtanDatabase import OgnAtanDatabase
test_file_name = "OgnAtanTemplate.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_Atan")
database = OgnAtanDatabase(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,961 | Python | 47.91358 | 181 | 0.646301 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRpResourceExampleAllocator.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.OgnRpResourceExampleAllocatorDatabase import OgnRpResourceExampleAllocatorDatabase
test_file_name = "OgnRpResourceExampleAllocatorTemplate.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_RpResourceExampleAllocator")
database = OgnRpResourceExampleAllocatorDatabase(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:points"))
attribute = test_node.get_attribute("inputs:points")
db_value = database.inputs.points
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:reload"))
attribute = test_node.get_attribute("inputs:reload")
db_value = database.inputs.reload
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:stream"))
attribute = test_node.get_attribute("inputs:stream")
db_value = database.inputs.stream
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:verbose"))
attribute = test_node.get_attribute("inputs:verbose")
db_value = database.inputs.verbose
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:pointCountCollection"))
attribute = test_node.get_attribute("outputs:pointCountCollection")
db_value = database.outputs.pointCountCollection
self.assertTrue(test_node.get_attribute_exists("outputs:primPathCollection"))
attribute = test_node.get_attribute("outputs:primPathCollection")
db_value = database.outputs.primPathCollection
self.assertTrue(test_node.get_attribute_exists("outputs:reload"))
attribute = test_node.get_attribute("outputs:reload")
db_value = database.outputs.reload
self.assertTrue(test_node.get_attribute_exists("outputs:resourcePointerCollection"))
attribute = test_node.get_attribute("outputs:resourcePointerCollection")
db_value = database.outputs.resourcePointerCollection
self.assertTrue(test_node.get_attribute_exists("outputs:stream"))
attribute = test_node.get_attribute("outputs:stream")
db_value = database.outputs.stream
| 4,761 | Python | 51.32967 | 116 | 0.702583 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetGraphTargetPrim.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.OgnGetGraphTargetPrimDatabase import OgnGetGraphTargetPrimDatabase
test_file_name = "OgnGetGraphTargetPrimTemplate.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_GetGraphTargetPrim")
database = OgnGetGraphTargetPrimDatabase(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:prim"))
attribute = test_node.get_attribute("outputs:prim")
db_value = database.outputs.prim
| 1,706 | Python | 47.771427 | 100 | 0.707503 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNegate.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': 1.0}, False],
],
'outputs': [
['outputs:output', {'type': 'double', 'value': -1.0}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'float[2]', 'value': [0.0, 1.0]}, False],
],
'outputs': [
['outputs:output', {'type': 'float[2]', 'value': [-0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'half[3]', 'value': [-1.0, -0.0, 1.0]}, False],
],
'outputs': [
['outputs:output', {'type': 'half[3]', 'value': [1.0, 0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int[4]', 'value': [-1, 0, 1, 2]}, False],
],
'outputs': [
['outputs:output', {'type': 'int[4]', 'value': [1, 0, -1, -2]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'int64[]', 'value': [-1, 0, 1, 2]}, False],
],
'outputs': [
['outputs:output', {'type': 'int64[]', 'value': [1, 0, -1, -2]}, False],
],
},
{
'inputs': [
['inputs:input', {'type': 'double[][2]', 'value': [[-1.0, 0.0], [1.0, 2.0]]}, False],
],
'outputs': [
['outputs:output', {'type': 'double[][2]', 'value': [[1.0, -0.0], [-1.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_Negate", "omni.graph.nodes.Negate", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Negate 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_Negate","omni.graph.nodes.Negate", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Negate 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_Negate", "omni.graph.nodes.Negate", 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.Negate User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNegateDatabase import OgnNegateDatabase
test_file_name = "OgnNegateTemplate.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_Negate")
database = OgnNegateDatabase(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,403 | Python | 43.661157 | 185 | 0.559319 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnHasAttr.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.OgnHasAttrDatabase import OgnHasAttrDatabase
test_file_name = "OgnHasAttrTemplate.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_HasAttribute")
database = OgnHasAttrDatabase(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:output"))
attribute = test_node.get_attribute("outputs:output")
db_value = database.outputs.output
| 2,273 | Python | 47.382978 | 92 | 0.694237 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetLookAtRotation.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:start', [0.0, 0.0, 0.0], False],
['inputs:target', [100.0, 0.0, 0.0], False],
['inputs:forward', [1.0, 0.0, 0.0], False],
],
'outputs': [
['outputs:rotateXYZ', [0.0, 0.0, 0.0], False],
['outputs:orientation', [0.0, 0.0, 0.0, 1.0], False],
],
},
{
'inputs': [
['inputs:start', [0.0, 0.0, 0.0], False],
['inputs:target', [100.0, 0.0, 0.0], False],
['inputs:forward', [0.0, 0.0, 1.0], False],
],
'outputs': [
['outputs:rotateXYZ', [0.0, 90, 0.0], False],
['outputs:orientation', [0.0, 0.70710678, 0.0, 0.70710678], False],
],
},
{
'inputs': [
['inputs:start', [0.0, 0.0, 0.0], False],
['inputs:target', [100.0, 0.0, 100.0], False],
['inputs:forward', [1.0, 0.0, 0.0], False],
],
'outputs': [
['outputs:rotateXYZ', [0.0, -45.0, 0.0], False],
['outputs:orientation', [0.0, -0.3826834, 0.0, 0.92387953], False],
],
},
{
'inputs': [
['inputs:start', [100.0, 0.0, 100.0], False],
['inputs:target', [200.0, 0.0, 100.0], False],
['inputs:forward', [1.0, 0.0, 0.0], False],
],
'outputs': [
['outputs:rotateXYZ', [0.0, 0.0, 0.0], False],
['outputs:orientation', [0.0, 0.0, 0.0, 1.0], False],
],
},
{
'inputs': [
['inputs:start', [100.0, 0.0, -100.0], False],
['inputs:target', [-100.0, 200.0, -300.0], False],
['inputs:forward', [1.0, 0.0, 0.0], False],
],
'outputs': [
['outputs:rotateXYZ', [150.0, 35.26439, 135.0], False],
['outputs:orientation', [0.27984814, 0.88047624, 0.115916896, 0.3647052], 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_GetLookAtRotation", "omni.graph.nodes.GetLookAtRotation", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLookAtRotation 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_GetLookAtRotation","omni.graph.nodes.GetLookAtRotation", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetLookAtRotation 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_GetLookAtRotation", "omni.graph.nodes.GetLookAtRotation", 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.GetLookAtRotation User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetLookAtRotationDatabase import OgnGetLookAtRotationDatabase
test_file_name = "OgnGetLookAtRotationTemplate.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_GetLookAtRotation")
database = OgnGetLookAtRotationDatabase(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:forward"))
attribute = test_node.get_attribute("inputs:forward")
db_value = database.inputs.forward
expected_value = [0.0, 0.0, 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:start"))
attribute = test_node.get_attribute("inputs:start")
db_value = database.inputs.start
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: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("outputs:orientation"))
attribute = test_node.get_attribute("outputs:orientation")
db_value = database.outputs.orientation
self.assertTrue(test_node.get_attribute_exists("outputs:rotateXYZ"))
attribute = test_node.get_attribute("outputs:rotateXYZ")
db_value = database.outputs.rotateXYZ
| 7,639 | Python | 46.75 | 207 | 0.603482 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantInt.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.OgnConstantIntDatabase import OgnConstantIntDatabase
test_file_name = "OgnConstantIntTemplate.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_ConstantInt")
database = OgnConstantIntDatabase(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
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,921 | Python | 48.28205 | 92 | 0.698594 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNormalize.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:vector', {'type': 'float[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [0.57735027, 0.57735027, 0.57735027]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [5.0, 0.0, 0.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [1.0, 0.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3]', 'value': [-1.0, 2.0, -3.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3]', 'value': [-0.26726124, 0.53452248, -0.80178373]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'double[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'double[3]', 'value': [0.57735027, 0.57735027, 0.57735027]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'half[3]', 'value': [1.0, 1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[3]', 'value': [0.57714844, 0.57714844, 0.57714844]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[3][]', 'value': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[3][]', 'value': [[0.26726124, 0.5345225, 0.8017837], [0.45584232, 0.5698029, 0.6837635]]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'half[3][]', 'value': [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]}, False],
],
'outputs': [
['outputs:result', {'type': 'half[3][]', 'value': [[0.26733398, 0.53466797, 0.8017578], [0.45581055, 0.5698242, 0.68359375]]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[2]', 'value': [1.0, 1.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [0.70710677, 0.70710677]}, False],
],
},
{
'inputs': [
['inputs:vector', {'type': 'float[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
],
'outputs': [
['outputs:result', {'type': 'float[4]', 'value': [0.18257418, 0.36514837, 0.5477226, 0.73029673]}, 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_Normalize", "omni.graph.nodes.Normalize", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Normalize 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_Normalize","omni.graph.nodes.Normalize", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Normalize 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_Normalize", "omni.graph.nodes.Normalize", 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.Normalize User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnNormalizeDatabase import OgnNormalizeDatabase
test_file_name = "OgnNormalizeTemplate.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_Normalize")
database = OgnNormalizeDatabase(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,882 | Python | 43.986928 | 191 | 0.534292 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayRemoveValue.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': []}, False],
['inputs:removeAll', False, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'int[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 41]}, False],
['inputs:removeAll', False, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': [42, 41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 43, 41]}, False],
['inputs:removeAll', True, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': [42, 43]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 41, 41, 41]}, False],
['inputs:removeAll', True, False],
['inputs:value', {'type': 'int', 'value': 41}, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOO'}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['FOOD', 'BARFOOD', 'BAZ']}, False],
['inputs:value', {'type': 'token', 'value': 'FOOD'}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'token[]', 'value': ['BARFOOD', 'BAZ']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'int64', 'value': 41}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int64[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uchar[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uchar', 'value': 41}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uchar[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint', 'value': 42}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uint[]', 'value': [41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'uint64[]', 'value': [41, 42]}, False],
['inputs:value', {'type': 'uint64', 'value': 42}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'uint64[]', 'value': [41]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:value', {'type': 'bool', 'value': False}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'bool[]', 'value': [True]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:value', {'type': 'half[2]', 'value': [1, 2]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'half[2][]', 'value': [[3, 4]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4], [5, 6]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[2][]', 'value': [[3, 4], [5, 6]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'double[2][]', 'value': [[1, 2], [3, 4], [5, 6], [1, 2]]}, False],
['inputs:value', {'type': 'double[2]', 'value': [1, 2]}, False],
['inputs:removeAll', True, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[2][]', 'value': [[3, 4], [5, 6]]}, 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],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.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.1, 4, 5]}, False],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', False, False],
['outputs:array', {'type': 'double[3][]', 'value': [[1.1, 2.1, 1.0], [3, 4, 5]]}, 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],
['inputs:removeAll', False, False],
],
'outputs': [
['outputs:found', True, False],
['outputs:array', {'type': 'int[4][]', 'value': [[3, 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_ArrayRemoveValue", "omni.graph.nodes.ArrayRemoveValue", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveValue 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_ArrayRemoveValue","omni.graph.nodes.ArrayRemoveValue", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveValue 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_ArrayRemoveValue", "omni.graph.nodes.ArrayRemoveValue", 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.ArrayRemoveValue User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayRemoveValueDatabase import OgnArrayRemoveValueDatabase
test_file_name = "OgnArrayRemoveValueTemplate.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_ArrayRemoveValue")
database = OgnArrayRemoveValueDatabase(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:removeAll"))
attribute = test_node.get_attribute("inputs:removeAll")
db_value = database.inputs.removeAll
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:found"))
attribute = test_node.get_attribute("outputs:found")
db_value = database.outputs.found
| 12,160 | Python | 43.709559 | 205 | 0.481414 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantHalf2.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.OgnConstantHalf2Database import OgnConstantHalf2Database
test_file_name = "OgnConstantHalf2Template.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_ConstantHalf2")
database = OgnConstantHalf2Database(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,940 | Python | 48.76923 | 92 | 0.698454 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble3.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.OgnConstantDouble3Database import OgnConstantDouble3Database
test_file_name = "OgnConstantDouble3Template.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_ConstantDouble3")
database = OgnConstantDouble3Database(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/TestOgnRandomUnitVector.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.99799526, 0.02564502, -0.05785976], 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_RandomUnitVector", "omni.graph.nodes.RandomUnitVector", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitVector 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_RandomUnitVector","omni.graph.nodes.RandomUnitVector", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomUnitVector 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_RandomUnitVector", "omni.graph.nodes.RandomUnitVector", 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.RandomUnitVector User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomUnitVectorDatabase import OgnRandomUnitVectorDatabase
test_file_name = "OgnRandomUnitVectorTemplate.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_RandomUnitVector")
database = OgnRandomUnitVectorDatabase(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,773 | Python | 48.350427 | 205 | 0.67296 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnStartsWith.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:prefix', "", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "a", False],
['inputs:prefix', "", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "", False],
['inputs:prefix', "a", False],
],
'outputs': [
['outputs:isPrefix', False, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "a", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "aa", False],
],
'outputs': [
['outputs:isPrefix', True, False],
],
},
{
'inputs': [
['inputs:value', "aa", False],
['inputs:prefix', "aaa", False],
],
'outputs': [
['outputs:isPrefix', False, False],
],
},
{
'inputs': [
['inputs:value', "aaa", False],
['inputs:prefix', "aa", False],
],
'outputs': [
['outputs:isPrefix', 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_StartsWith", "omni.graph.nodes.StartsWith", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.StartsWith 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_StartsWith","omni.graph.nodes.StartsWith", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.StartsWith 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_StartsWith", "omni.graph.nodes.StartsWith", 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.StartsWith User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnStartsWithDatabase import OgnStartsWithDatabase
test_file_name = "OgnStartsWithTemplate.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_StartsWith")
database = OgnStartsWithDatabase(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:prefix"))
attribute = test_node.get_attribute("inputs:prefix")
db_value = database.inputs.prefix
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:isPrefix"))
attribute = test_node.get_attribute("outputs:isPrefix")
db_value = database.outputs.isPrefix
| 6,483 | Python | 40.564102 | 193 | 0.583218 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnDotProduct.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[2]', 'value': [1, 2]}, False],
['inputs:b', {'type': 'double[2]', 'value': [3, 4]}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 11}, 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', 'value': 38}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4]', 'value': [10.2, 3.5, 7, 0]}, False],
['inputs:b', {'type': 'double[4]', 'value': [5, 6.1, 4.2, 5]}, False],
],
'outputs': [
['outputs:product', {'type': 'double', 'value': 101.75}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[4][]', 'value': [[3, 6.5, 2, 0], [4, 3.6, 2, 0]]}, False],
['inputs:b', {'type': 'double[4][]', 'value': [[5, 6.1, -2.1, 5], [3, 5, -2, 7]]}, False],
],
'outputs': [
['outputs:product', {'type': 'double[]', 'value': [50.449999999999996, 26.0]}, False],
],
},
{
'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', 'value': 38}, 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_DotProduct", "omni.graph.nodes.DotProduct", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.DotProduct 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_DotProduct","omni.graph.nodes.DotProduct", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.DotProduct 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_DotProduct", "omni.graph.nodes.DotProduct", 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.DotProduct User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnDotProductDatabase import OgnDotProductDatabase
test_file_name = "OgnDotProductTemplate.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_DotProduct")
database = OgnDotProductDatabase(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,567 | Python | 46.18644 | 193 | 0.566733 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPi.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.OgnConstantPiDatabase import OgnConstantPiDatabase
test_file_name = "OgnConstantPiTemplate.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_ConstantPi")
database = OgnConstantPiDatabase(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:factor"))
attribute = test_node.get_attribute("inputs:factor")
db_value = database.inputs.factor
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("outputs:value"))
attribute = test_node.get_attribute("outputs:value")
db_value = database.outputs.value
| 2,096 | Python | 47.767441 | 92 | 0.696565 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBooleanExpr.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', True, False],
['inputs:b', True, False],
['inputs:operator', "XOR", False],
],
'outputs': [
['outputs:result', False, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', True, False],
['inputs:operator', "XNOR", False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', False, False],
['inputs:operator', "OR", False],
],
'outputs': [
['outputs:result', True, False],
],
},
{
'inputs': [
['inputs:a', True, False],
['inputs:b', False, False],
['inputs:operator', "AND", False],
],
'outputs': [
['outputs:result', 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_BooleanExpr", "omni.graph.nodes.BooleanExpr", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanExpr 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_BooleanExpr","omni.graph.nodes.BooleanExpr", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanExpr User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBooleanExprDatabase import OgnBooleanExprDatabase
test_file_name = "OgnBooleanExprTemplate.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_BooleanExpr")
database = OgnBooleanExprDatabase(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:a"))
attribute = test_node.get_attribute("inputs:a")
db_value = database.inputs.a
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:b"))
attribute = test_node.get_attribute("inputs:b")
db_value = database.inputs.b
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:operator"))
attribute = test_node.get_attribute("inputs:operator")
db_value = database.inputs.operator
expected_value = "AND"
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:result"))
attribute = test_node.get_attribute("outputs:result")
db_value = database.outputs.result
| 5,285 | Python | 43.05 | 176 | 0.600189 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRotateToTarget.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.OgnRotateToTargetDatabase import OgnRotateToTargetDatabase
test_file_name = "OgnRotateToTargetTemplate.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_RotateToTarget")
database = OgnRotateToTargetDatabase(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,811 | Python | 49.826666 | 93 | 0.694831 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnArrayRemoveIndex.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],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [42]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'bool[]', 'value': [True, False]}, False],
['inputs:index', 0, False],
],
'outputs': [
['outputs:array', {'type': 'bool[]', 'value': [False]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'half[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:array', {'type': 'half[2][]', 'value': [[1, 2]]}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'token[]', 'value': ['41', '42']}, False],
['inputs:index', -2, False],
],
'outputs': [
['outputs:array', {'type': 'token[]', 'value': ['42']}, False],
],
},
{
'inputs': [
['inputs:array', {'type': 'int[]', 'value': [41, 42, 43, 41]}, False],
['inputs:index', 1, False],
],
'outputs': [
['outputs:array', {'type': 'int[]', 'value': [41, 43, 41]}, 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_ArrayRemoveIndex", "omni.graph.nodes.ArrayRemoveIndex", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveIndex 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_ArrayRemoveIndex","omni.graph.nodes.ArrayRemoveIndex", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ArrayRemoveIndex 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_ArrayRemoveIndex", "omni.graph.nodes.ArrayRemoveIndex", 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.ArrayRemoveIndex User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnArrayRemoveIndexDatabase import OgnArrayRemoveIndexDatabase
test_file_name = "OgnArrayRemoveIndexTemplate.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_ArrayRemoveIndex")
database = OgnArrayRemoveIndexDatabase(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))
| 5,829 | Python | 45.269841 | 205 | 0.588094 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGetParentPath.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:path', {'type': 'token', 'value': '/'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': ''}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo/bar'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World/foo'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token', 'value': '/World/foo/bar.attrib'}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token', 'value': '/World/foo/bar'}, False],
],
},
{
'inputs': [
['inputs:path', {'type': 'token[]', 'value': ['/World1/foo', '/World2/bar']}, False],
],
'outputs': [
['outputs:parentPath', {'type': 'token[]', 'value': ['/World1', '/World2']}, 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_GetParentPath", "omni.graph.nodes.GetParentPath", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetParentPath 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_GetParentPath","omni.graph.nodes.GetParentPath", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.GetParentPath 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_GetParentPath", "omni.graph.nodes.GetParentPath", 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.GetParentPath User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnGetParentPathDatabase import OgnGetParentPathDatabase
test_file_name = "OgnGetParentPathTemplate.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_GetParentPath")
database = OgnGetParentPathDatabase(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("state:path"))
attribute = test_node.get_attribute("state:path")
db_value = database.state.path
| 5,636 | Python | 44.096 | 199 | 0.582328 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSubtract.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': 1.0}, False],
['inputs:b', {'type': 'double', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'double', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'float', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': 1.0}, False],
['inputs:b', {'type': 'half', 'value': 0.5}, False],
],
'outputs': [
['outputs:difference', {'type': 'half', 'value': 0.5}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int', 'value': 10}, False],
['inputs:b', {'type': 'int', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'int', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 10}, False],
['inputs:b', {'type': 'int64', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 10}, False],
['inputs:b', {'type': 'uchar', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uchar', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint', 'value': 10}, False],
['inputs:b', {'type': 'uint', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uint', 'value': 4}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uint64', 'value': 10}, False],
['inputs:b', {'type': 'uint64', 'value': 6}, False],
],
'outputs': [
['outputs:difference', {'type': 'uint64', 'value': 4}, False],
],
},
{
'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:difference', {'type': 'float[2]', 'value': [0.5, 1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[3]', 'value': [1.0, 2.0, 3.0]}, False],
['inputs:b', {'type': 'float[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[3]', 'value': [0.5, 1.0, 1.5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[4]', 'value': [1.0, 2.0, 3.0, 4.0]}, False],
['inputs:b', {'type': 'float[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[4]', 'value': [0.5, 1.0, 1.5, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[2]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float[2]', 'value': [1.0, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[2]', 'value': [0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 1.0}, False],
['inputs:b', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
],
'outputs': [
['outputs:difference', {'type': 'float[]', 'value': [0.0, -1.0]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20, 30]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10, 15]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10, 15]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64[]', 'value': [10, 20, 30, 40]}, False],
['inputs:b', {'type': 'int64[]', 'value': [5, 10, 15, 20]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int64[]', 'value': [5, 10, 15, 20]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3][]', 'value': [[10, 20, 30], [40, 50, 60]]}, False],
['inputs:b', {'type': 'int[3]', 'value': [5, 10, 15]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[3][]', 'value': [[5, 10, 15], [35, 40, 45]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[3]', 'value': [5, 10, 15]}, False],
['inputs:b', {'type': 'int[3][]', 'value': [[10, 20, 30], [40, 50, 60]]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[3][]', 'value': [[-5, -10, -15], [-35, -40, -45]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[2][]', 'value': [[10, 20], [30, 40], [50, 60]]}, False],
['inputs:b', {'type': 'int[2]', 'value': [5, 10]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[2][]', 'value': [[5, 10], [25, 30], [45, 50]]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int[2]', 'value': [5, 10]}, False],
['inputs:b', {'type': 'int[2][]', 'value': [[10, 20], [30, 40], [50, 60]]}, False],
],
'outputs': [
['outputs:difference', {'type': 'int[2][]', 'value': [[-5, -10], [-25, -30], [-45, -50]]}, 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_Subtract", "omni.graph.nodes.Subtract", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Subtract 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_Subtract","omni.graph.nodes.Subtract", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Subtract 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_Subtract", "omni.graph.nodes.Subtract", 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.Subtract User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSubtractDatabase import OgnSubtractDatabase
test_file_name = "OgnSubtractTemplate.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_Subtract")
database = OgnSubtractDatabase(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"
| 11,679 | Python | 40.714286 | 189 | 0.440791 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnBreakVector3.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[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 0.0}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'int[3]', 'value': [42, -42, 5]}, False],
],
'outputs': [
['outputs:x', {'type': 'int', 'value': 42}, False],
['outputs:y', {'type': 'int', 'value': -42}, False],
['outputs:z', {'type': 'int', 'value': 5}, False],
],
},
{
'inputs': [
['inputs:tuple', {'type': 'colorf[3]', 'value': [42.0, 1.0, 0.0]}, False],
],
'outputs': [
['outputs:x', {'type': 'float', 'value': 42.0}, False],
['outputs:y', {'type': 'float', 'value': 1.0}, False],
['outputs:z', {'type': 'float', 'value': 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_BreakVector3", "omni.graph.nodes.BreakVector3", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector3 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_BreakVector3","omni.graph.nodes.BreakVector3", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BreakVector3 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_BreakVector3", "omni.graph.nodes.BreakVector3", 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.BreakVector3 User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnBreakVector3Database import OgnBreakVector3Database
test_file_name = "OgnBreakVector3Template.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_BreakVector3")
database = OgnBreakVector3Database(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,022 | Python | 47.76699 | 197 | 0.597372 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCompare.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': 1.0}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float', 'value': 42.0}, False],
['inputs:b', {'type': 'float', 'value': 1.0}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:b', {'type': 'int64', 'value': 9223372036854775807}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [1.0, 2.0]}, False],
['inputs:b', {'type': 'float[]', 'value': [1.0, 2.01]}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, False]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[]', 'value': [2.0, 3.0]}, False],
['inputs:b', {'type': 'double[]', 'value': [2.0, 3.1]}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'double[3][]', 'value': [[2.0, 3.0, 1.0], [1.0, 2.0, 5.0]]}, False],
['inputs:b', {'type': 'double[3][]', 'value': [[2.0, 1.0, 4.0], [2.0, 2.0, 2.0]]}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': ''}, False],
['inputs:b', {'type': 'token', 'value': ''}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': 'abc'}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': 'd'}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': 'abc'}, False],
['inputs:b', {'type': 'token', 'value': ''}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': ''}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'd'}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': ''}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', "<", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': False}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'ad'}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': ''}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', ">=", False],
],
'outputs': [
['outputs:result', {'type': 'bool', 'value': True}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar[]', 'value': []}, False],
['inputs:b', {'type': 'uchar[]', 'value': []}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'string', 'value': 'abc'}, False],
['inputs:b', {'type': 'uchar[]', 'value': [97, 98, 99]}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, False, False]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar[]', 'value': [97, 98, 99]}, False],
['inputs:b', {'type': 'uchar', 'value': 98}, False],
['inputs:operation', ">", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'uchar', 'value': 98}, False],
['inputs:b', {'type': 'string', 'value': 'abc'}, False],
['inputs:operation', "<=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, True, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token[]', 'value': ['abcd', 'a', 'foo']}, False],
['inputs:b', {'type': 'token[]', 'value': ['abc', 'a', 'food']}, False],
['inputs:operation', "!=", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [True, False, True]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'token', 'value': ''}, False],
['inputs:b', {'type': 'token[]', 'value': ['abc', 'a', '']}, False],
['inputs:operation', "==", False],
],
'outputs': [
['outputs:result', {'type': 'bool[]', 'value': [False, 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_Compare", "omni.graph.nodes.Compare", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Compare 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_Compare","omni.graph.nodes.Compare", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Compare 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_Compare", "omni.graph.nodes.Compare", 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.Compare User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnCompareDatabase import OgnCompareDatabase
test_file_name = "OgnCompareTemplate.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_Compare")
database = OgnCompareDatabase(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 = ">"
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))
| 13,355 | Python | 40.607477 | 187 | 0.446425 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnMakeTransformLookAt.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:eye', [1, 0, 0], False],
['inputs:center', [0, 0, 1], False],
['inputs:up', [0, 1, 0], False],
],
'outputs': [
['outputs:transform', [0.70710678, 0, -0.70710678, 0, 0, 1, 0, 0, 0.70710678, 0, 0.70710678, 0, -0.70710678, 0, -0.70710678, 1], False],
],
},
{
'inputs': [
['inputs:eye', [1, 0, 0], False],
['inputs:center', [0, 0, 0], False],
['inputs:up', [0, 1, 0], False],
],
'outputs': [
['outputs:transform', [0, 0, -1, 0, 0, 1, 0, 0, 1, 0, 0, 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_MakeTransformLookAt", "omni.graph.nodes.MakeTransformLookAt", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransformLookAt 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_MakeTransformLookAt","omni.graph.nodes.MakeTransformLookAt", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.MakeTransformLookAt 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_MakeTransformLookAt", "omni.graph.nodes.MakeTransformLookAt", 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.MakeTransformLookAt User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnMakeTransformLookAtDatabase import OgnMakeTransformLookAtDatabase
test_file_name = "OgnMakeTransformLookAtTemplate.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_MakeTransformLookAt")
database = OgnMakeTransformLookAtDatabase(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:center"))
attribute = test_node.get_attribute("inputs:center")
db_value = database.inputs.center
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:eye"))
attribute = test_node.get_attribute("inputs:eye")
db_value = database.inputs.eye
expected_value = [1, 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:up"))
attribute = test_node.get_attribute("inputs:up")
db_value = database.inputs.up
expected_value = [0, 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("outputs:transform"))
attribute = test_node.get_attribute("outputs:transform")
db_value = database.outputs.transform
| 6,054 | Python | 49.041322 | 211 | 0.649653 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnFMod.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': 4.0}, False],
['inputs:b', {'type': 'float', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'float', 'value': 0.375}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'float[]', 'value': [4.0, 7.625]}, False],
['inputs:b', {'type': 'float', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'float[]', 'value': [0.375, 0.375]}, False],
],
},
{
'inputs': [
['inputs:a', {'type': 'half', 'value': -4.0}, False],
['inputs:b', {'type': 'half', 'value': 3.625}, False],
],
'outputs': [
['outputs:result', {'type': 'half', 'value': -0.375}, 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_FMod", "omni.graph.nodes.FMod", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FMod 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_FMod","omni.graph.nodes.FMod", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FMod User test case #{i+1}", 16)
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnFModDatabase import OgnFModDatabase
test_file_name = "OgnFModTemplate.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_FMod")
database = OgnFModDatabase(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,592 | Python | 44.481012 | 162 | 0.579621 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnHasVariantSet.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.OgnHasVariantSetDatabase import OgnHasVariantSetDatabase
test_file_name = "OgnHasVariantSetTemplate.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_HasVariantSet")
database = OgnHasVariantSetDatabase(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:exists"))
attribute = test_node.get_attribute("outputs:exists")
db_value = database.outputs.exists
| 2,310 | Python | 48.170212 | 92 | 0.699134 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantDouble4.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.OgnConstantDouble4Database import OgnConstantDouble4Database
test_file_name = "OgnConstantDouble4Template.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_ConstantDouble4")
database = OgnConstantDouble4Database(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,960 | Python | 49.28205 | 94 | 0.698469 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnSourceIndices.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:sourceStartsInTarget', [1, 2, 3, 5, 6, 6], False],
],
'outputs': [
['outputs:sourceIndices', [0, 0, 1, 2, 2, 3], 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_SourceIndices", "omni.graph.nodes.SourceIndices", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SourceIndices 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_SourceIndices","omni.graph.nodes.SourceIndices", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.SourceIndices 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_SourceIndices", "omni.graph.nodes.SourceIndices", 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.SourceIndices User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnSourceIndicesDatabase import OgnSourceIndicesDatabase
test_file_name = "OgnSourceIndicesTemplate.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_SourceIndices")
database = OgnSourceIndicesDatabase(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:sourceStartsInTarget"))
attribute = test_node.get_attribute("inputs:sourceStartsInTarget")
db_value = database.inputs.sourceStartsInTarget
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:sourceIndices"))
attribute = test_node.get_attribute("outputs:sourceIndices")
db_value = database.outputs.sourceIndices
| 4,716 | Python | 49.72043 | 199 | 0.670908 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantUInt64.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.OgnConstantUInt64Database import OgnConstantUInt64Database
test_file_name = "OgnConstantUInt64Template.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_ConstantUInt64")
database = OgnConstantUInt64Database(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
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,936 | Python | 48.666665 | 93 | 0.70093 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnToDouble.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': 'double[]', 'value': []}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.1}, False],
],
'outputs': [
['outputs:converted', {'type': 'double', 'value': 2.1}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int', 'value': 42}, False],
],
'outputs': [
['outputs:converted', {'type': 'double', 'value': 42.0}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'bool[]', 'value': [True, False]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[]', 'value': [1.0, 0.0]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'float[2]', 'value': [2.1, 2.1]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[2]', 'value': [2.1, 2.1]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3]', 'value': [2, 3, 4]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[3]', 'value': [2, 3, 4]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'half[3][]', 'value': [[2, 3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[3][]', 'value': [[2, 3, 4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int[2][]', 'value': [[1, 2], [3, 4]]}, False],
],
'outputs': [
['outputs:converted', {'type': 'double[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_ToDouble", "omni.graph.nodes.ToDouble", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDouble 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_ToDouble","omni.graph.nodes.ToDouble", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.ToDouble 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_ToDouble", "omni.graph.nodes.ToDouble", 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.ToDouble User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnToDoubleDatabase import OgnToDoubleDatabase
test_file_name = "OgnToDoubleTemplate.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_ToDouble")
database = OgnToDoubleDatabase(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,926 | Python | 42.262773 | 189 | 0.544381 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnNoOp.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.OgnNoOpDatabase import OgnNoOpDatabase
test_file_name = "OgnNoOpTemplate.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_Noop")
database = OgnNoOpDatabase(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"
| 1,462 | Python | 46.193547 | 92 | 0.697674 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnReadPrim.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.OgnReadPrimDatabase import OgnReadPrimDatabase
test_file_name = "OgnReadPrimTemplate.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_ReadPrim")
database = OgnReadPrimDatabase(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), 9)
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: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: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_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:computeBoundingBox"))
attribute = test_node.get_attribute("state:computeBoundingBox")
db_value = database.state.computeBoundingBox
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:primTypes"))
attribute = test_node.get_attribute("state:primTypes")
db_value = database.state.primTypes
self.assertTrue(test_node.get_attribute_exists("state:usdTimecode"))
attribute = test_node.get_attribute("state:usdTimecode")
db_value = database.state.usdTimecode
| 4,025 | Python | 49.962025 | 92 | 0.701366 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnXor.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', True, 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, True, True, False], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool', 'value': False}, False],
['inputs:b', {'type': 'bool[]', 'value': [False, True]}, False],
],
'outputs': [
['outputs:result', [False, True], False],
],
},
{
'inputs': [
['inputs:a', {'type': 'bool[]', 'value': [False, True]}, False],
['inputs:b', {'type': 'bool', 'value': False}, 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_BooleanXor", "omni.graph.nodes.BooleanXor", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanXor 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_BooleanXor","omni.graph.nodes.BooleanXor", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.BooleanXor 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_BooleanXor", "omni.graph.nodes.BooleanXor", 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.BooleanXor User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnXorDatabase import OgnXorDatabase
test_file_name = "OgnXorTemplate.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_BooleanXor")
database = OgnXorDatabase(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,038 | Python | 45.229357 | 193 | 0.590512 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnFindPrims.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:namePrefix', "Xform", False],
],
'outputs': [
['outputs:primPaths', ["/Xform1", "/Xform2", "/XformTagged1"], False],
],
'setup': {'create_nodes': [['TestNode', 'omni.graph.nodes.FindPrims']], '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:namePrefix', "", False],
['inputs:requiredAttributes', "foo _translate", False],
],
'outputs': [
['outputs:primPaths', ["/XformTagged1"], False],
],
'setup': {} },
]
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_FindPrims", "omni.graph.nodes.FindPrims", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FindPrims 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_FindPrims","omni.graph.nodes.FindPrims", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.FindPrims 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_FindPrims", "omni.graph.nodes.FindPrims", 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.FindPrims User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnFindPrimsDatabase import OgnFindPrimsDatabase
test_file_name = "OgnFindPrimsTemplate.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_FindPrims")
database = OgnFindPrimsDatabase(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:ignoreSystemPrims"))
attribute = test_node.get_attribute("inputs:ignoreSystemPrims")
db_value = database.inputs.ignoreSystemPrims
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:namePrefix"))
attribute = test_node.get_attribute("inputs:namePrefix")
db_value = database.inputs.namePrefix
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:recursive"))
attribute = test_node.get_attribute("inputs:recursive")
db_value = database.inputs.recursive
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:requiredAttributes"))
attribute = test_node.get_attribute("inputs:requiredAttributes")
db_value = database.inputs.requiredAttributes
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:requiredRelationship"))
attribute = test_node.get_attribute("inputs:requiredRelationship")
db_value = database.inputs.requiredRelationship
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:requiredRelationshipTarget"))
attribute = test_node.get_attribute("inputs:requiredRelationshipTarget")
db_value = database.inputs.requiredRelationshipTarget
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:requiredTarget"))
attribute = test_node.get_attribute("inputs:requiredTarget")
db_value = database.inputs.requiredTarget
self.assertTrue(test_node.get_attribute_exists("inputs:rootPrim"))
attribute = test_node.get_attribute("inputs:rootPrim")
db_value = database.inputs.rootPrim
self.assertTrue(test_node.get_attribute_exists("inputs:rootPrimPath"))
attribute = test_node.get_attribute("inputs:rootPrimPath")
db_value = database.inputs.rootPrimPath
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:type"))
attribute = test_node.get_attribute("inputs:type")
db_value = database.inputs.type
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:primPaths"))
attribute = test_node.get_attribute("outputs:primPaths")
db_value = database.outputs.primPaths
self.assertTrue(test_node.get_attribute_exists("outputs:prims"))
attribute = test_node.get_attribute("outputs:prims")
db_value = database.outputs.prims
self.assertTrue(test_node.get_attribute_exists("state:ignoreSystemPrims"))
attribute = test_node.get_attribute("state:ignoreSystemPrims")
db_value = database.state.ignoreSystemPrims
self.assertTrue(test_node.get_attribute_exists("state:inputType"))
attribute = test_node.get_attribute("state:inputType")
db_value = database.state.inputType
self.assertTrue(test_node.get_attribute_exists("state:namePrefix"))
attribute = test_node.get_attribute("state:namePrefix")
db_value = database.state.namePrefix
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:recursive"))
attribute = test_node.get_attribute("state:recursive")
db_value = database.state.recursive
self.assertTrue(test_node.get_attribute_exists("state:requiredAttributes"))
attribute = test_node.get_attribute("state:requiredAttributes")
db_value = database.state.requiredAttributes
self.assertTrue(test_node.get_attribute_exists("state:requiredRelationship"))
attribute = test_node.get_attribute("state:requiredRelationship")
db_value = database.state.requiredRelationship
self.assertTrue(test_node.get_attribute_exists("state:requiredRelationshipTarget"))
attribute = test_node.get_attribute("state:requiredRelationshipTarget")
db_value = database.state.requiredRelationshipTarget
self.assertTrue(test_node.get_attribute_exists("state:requiredTarget"))
attribute = test_node.get_attribute("state:requiredTarget")
db_value = database.state.requiredTarget
self.assertTrue(test_node.get_attribute_exists("state:rootPrim"))
attribute = test_node.get_attribute("state:rootPrim")
db_value = database.state.rootPrim
self.assertTrue(test_node.get_attribute_exists("state:rootPrimPath"))
attribute = test_node.get_attribute("state:rootPrimPath")
db_value = database.state.rootPrimPath
| 11,264 | Python | 49.743243 | 365 | 0.694158 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/__init__.py | """====== GENERATED BY omni.graph.tools - DO NOT EDIT ======"""
import omni.graph.tools._internal as ogi
ogi.import_tests_in_directory(__file__, __name__)
| 155 | Python | 37.999991 | 63 | 0.645161 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnGpuInteropCudaEntry.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.OgnGpuInteropCudaEntryDatabase import OgnGpuInteropCudaEntryDatabase
test_file_name = "OgnGpuInteropCudaEntryTemplate.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_GpuInteropCudaEntry")
database = OgnGpuInteropCudaEntryDatabase(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:sourceName"))
attribute = test_node.get_attribute("inputs:sourceName")
db_value = database.inputs.sourceName
expected_value = "ldrColor"
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:bufferSize"))
attribute = test_node.get_attribute("outputs:bufferSize")
db_value = database.outputs.bufferSize
self.assertTrue(test_node.get_attribute_exists("outputs:cudaMipmappedArray"))
attribute = test_node.get_attribute("outputs:cudaMipmappedArray")
db_value = database.outputs.cudaMipmappedArray
self.assertTrue(test_node.get_attribute_exists("outputs:externalTimeOfSimFrame"))
attribute = test_node.get_attribute("outputs:externalTimeOfSimFrame")
db_value = database.outputs.externalTimeOfSimFrame
self.assertTrue(test_node.get_attribute_exists("outputs:format"))
attribute = test_node.get_attribute("outputs:format")
db_value = database.outputs.format
self.assertTrue(test_node.get_attribute_exists("outputs:frameId"))
attribute = test_node.get_attribute("outputs:frameId")
db_value = database.outputs.frameId
self.assertTrue(test_node.get_attribute_exists("outputs:height"))
attribute = test_node.get_attribute("outputs:height")
db_value = database.outputs.height
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:isBuffer"))
attribute = test_node.get_attribute("outputs:isBuffer")
db_value = database.outputs.isBuffer
self.assertTrue(test_node.get_attribute_exists("outputs:mipCount"))
attribute = test_node.get_attribute("outputs:mipCount")
db_value = database.outputs.mipCount
self.assertTrue(test_node.get_attribute_exists("outputs:simTime"))
attribute = test_node.get_attribute("outputs:simTime")
db_value = database.outputs.simTime
self.assertTrue(test_node.get_attribute_exists("outputs:stream"))
attribute = test_node.get_attribute("outputs:stream")
db_value = database.outputs.stream
self.assertTrue(test_node.get_attribute_exists("outputs:width"))
attribute = test_node.get_attribute("outputs:width")
db_value = database.outputs.width
| 4,265 | Python | 48.034482 | 102 | 0.7034 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantPath.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.OgnConstantPathDatabase import OgnConstantPathDatabase
test_file_name = "OgnConstantPathTemplate.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_ConstantPath")
database = OgnConstantPathDatabase(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,927 | Python | 48.435896 | 92 | 0.698495 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIncrement.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[2]', 'value': [1.0, 2.0]}, False],
['inputs:increment', 0.5, False],
],
'outputs': [
['outputs:result', {'type': 'float[2]', 'value': [1.5, 2.5]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'int64', 'value': 10}, False],
['inputs:increment', 1.2, False],
],
'outputs': [
['outputs:result', {'type': 'int64', 'value': 11}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:increment', 5.4, False],
],
'outputs': [
['outputs:result', {'type': 'double[2][]', 'value': [[15.4, 10.4], [6.4, 6.4]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double[2][]', 'value': [[10, 5], [1, 1]]}, False],
['inputs:increment', 5, False],
],
'outputs': [
['outputs:result', {'type': 'double[2][]', 'value': [[15, 10], [6, 6]]}, False],
],
},
{
'inputs': [
['inputs:value', {'type': 'double', 'value': 2.22045e-16}, False],
],
'outputs': [
['outputs:result', {'type': 'double', 'value': 1.0000000000000002}, 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_Increment", "omni.graph.nodes.Increment", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Increment 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_Increment","omni.graph.nodes.Increment", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.Increment 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_Increment", "omni.graph.nodes.Increment", 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.Increment User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnIncrementDatabase import OgnIncrementDatabase
test_file_name = "OgnIncrementTemplate.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_Increment")
database = OgnIncrementDatabase(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:increment"))
attribute = test_node.get_attribute("inputs:increment")
db_value = database.inputs.increment
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))
| 5,774 | Python | 45.2 | 191 | 0.587115 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnCurveTubeST.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.OgnCurveTubeSTDatabase import OgnCurveTubeSTDatabase
test_file_name = "OgnCurveTubeSTTemplate.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_CurveTubeST")
database = OgnCurveTubeSTDatabase(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: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:scaleTLikeS"))
attribute = test_node.get_attribute("inputs:scaleTLikeS")
db_value = database.inputs.scaleTLikeS
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:t"))
attribute = test_node.get_attribute("inputs:t")
db_value = database.inputs.t
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:tubeQuadStarts"))
attribute = test_node.get_attribute("inputs:tubeQuadStarts")
db_value = database.inputs.tubeQuadStarts
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:tubeSTStarts"))
attribute = test_node.get_attribute("inputs:tubeSTStarts")
db_value = database.inputs.tubeSTStarts
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:primvars:st"))
attribute = test_node.get_attribute("outputs:primvars:st")
db_value = database.outputs.primvars_st
self.assertTrue(test_node.get_attribute_exists("outputs:primvars:st:indices"))
attribute = test_node.get_attribute("outputs:primvars:st:indices")
db_value = database.outputs.primvars_st_indices
| 5,437 | Python | 51.796116 | 92 | 0.691926 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnExtractAttr.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.OgnExtractAttrDatabase import OgnExtractAttrDatabase
test_file_name = "OgnExtractAttrTemplate.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_ExtractAttribute")
database = OgnExtractAttrDatabase(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
| 2,113 | Python | 48.16279 | 95 | 0.69806 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnEventUpdateTick.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.OgnEventUpdateTickDatabase import OgnEventUpdateTickDatabase
test_file_name = "OgnEventUpdateTickTemplate.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_UpdateTickEvent")
database = OgnEventUpdateTickDatabase(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:event"))
attribute = test_node.get_attribute("outputs:event")
db_value = database.outputs.event
| 1,694 | Python | 47.42857 | 94 | 0.705431 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnRandomGaussian.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:mean', {'type': 'float', 'value': 123.0}, False],
['inputs:stdev', {'type': 'float', 'value': 0.0}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float', 'value': 123.0}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'double[]', 'value': [-100, 100]}, False],
['inputs:stdev', {'type': 'double', 'value': 1}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'double[]', 'value': [-98.27423617, 100.04434614]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'half', 'value': 0}, False],
['inputs:stdev', {'type': 'half[2]', 'value': [1, 2]}, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'half[2]', 'value': [1.7255859, 0.08868408]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'float[2][]', 'value': [[1, 2], [3, 4]]}, False],
['inputs:stdev', {'type': 'float', 'value': 0}, False],
['inputs:useLog', True, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[2][]', 'value': [[1, 2], [3, 4]]}, False],
['outputs:execOut', 1, False],
],
},
{
'inputs': [
['inputs:useSeed', True, False],
['inputs:seed', 123456789, False],
['inputs:mean', {'type': 'float', 'value': 100}, False],
['inputs:stdev', {'type': 'float[]', 'value': [1, 1, 1, 1, 1]}, False],
['inputs:useLog', True, False],
['inputs:execIn', 1, False],
['inputs:isNoise', True, False],
],
'outputs': [
['outputs:random', {'type': 'float[]', 'value': [101.735756, 100.03935, 99.89501, 100.42319, 99.54652]}, 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.6957887336760361}, 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_RandomGaussian", "omni.graph.nodes.RandomGaussian", test_run, test_info)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomGaussian 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_RandomGaussian","omni.graph.nodes.RandomGaussian", test_run, test_info, 16)
await controller.evaluate(test_info.graph)
_test_verify_scene(self, controller, test_run, test_info, f"omni.graph.nodes.RandomGaussian 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_RandomGaussian", "omni.graph.nodes.RandomGaussian", 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.RandomGaussian User test case #{i+1}, instance{key}")
async def test_data_access(self):
from omni.graph.nodes.ogn.OgnRandomGaussianDatabase import OgnRandomGaussianDatabase
test_file_name = "OgnRandomGaussianTemplate.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_RandomGaussian")
database = OgnRandomGaussianDatabase(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:useLog"))
attribute = test_node.get_attribute("inputs:useLog")
db_value = database.inputs.useLog
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
| 9,083 | Python | 46.067357 | 201 | 0.578333 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnTimelineGet.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.OgnTimelineGetDatabase import OgnTimelineGetDatabase
test_file_name = "OgnTimelineGetTemplate.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_GetTimeline")
database = OgnTimelineGetDatabase(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:endFrame"))
attribute = test_node.get_attribute("outputs:endFrame")
db_value = database.outputs.endFrame
self.assertTrue(test_node.get_attribute_exists("outputs:endTime"))
attribute = test_node.get_attribute("outputs:endTime")
db_value = database.outputs.endTime
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:framesPerSecond"))
attribute = test_node.get_attribute("outputs:framesPerSecond")
db_value = database.outputs.framesPerSecond
self.assertTrue(test_node.get_attribute_exists("outputs:isLooping"))
attribute = test_node.get_attribute("outputs:isLooping")
db_value = database.outputs.isLooping
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:startFrame"))
attribute = test_node.get_attribute("outputs:startFrame")
db_value = database.outputs.startFrame
self.assertTrue(test_node.get_attribute_exists("outputs:startTime"))
attribute = test_node.get_attribute("outputs:startTime")
db_value = database.outputs.startTime
self.assertTrue(test_node.get_attribute_exists("outputs:time"))
attribute = test_node.get_attribute("outputs:time")
db_value = database.outputs.time
| 3,183 | Python | 46.522387 | 92 | 0.699969 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnIsPrimSelected.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.OgnIsPrimSelectedDatabase import OgnIsPrimSelectedDatabase
test_file_name = "OgnIsPrimSelectedTemplate.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_IsPrimSelected")
database = OgnIsPrimSelectedDatabase(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
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("outputs:isSelected"))
attribute = test_node.get_attribute("outputs:isSelected")
db_value = database.outputs.isSelected
| 2,309 | Python | 48.148935 | 93 | 0.699004 |
omniverse-code/kit/exts/omni.graph.nodes/omni/graph/nodes/ogn/tests/TestOgnConstantBool.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.OgnConstantBoolDatabase import OgnConstantBoolDatabase
test_file_name = "OgnConstantBoolTemplate.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_ConstantBool")
database = OgnConstantBoolDatabase(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 = 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))
| 1,930 | Python | 48.512819 | 92 | 0.7 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.