Skip to content

Commit

Permalink
Implement from_occasion for Subject
Browse files Browse the repository at this point in the history
Version bump for release
  • Loading branch information
mhovd committed Oct 17, 2024
1 parent 69986e7 commit bc25cca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pharmsol"
version = "0.7.0"
version = "0.7.1"
edition = "2021"
authors = ["Julián D. Otálvaro <[email protected]>", "Markus Hovd"]
description = "Rust library for solving analytic and ode-defined pharmacometric models."
Expand Down
12 changes: 12 additions & 0 deletions src/data/structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,23 @@ impl Subject {
pub(crate) fn new(id: String, occasions: Vec<Occasion>) -> Self {
Subject { id, occasions }
}

/// Get a vector of references to all [Occasion]s in the [Subject]
pub fn occasions(&self) -> Vec<&Occasion> {
self.occasions.iter().collect()
}

/// Get the ID of the [Subject]
pub fn id(&self) -> &String {
&self.id
}

/// Create a new [Subject] from one or more [Occasion]s
///
/// This can be useful if you want to create a [Subject] from a single [Occasion], or a vector of select [Occasion]s
pub fn from_occasions(id: String, occasions: Vec<Occasion>) -> Self {
Subject { id, occasions }
}
}

/// An [Occasion] is a collection of events, for a given [Subject], that are from a specific occasion
Expand All @@ -248,6 +259,7 @@ pub struct Occasion {
covariates: Covariates,
index: usize,
}

impl Occasion {
// Constructor
pub(crate) fn new(events: Vec<Event>, covariates: Covariates, index: usize) -> Self {
Expand Down

0 comments on commit bc25cca

Please sign in to comment.