Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region Sampler bug fixed #22

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions epios/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from .sampler_region import SamplerRegion # noqa
from .sampler_age_region import SamplerAgeRegion # noqa
from .post_process import PostProcess # noqa
from .re_scaler import ReScaler # noqa
6 changes: 4 additions & 2 deletions epios/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,8 @@ def _wrapper_Region_AgeRegion(self, sampling_method, sample_size, time_sample, n

# Plot the figure
if gen_plot:
plt.plot(time_sample, infected_rate)
infected_population = np.array(infected_rate) * len(self.demo_data)
plt.plot(time_sample, infected_population)
plt.xlabel('Time')
plt.ylabel('Population')
plt.xlim(0, max(time_sample))
Expand Down Expand Up @@ -744,7 +745,8 @@ def _wrapper_Age_Base(self, sampling_method, sample_size, time_sample,

# Plot the figure
if gen_plot:
plt.plot(time_sample, infected_rate)
infected_population = np.array(infected_rate) * len(self.demo_data)
plt.plot(time_sample, infected_population)
plt.xlabel('Time')
plt.ylabel('Population')
plt.xlim(0, max(time_sample))
Expand Down
2 changes: 1 addition & 1 deletion epios/sampler_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def multinomial_draw(self, n: int, prob: list):
cap_region = []
record_cap_region = []
for i in range(len(prob)):
cap_region.append(min(max(n * prob[i] + 0.005 * n, 1),
cap_region.append(min(n * prob[i] + 0.005 * n + 1,
self.geoinfo[self.geoinfo['cell'] == i]['Susceptible'].sum()))
record_cap_region.append(self.geoinfo[self.geoinfo['cell'] == i]['Susceptible'].sum())
cap_region = [cap_region, list(np.arange(len(cap_region)))]
Expand Down
2 changes: 1 addition & 1 deletion epios/tests/test_re_scaler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from unittest import TestCase
from numpy.random import rand
from numpy import array
from epios.re_scaler import ReScaler
from re_scaler import ReScaler


class TestRS(TestCase):
Expand Down
Loading