Skip to content

Commit

Permalink
Bump version (#57)
Browse files Browse the repository at this point in the history
* rename to CombinedConnections

* add to __init__

* bump version

* poetry update
  • Loading branch information
PythonFZ authored Mar 22, 2023
1 parent 3f1e36d commit fadf4c9
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 120 deletions.
204 changes: 103 additions & 101 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "znflow"
version = "0.1.5"
version = "0.1.6"
description = ""
authors = ["zincwarecode <[email protected]>"]
license = "Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions tests/test_add_connections.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import znflow
from znflow.base import AddedConnections
from znflow.base import CombinedConnections


@znflow.nodify
Expand Down Expand Up @@ -41,7 +41,7 @@ def test_AddLists():

outs = AddOne(lst1.outs + lst2.outs)

assert isinstance(outs.value, AddedConnections)
assert isinstance(outs.value, CombinedConnections)
assert len(outs.value.connections) == 2
assert outs.value.connections[0].instance is lst1
assert outs.value.connections[0].attribute == "outs"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_znflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

def test_version():
"""Test the version."""
assert znflow.__version__ == "0.1.5"
assert znflow.__version__ == "0.1.6"
2 changes: 2 additions & 0 deletions znflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import sys

from znflow.base import (
CombinedConnections,
Connection,
FunctionFuture,
Property,
Expand All @@ -26,6 +27,7 @@
"get_attribute",
"disable_graph",
"Property",
"CombinedConnections",
]

logger = logging.getLogger(__name__)
Expand Down
26 changes: 13 additions & 13 deletions znflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ def __iter__(self):
raise TypeError(f"Can not iterate over {self}.")

def __add__(
self, other: typing.Union[Connection, FunctionFuture, AddedConnections]
) -> AddedConnections:
if isinstance(other, (Connection, FunctionFuture, AddedConnections)):
return AddedConnections(connections=[self, other])
self, other: typing.Union[Connection, FunctionFuture, CombinedConnections]
) -> CombinedConnections:
if isinstance(other, (Connection, FunctionFuture, CombinedConnections)):
return CombinedConnections(connections=[self, other])
raise TypeError(f"Can not add {type(other)} to {type(self)}.")

@property
Expand All @@ -176,12 +176,12 @@ def result(self):


@dataclasses.dataclass(frozen=True)
class AddedConnections:
class CombinedConnections:
"""Combine multiple Connections into one.
This class allows to 'add' Connections and/or FunctionFutures.
This only works if the Connection or FunctionFuture points to a 'list'.
A new entry of 'AddedConnections' will be created for every time a new
A new entry of 'CombinedConnections' will be created for every time a new
item is added.
Examples
Expand All @@ -208,8 +208,8 @@ class AddedConnections:
item: any = None

def __add__(
self, other: typing.Union[Connection, FunctionFuture, AddedConnections]
) -> AddedConnections:
self, other: typing.Union[Connection, FunctionFuture, CombinedConnections]
) -> CombinedConnections:
"""Implement add for AddedConnections.
Raises
Expand All @@ -223,7 +223,7 @@ def __add__(
raise ValueError("Can not combine multiple slices")
if isinstance(other, (Connection, FunctionFuture)):
return dataclasses.replace(self, connections=self.connections + [other])
elif isinstance(other, AddedConnections):
elif isinstance(other, CombinedConnections):
return dataclasses.replace(
self, connections=self.connections + other.connections
)
Expand Down Expand Up @@ -271,8 +271,8 @@ def __iter__(self):
raise TypeError(f"Can not iterate over {self}.")

def __add__(
self, other: typing.Union[Connection, FunctionFuture, AddedConnections]
) -> AddedConnections:
if isinstance(other, (Connection, FunctionFuture, AddedConnections)):
return AddedConnections(connections=[self, other])
self, other: typing.Union[Connection, FunctionFuture, CombinedConnections]
) -> CombinedConnections:
if isinstance(other, (Connection, FunctionFuture, CombinedConnections)):
return CombinedConnections(connections=[self, other])
raise TypeError(f"Can not add {type(other)} to {type(self)}.")
4 changes: 2 additions & 2 deletions znflow/handler.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from znflow import utils
from znflow.base import AddedConnections, Connection, FunctionFuture
from znflow.base import CombinedConnections, Connection, FunctionFuture
from znflow.node import Node


Expand All @@ -24,7 +24,7 @@ def default(self, value, **kwargs):

class UpdateConnectors(utils.IterableHandler):
def default(self, value, **kwargs):
if isinstance(value, (Connection, AddedConnections)):
if isinstance(value, (Connection, CombinedConnections)):
return value.result
else:
return value

0 comments on commit fadf4c9

Please sign in to comment.