Files
TashaSkyUp-EternalKernelPyt…/tests/test_utils.py
T
Tasha Upchurch 57e514b0b6 Add several new nodes:
- DecodeTranscriptNode to parse transcript text
- YoutubeUploadNode to upload videos to YouTube
- Audio metadata and file list nodes
- Image stack blending and stripping alpha channel
- Sampler dataset creation node
- Utils for deep copying tensors and arrays

Also includes:

- Testing for new utils module
- Git nodes marked with base class
- Renamed nodes.py to avoid conflicts
- Import refactoring to handle naming

Specifics:

- descript.py: New transcript parsing node
- youtube_nodes.py: New YouTube upload node
- audio.py: New audio metadata and file list nodes
- utils.py: Deep copy utility functions
- image.py: New image stack blending and alpha stripping
- tests/test_utils.py: Tests for new utils
- git.py: Marked git nodes with base class
- __init__.py: Refactored imports and mappings
- requirements.txt: Added YouTube dependencies
- functional.py: Minor tweaks
- modules/youtube.py: Helper for upload node
- video.py: Minor cleanup
- tests/test_youtube_nodes.py: Test for YouTube upload
2023-08-05 15:19:21 -04:00

42 lines
1.1 KiB
Python

import torch
import numpy as np
from custom_nodes.EternalKernelLiteGraphNodes.utils import etk_deep_copy
def test_etk_deep_copy():
original = {
"list": [1, 2, 3, [4, 5, 6], {"inner_list": [7, 8, 9]}],
"dict": {"inner_dict": {"key": "value"}}
}
torch_test = {"torch_tensor": torch.tensor([1, 2, 3])}
np_test = {"np_array": np.array([1, 2, 3])}
test(original)
test(torch_test)
test(np_test)
def test(original):
# Creating a deep copy
copy = etk_deep_copy(original)
# Modifying the original structure
if "list" in original:
original["list"][0] = 100
if isinstance(original["list"][3], list):
original["list"][3][0] = 200
if "inner_list" in original["list"][4]:
original["list"][4]["inner_list"][0] = 300
if "dict" in original and "inner_dict" in original["dict"]:
original["dict"]["inner_dict"]["key"] = "modified"
if "torch_tensor" in original:
original["torch_tensor"][0] = 100
if "np_array" in original:
original["np_array"][0] = 200
# Returning both the original and the copy for inspection
return original, copy