diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0c4b6ff --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,16 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.1] - 2022-01-19 + +### Fixed + +- Fixed `MAIC.compare_populations` bug [[#1](https://github.com/AidanCooper/indcomp/issues/1)] + +## [0.1.0] - 2022-01-17 + +Initial alpha release \ No newline at end of file diff --git a/indcomp/__init__.py b/indcomp/__init__.py index de1528a..7401508 100644 --- a/indcomp/__init__.py +++ b/indcomp/__init__.py @@ -8,6 +8,6 @@ - Simulated Treatment Comparison (STC) """ -__version__ = "0.1.0" +__version__ = "0.1.1" from ._maic import MAIC diff --git a/indcomp/_maic.py b/indcomp/_maic.py index 8a28c92..c25c111 100644 --- a/indcomp/_maic.py +++ b/indcomp/_maic.py @@ -174,12 +174,18 @@ def compare_populations( raise e.NoWeightsException() # create grid - ncols = min(ncols, len(variables)) - nrows = len(variables) // ncols - remainder = len(variables) % ncols + if len(variables) == 1: + ncols, nrows, remainder = 1, 1, 0 + else: + ncols = min(ncols, len(variables)) + nrows = len(variables) // ncols + remainder = len(variables) % ncols fig, axes = plt.subplots(nrows, ncols, figsize=(ncols * 4, nrows * 4)) fig.patch.set_facecolor("white") - axes = axes.flatten() + if len(variables) == 1: + axes = [axes] + else: + axes = axes.flatten() for r in range(1, remainder + 1): axes[-r].axis("off") diff --git a/setup.py b/setup.py index 4a6bd2e..2f3be3f 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="indcomp", - version="0.1.0", + version="0.1.1", description="Perform indirect treatment comparison (ITC) analyses", long_description=README, long_description_content_type="text/markdown", diff --git a/tests/test_maic.py b/tests/test_maic.py index 7884cea..410416b 100644 --- a/tests/test_maic.py +++ b/tests/test_maic.py @@ -19,14 +19,19 @@ def data_NICE_DSU18(): return (df_ind, df_tar) -@pytest.fixture -def correct_config_maic(data_NICE_DSU18): +@pytest.fixture( + params=[ + {"age.mean": ("mean", "age")}, + {"age.mean": ("mean", "age"), "age.sd": ("std", "age", "age.mean")}, + ] +) +def correct_config_maic(request, data_NICE_DSU18): """Return a correctly configued MAIC instance""" df_ind, df_tar = data_NICE_DSU18 return MAIC( df_ind, df_tar, - {"age.mean": ("mean", "age"), "age.sd": ("std", "age", "age.mean")}, + request.param, ) @@ -123,7 +128,9 @@ def test_maic_methods(correct_config_maic): # calculate_weights with optional_step("calculate_weights") as calculate_weights: maic.calc_weights() - assert np.isclose(maic.ESS_, 178.56, atol=0.01) + assert np.isclose(maic.ESS_, 178.56, atol=0.01) or np.isclose( + maic.ESS_, 188.89, atol=0.01 + ) yield calculate_weights # plot_weights