Skip to content

Commit

Permalink
Merge pull request #71 from teald/hotfix-initialization
Browse files Browse the repository at this point in the history
Hotfix initialization/finalization empty returns
  • Loading branch information
teald authored Feb 6, 2023
2 parents c58852b + 93b7e1c commit 55875a9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = "D J Teal"

# The full version, including alpha/beta/rc tags
release = "1.0.0"
release = "1.0.1"


# -- General configuration ---------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions porchlight/neighborhood.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def initialize(self):
# via Neighborhood.add_param.
neighborhood_params = tuple(self.params.keys())

if len(return_values) == 1:
if len(return_values) <= 1:
result = [result]

for retval, value in zip(return_values, result):
Expand All @@ -631,7 +631,7 @@ def finalize(self):
"""
# Ensure finalization is iterable, if not raise either a ValueError
# (because it is not a valid object) or TypeError (because it is not a
# string nor a door.Door).
# list nor a door.Door).
if not hasattr(self.finalization, "__iter__"):
self.finalization = [self.finalization]

Expand All @@ -654,7 +654,7 @@ def finalize(self):

result = fxn(*arguments, **keyword_arguments)

if len(return_values) == 1:
if len(return_values) <= 1:
result = [result]

for retval, value in zip(return_values, result):
Expand Down
25 changes: 25 additions & 0 deletions porchlight/tests/test_neighborhood.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,31 @@ def test1(x):
self.assertEqual(neighborhood.get_value("x"), 5)
self.assertEqual(neighborhood.get_value("y"), 25)

@unittest.skip(reason="Because")
def test_plain_initialization(self):
# Testing specifically a None-returning function.
def inittest1():
pass

neighborhood = Neighborhood([], initialization=inittest1)
neighborhood.run_step()

neighborhood_2 = Neighborhood([], initialization=[inittest1])
neighborhood_2.run_step()

def test_plain_finalization(self):
# Testing specifically a None-returning function.
def inittest1():
pass

neighborhood = Neighborhood([], finalization=inittest1)
neighborhood.run_step()
neighborhood.finalize()

neighborhood_2 = Neighborhood([], finalization=[inittest1])
neighborhood_2.run_step()
neighborhood_2.finalize()

def test_finalization(self):
def inittest1():
x = 5
Expand Down
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 = "porchlight"
version = "1.0.0"
version = "1.0.1"
description = "A function-managing package for models and systems with shared variables."
authors = ["Teal, D <[email protected]>"]
license = "GNU General Public License v3.0 or later"
Expand Down

0 comments on commit 55875a9

Please sign in to comment.