Initial phase of adding PyTorch support for data analysis. Added conversion nodes.

This commit is contained in:
HowToSD
2025-02-24 21:50:18 -08:00
parent 4a0d561d8f
commit 17a40d7798
30 changed files with 1042 additions and 1 deletions
@@ -0,0 +1,47 @@
from typing import Any, Dict
import numpy as np
import ast
class NumpyFloatCreate:
"""
Creates a NumPy ndarray with 32-bit floating point precision
using values entered in the text field.
category: Numpy
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"data": ("STRING", {"multiline": True}),
}
}
RETURN_TYPES: tuple = ("NDARRAY",)
FUNCTION: str = "f"
CATEGORY: str = "Numpy wrapper"
def f(self, data: str) -> tuple:
"""
Creates a Numpy ndarray using values entered in the text field.
Args:
data (str): String value in the text field.
Returns:
tuple: A tuple containing a the DataFrame.
"""
# Convert string to Python list
list_data = ast.literal_eval(data)
# Convert list to NumPy array
array = np.array(list_data, dtype=np.float32)
return (array,)
+48
View File
@@ -0,0 +1,48 @@
from typing import Any, Dict
import numpy as np
import ast
class NumpyIntCreate:
"""
Creates a NumPy ndarray with 32-bit integer
using values entered in the text field.
category: Numpy
"""
@classmethod
def INPUT_TYPES(cls) -> Dict[str, Any]:
"""
Defines the input types for the function.
Returns:
Dict[str, Any]: A dictionary specifying required input types.
"""
return {
"required": {
"data": ("STRING", {"multiline": True}),
}
}
RETURN_TYPES: tuple = ("NDARRAY",)
FUNCTION: str = "f"
CATEGORY: str = "Numpy wrapper"
def f(self, data: str) -> tuple:
"""
Creates a NumPy ndarray with 32-bit integer using values
entered in the text field.
Args:
data (str): String value in the text field.
Returns:
tuple: A tuple containing the NumPy ndarray.
"""
# Convert string to Python list
list_data = ast.literal_eval(data)
# Convert list to NumPy int32 array
array = np.array(list_data, dtype=np.int32)
return (array,)