funcnodes-basic 0.1.8__py3-none-any.whl → 0.1.10__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,7 +6,7 @@ from .strings import NODE_SHELF as strings_shelf
6
6
  from .dicts import NODE_SHELF as dicts_shelf
7
7
 
8
8
 
9
- __version__ = "0.1.8"
9
+ __version__ = "0.1.10"
10
10
 
11
11
  NODE_SHELF = Shelf(
12
12
  nodes=[],
funcnodes_basic/lists.py CHANGED
@@ -1,5 +1,6 @@
1
- from typing import List, Union, Any
1
+ from typing import List, Union, Any, Tuple
2
2
  import funcnodes_core as fn
3
+ import copy
3
4
 
4
5
 
5
6
  @fn.NodeDecorator(
@@ -58,8 +59,213 @@ class GetIndexNode(fn.Node):
58
59
  return ele
59
60
 
60
61
 
62
+ @fn.NodeDecorator(
63
+ id="to_list",
64
+ name="To List",
65
+ )
66
+ def to_list(obj: Any) -> List[Any]:
67
+ try:
68
+ return list(obj)
69
+ except TypeError:
70
+ return [obj]
71
+
72
+
73
+ @fn.NodeDecorator(
74
+ id="list_length",
75
+ name="List Length",
76
+ )
77
+ def list_length(lst: List[Any]) -> int:
78
+ return len(lst)
79
+
80
+
81
+ @fn.NodeDecorator(
82
+ id="list_append",
83
+ name="List Append",
84
+ )
85
+ def list_append(lst: List[Any], item: Any) -> List[Any]:
86
+ return lst + [item]
87
+
88
+
89
+ @fn.NodeDecorator(
90
+ id="list_extend",
91
+ name="List Extend",
92
+ )
93
+ def list_extend(lst: List[Any], items: List[Any]) -> List[Any]:
94
+ return lst + items
95
+
96
+
97
+ @fn.NodeDecorator(
98
+ id="list_pop",
99
+ name="List Pop",
100
+ default_io_options={
101
+ "lst": {
102
+ "on": {
103
+ "after_set_value": fn.decorator.update_other_io_value_options(
104
+ "index",
105
+ lambda result: {"min": 0, "max": len(result) - 1},
106
+ )
107
+ }
108
+ },
109
+ },
110
+ outputs=[
111
+ {"name": "new_list"},
112
+ {"name": "item"},
113
+ ],
114
+ )
115
+ def list_pop(lst: List[Any], index: int) -> Tuple[List[Any], Any]:
116
+ # shallow copy the list
117
+ lst = copy.copy(lst)
118
+ item = lst.pop(index)
119
+ return lst, item
120
+
121
+
122
+ @fn.NodeDecorator(
123
+ id="list_remove",
124
+ name="List Remove",
125
+ )
126
+ def list_remove(lst: List[Any], item: Any, all: bool = False) -> List[Any]:
127
+ lst = copy.copy(lst)
128
+ if item in lst:
129
+ lst.remove(item)
130
+ if all:
131
+ while item in lst:
132
+ lst.remove(item)
133
+ return lst
134
+
135
+
136
+ @fn.NodeDecorator(
137
+ id="list_index",
138
+ name="List Index",
139
+ )
140
+ def list_index(lst: List[Any], item: Any) -> int:
141
+ return lst.index(item)
142
+
143
+
144
+ @fn.NodeDecorator(
145
+ id="list_reverse",
146
+ name="List Reverse",
147
+ )
148
+ def list_reverse(lst: List[Any]) -> List[Any]:
149
+ lst = copy.copy(lst)
150
+ lst.reverse()
151
+ return lst
152
+
153
+
154
+ @fn.NodeDecorator(
155
+ id="list_sort",
156
+ name="List Sort",
157
+ )
158
+ def list_sort(lst: List[Any], reverse: bool = False) -> List[Any]:
159
+ lst = copy.copy(lst)
160
+ lst.sort(reverse=reverse)
161
+ return lst
162
+
163
+
164
+ @fn.NodeDecorator(
165
+ id="list_count",
166
+ name="List Count",
167
+ )
168
+ def list_count(lst: List[Any], item: Any) -> int:
169
+ return lst.count(item)
170
+
171
+
172
+ @fn.NodeDecorator(
173
+ id="list_insert",
174
+ name="List Insert",
175
+ default_io_options={
176
+ "lst": {
177
+ "on": {
178
+ "after_set_value": fn.decorator.update_other_io_value_options(
179
+ "index",
180
+ lambda result: {"min": 0, "max": len(result)},
181
+ )
182
+ }
183
+ },
184
+ },
185
+ )
186
+ def list_insert(lst: List[Any], index: int, item: Any) -> List[Any]:
187
+ lst = copy.copy(lst)
188
+ lst.insert(index, item)
189
+ return lst
190
+
191
+
192
+ @fn.NodeDecorator(
193
+ id="list_set",
194
+ name="List Set",
195
+ default_io_options={
196
+ "lst": {
197
+ "on": {
198
+ "after_set_value": fn.decorator.update_other_io_value_options(
199
+ "index",
200
+ lambda result: {"min": 0, "max": len(result) - 1},
201
+ )
202
+ }
203
+ },
204
+ },
205
+ )
206
+ def list_set(lst: List[Any], index: int, item: Any) -> List[Any]:
207
+ lst = copy.copy(lst)
208
+ lst[index] = item
209
+ return lst
210
+
211
+
212
+ @fn.NodeDecorator(
213
+ id="list_slice",
214
+ name="List Slice",
215
+ default_io_options={
216
+ "lst": {
217
+ "on": {
218
+ "after_set_value": fn.decorator.update_other_io_value_options(
219
+ ["start", "end"],
220
+ lambda result: {"min": -len(result), "max": len(result) + 1},
221
+ ),
222
+ }
223
+ },
224
+ },
225
+ )
226
+ def list_slice(lst: List[Any], start: int = 0, end: int = -1) -> List[Any]:
227
+ return lst[start:end]
228
+
229
+
230
+ @fn.NodeDecorator(
231
+ id="list_slice_step",
232
+ name="List Slice Step",
233
+ default_io_options={
234
+ "lst": {
235
+ "on": {
236
+ "after_set_value": fn.decorator.update_other_io_value_options(
237
+ ["start", "end"],
238
+ lambda result: {"min": -len(result), "max": len(result) + 1},
239
+ ),
240
+ }
241
+ },
242
+ },
243
+ )
244
+ def list_slice_step(
245
+ lst: List[Any], start: int = 0, end: int = -1, step: int = 1
246
+ ) -> List[Any]:
247
+ return lst[start:end:step]
248
+
249
+
61
250
  NODE_SHELF = fn.Shelf(
62
- nodes=[contains, GetIndexNode],
251
+ nodes=[
252
+ contains,
253
+ GetIndexNode,
254
+ to_list,
255
+ list_length,
256
+ list_append,
257
+ list_extend,
258
+ list_pop,
259
+ list_remove,
260
+ list_index,
261
+ list_reverse,
262
+ list_sort,
263
+ list_count,
264
+ list_insert,
265
+ list_set,
266
+ list_slice,
267
+ list_slice_step,
268
+ ],
63
269
  subshelves=[],
64
270
  name="Lists",
65
271
  description="List operations",
@@ -22,9 +22,7 @@ def value_node(value: float) -> float:
22
22
  )
23
23
  def add_node(a: float, b: float) -> float:
24
24
  """Add two numbers"""
25
- a = float(a)
26
- b = float(b)
27
- return a + b
25
+ return float(a) + float(b)
28
26
 
29
27
 
30
28
  @NodeDecorator(
@@ -154,7 +154,7 @@ def string_split(s: str, delimiter: Optional[str] = None) -> List[str]:
154
154
  {"name": "joined"},
155
155
  ],
156
156
  )
157
- def string_join(strings: List[str], delimiter: str = " ") -> str:
157
+ def string_join(strings: List[str], delimiter: str = "") -> str:
158
158
  return delimiter.join(strings)
159
159
 
160
160
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: funcnodes-basic
3
- Version: 0.1.8
3
+ Version: 0.1.10
4
4
  Summary: Basic functionalities for funcnodes
5
5
  License: MIT
6
6
  Author: Julian Kimmig
@@ -10,8 +10,9 @@ Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
13
14
  Requires-Dist: funcnodes
14
- Requires-Dist: funcnodes-core (>=0.1.14)
15
+ Requires-Dist: funcnodes-core (>=0.1.24)
15
16
  Project-URL: download, https://pypi.org/project/funcnodes-basic/#files
16
17
  Project-URL: homepage, https://github.com/Linkdlab/funcnodes_basic
17
18
  Project-URL: source, https://github.com/Linkdlab/funcnodes_basic
@@ -0,0 +1,11 @@
1
+ funcnodes_basic/__init__.py,sha256=KTwOVIWjb4bZ2w0RLTdG18BX-vZlvqDs46ZnYOJROYU,518
2
+ funcnodes_basic/dicts.py,sha256=koNJEwIq9ryC7evBpnI-QmR7MBIbgUWqpPpwhB3M69Y,2507
3
+ funcnodes_basic/lists.py,sha256=D2RH1-zMa9geKClyR_KqTVQelH4DJI26ukr2ax4vD7c,6041
4
+ funcnodes_basic/logic.py,sha256=ecWXzkgjxYMfMdvm0Gdt-agsSbe9-_ilCNfhLz5OFXk,3575
5
+ funcnodes_basic/math_nodes.py,sha256=PasNf-1wAvbJ_c-_qeiIDaUVfgPQEREJApeUcTS4FQg,10586
6
+ funcnodes_basic/strings.py,sha256=O6rcxBQJ5eYd765w_tolaD6xMwsNmtBjiPgJ_69tKyA,16429
7
+ funcnodes_basic-0.1.10.dist-info/LICENSE,sha256=VcvnA4LohgMs8yTDTS1sS3aZbSFa3Ei9YeJogeosE7Y,1070
8
+ funcnodes_basic-0.1.10.dist-info/METADATA,sha256=sXStmwolU5OeWm_xRPaRnJmth3VPi8m8xcMGup41nhY,2117
9
+ funcnodes_basic-0.1.10.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
10
+ funcnodes_basic-0.1.10.dist-info/entry_points.txt,sha256=Y7-9Rw_0qbyg8MrdLG6zjiEmUYBug_K4TBdJz9MAKxA,76
11
+ funcnodes_basic-0.1.10.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.9.0
2
+ Generator: poetry-core 1.9.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,11 +0,0 @@
1
- funcnodes_basic/__init__.py,sha256=BG1nvOaC2eeBoq5rtSfKwqxeB5nZd7YK3Kn6QQeSD4o,517
2
- funcnodes_basic/dicts.py,sha256=koNJEwIq9ryC7evBpnI-QmR7MBIbgUWqpPpwhB3M69Y,2507
3
- funcnodes_basic/lists.py,sha256=Sm4u1lqCbB9dQcY_YOTMRsBccUYfKGXaU_3kiqX8YhY,1566
4
- funcnodes_basic/logic.py,sha256=ecWXzkgjxYMfMdvm0Gdt-agsSbe9-_ilCNfhLz5OFXk,3575
5
- funcnodes_basic/math_nodes.py,sha256=tOwKty1x2TSXiHMFTFJQThZ1Ef0hSNUbCrOEhBPIpEM,10606
6
- funcnodes_basic/strings.py,sha256=3K0VvObVLdXpQmw1Aaxz3ZOdX6jkw9pUh_IB2qITmX0,16430
7
- funcnodes_basic-0.1.8.dist-info/LICENSE,sha256=VcvnA4LohgMs8yTDTS1sS3aZbSFa3Ei9YeJogeosE7Y,1070
8
- funcnodes_basic-0.1.8.dist-info/METADATA,sha256=n_i6ia25ifBwz60QQw4-S7B9OaEfXMlyB2Qq0-EHAbM,2065
9
- funcnodes_basic-0.1.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
10
- funcnodes_basic-0.1.8.dist-info/entry_points.txt,sha256=Y7-9Rw_0qbyg8MrdLG6zjiEmUYBug_K4TBdJz9MAKxA,76
11
- funcnodes_basic-0.1.8.dist-info/RECORD,,