Skip to content

Commit

Permalink
Fix issue #1
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanCooper committed Jan 19, 2022
1 parent 47bbe41 commit b5ba968
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion indcomp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
- Simulated Treatment Comparison (STC)
"""

__version__ = "0.1.0"
__version__ = "0.1.1"

from ._maic import MAIC
14 changes: 10 additions & 4 deletions indcomp/_maic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 11 additions & 4 deletions tests/test_maic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b5ba968

Please sign in to comment.