Skip to content
Open
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
26 changes: 14 additions & 12 deletions SMHviz_plot/utils_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ def sample_df(df, scenario, pathogen, k=1000):
all_sample_sel = list(np.random.permutation(all_sample_sel))
df_sample_sel = df_scen.reset_index().set_index("sample_id").loc[all_sample_sel]
all_sample = df_sample_sel.reset_index().drop(columns="index")
all_sample["sample_id_n"] = list(np.repeat(list(range(k)), len(df_scen['horizon'].drop_duplicates())))

all_sample["sample_id_n"] = np.repeat(np.arange(k), len(df_scen['horizon'].drop_duplicates()))

all_sample = all_sample[["value", "target_end_date", "sample_id_n"]]
all_sample = all_sample.rename(columns={"value": "value" + "_" + pathogen})
else:
Expand All @@ -223,7 +225,7 @@ def q1(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.025)
return np.quantile(x, 0.025)


def q2(x):
Expand All @@ -235,7 +237,7 @@ def q2(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.05)
return np.quantile(x, 0.05)


def q3(x):
Expand All @@ -247,7 +249,7 @@ def q3(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.1)
return np.quantile(x, 0.1)


def q4(x):
Expand All @@ -259,7 +261,7 @@ def q4(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.25)
return np.quantile(x, 0.25)


def q5(x):
Expand All @@ -271,7 +273,7 @@ def q5(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.75)
return np.quantile(x, 0.75)


def q6(x):
Expand All @@ -283,7 +285,7 @@ def q6(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.9)
return np.quantile(x, 0.9)


def q7(x):
Expand All @@ -295,7 +297,7 @@ def q7(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.95)
return np.quantile(x, 0.95)


def q8(x):
Expand All @@ -307,7 +309,7 @@ def q8(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.975)
return np.quantile(x, 0.975)


def med(x):
Expand All @@ -319,7 +321,7 @@ def med(x):
:type x: pd.Series
:return: float
"""
return x.quantile(0.5)
return np.quantile(x, 0.5)


def mean(x):
Expand Down Expand Up @@ -391,9 +393,9 @@ def prep_multipat_plot_comb(pathogen_information, calc_mean=False):
# Preparation
pathogen_name = patho.lower()
if calc_mean is True:
f2.update({"proportion_" + pathogen_name: [med, mean, q1, q2, q3, q4, q5, q6, q7, q8]})
f2.update({"proportion_" + pathogen_name: [mean, q4, q5]})
else:
f2.update({"proportion_" + pathogen_name: [med, q1, q2, q3, q4, q5, q6, q7, q8]})
f2.update({"proportion_" + pathogen_name: [q4, q5]})
all_sample["proportion_" + pathogen_name] = all_sample["value_" + pathogen_name] / all_sample["value"]
# Calculate the quantiles for each "value" and "proportion" columns
all_quantile = all_sample.groupby(["target_end_date"]).agg(f)
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

All notable changes to this project will be documented in this file.

## 0.0.1

First version
153 changes: 153 additions & 0 deletions docs/release_protocol.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Release Process

Parts of this document is adapted for the U.S. Scenario Modeling Hub (SMH) from
[The Hubverse](https://hubverse-org.github.io/hubDevs/articles/release-process.html)
and from
[The Carpentries Developer's Handbook](https://carpentries.github.io/workbench-dev/releases.html) ©
The Carpentries under the
[CC-BY 4.0 license](https://creativecommons.org/licenses/by/4.0/).

## Workflow

The release process follow a general workflow:

1. Iterate on small bug fixes and PRs on branches:
- merging into `main` once ready to publish/deploy
- merging into a development branch (here called `dev`) for ongoing test/process
2. When ready to release on `main`: bump the version, add an annotated git tag, and release
3. Bump the version in main back to a development version

Some of the steps in these instructions are specific for R packages, but they are largely process-based
and can apply to Python packages as well.

### Versioning

The SMH is built using very basic semantic versioning using the X.Y.Z[.9000] pattern. Everything that
has a .9000 attached is considered in-development.

`X`: **Major version number**: this version number will change if there are significant breaking
changes to any of the user-facing workflows. That is, if a change requires users to modify their
scripts, then it is a breaking change.

`Y`: **Minor version number**: this version number will change if there are new features or
enhanced behaviors available to the users in a way that *does not affect how users who do not
need the new features use the package*. This number grows the fastest in early stages of development.

`Z`: **Patch version number**: this version number will change if something that was previously
broken was fixed, but no new features have been added.

`9000`: **Development version indicator**: this version number indicates that the package is in a
development state and has the potential to change. When its on the main branch, it indicates
that the features or patches introduced have been reviewed and tested. This version is appended
after every successful release.

### Hotfixes

A hotfix is a bug fix for a situation where a bug has been found, but the main branch has new features
that are not yet ready to be released.

## Checklist

### Updates

[] Create new branch from `main` (or `master`, or branch of interest) called `"<author initial>/<feature>/<issue>"`

[] Update `Changelog.md` accordingly

[] Commit, push

[] Open Pull-Request (PR) on branch of interest (`main` for release we want to implement quickly or ready to deploy, other
branch of interest for ongoing updates)

[] Merge after review, once all accepted

**Create new release version only if important change, see version**

### Release

[] Create new branch from `main` (or `master`) called `"<author>/release/X.Y.Z"`

[] Update `pyproject.toml` and `Changelog.md` accordingly

[] Commit, push

[] Open Pull-Request (PR)

[] Merge after review, once all accepted

[] Checkout `main` branch (or `master`) & make sure it's up to date

[] Add new tag

```
git tag -a v.X.Y.Z -m '<short message>'
git push --tags
```

[] Create a new release on GitHub (can be done using R, for example)

```r
usethis::use_github_release()
```

### Post-Release

[] Create new branch from `main` (or `master`) called `"post-release-X.Y.Z"`

[] Set project to dev version (can be done using R, for example):
- adding `.9000` to the version number
- adding new heading to `Changelog.md` (`## <package name> (development)`)

```r
usethis::use_dev_version()
```

[] Commit, push, open Pull-Request (PR)

[] Merge after review, once all accepted


### Subsequent updates

[] Create new branch from `main` (or `master`, or branch of interest) called `"<author initial>/<feature>/<issue>"`

[] Update `Changelog.md` accordingly

[] Commit, push

[] Open Pull-Request (PR)

[] Merge after review, once all accepted

**Create new release version only if important change, see version**

### Hotfixes

[] Create new branch from `main` (or `master`) called `"<author>/hotfix/<issue>"`

```
git switch --detach v.X.Y.Z'
git switch -c <author>/hotfix/<issue>
```

[] Write a test, fix the bug, commit, push
** Don't change the version **

[] Open Pull-Request (PR)

[] Update `Changelog.md` accordingly and bump the patch version in `pyproject.toml`

```
git commit -m 'bump version to X.Y.Z+1'
git tag -a v.X.Y.Z+1 -m '<short message>'
git push
git push --tags
```

[] Create a new release on GitHub (can be done using R, for example)

```r
usethis::use_github_release()
```

[] Resolve conflicts in PR & merge into `main` (or `master`)