From f411fdf6cc95ee99c709a59ce4a0da6a31989391 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernanda=20De=20Le=C3=B3n?= Date: Wed, 9 Oct 2024 10:58:47 -0600 Subject: [PATCH 1/4] update documentation of tensor and format return type --- aepsych/generators/acqf_thompson_sampler_generator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aepsych/generators/acqf_thompson_sampler_generator.py b/aepsych/generators/acqf_thompson_sampler_generator.py index 9a744f56d..fb81637ae 100644 --- a/aepsych/generators/acqf_thompson_sampler_generator.py +++ b/aepsych/generators/acqf_thompson_sampler_generator.py @@ -76,7 +76,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. + or shape [num_points x dim x 2] if pairing is applied. """ if self.stimuli_per_trial == 2: From d3061c6102dd093cbbff7a53c84a6bfaefa5e1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernanda=20De=20Le=C3=B3n?= Date: Wed, 9 Oct 2024 12:06:22 -0600 Subject: [PATCH 2/4] update tensor documentation with format and return type --- aepsych/generators/acqf_thompson_sampler_generator.py | 4 ++-- aepsych/generators/manual_generator.py | 2 +- aepsych/generators/monotonic_rejection_generator.py | 2 +- aepsych/generators/monotonic_thompson_sampler_generator.py | 2 +- aepsych/generators/optimize_acqf_generator.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/aepsych/generators/acqf_thompson_sampler_generator.py b/aepsych/generators/acqf_thompson_sampler_generator.py index fb81637ae..510345aa2 100644 --- a/aepsych/generators/acqf_thompson_sampler_generator.py +++ b/aepsych/generators/acqf_thompson_sampler_generator.py @@ -76,8 +76,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. - or shape [num_points x dim x 2] if pairing is applied. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim] or + shape [num_points x dim x stimuli_per_trial] if `stimuli_per_trial` is greater than 1. """ if self.stimuli_per_trial == 2: diff --git a/aepsych/generators/manual_generator.py b/aepsych/generators/manual_generator.py index f794db2ab..100f5e0b5 100644 --- a/aepsych/generators/manual_generator.py +++ b/aepsych/generators/manual_generator.py @@ -57,7 +57,7 @@ def gen( Args: num_points (int): Number of points to query. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. """ if num_points > (len(self.points) - self._idx): warnings.warn( diff --git a/aepsych/generators/monotonic_rejection_generator.py b/aepsych/generators/monotonic_rejection_generator.py index 6676feaf9..1317f07f4 100644 --- a/aepsych/generators/monotonic_rejection_generator.py +++ b/aepsych/generators/monotonic_rejection_generator.py @@ -80,7 +80,7 @@ def gen( num_points (int, optional): Number of points to query. model (AEPsychMixin): Fitted model of the data. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. """ options = self.model_gen_options or {} diff --git a/aepsych/generators/monotonic_thompson_sampler_generator.py b/aepsych/generators/monotonic_thompson_sampler_generator.py index b08d50bbb..89a30c299 100644 --- a/aepsych/generators/monotonic_thompson_sampler_generator.py +++ b/aepsych/generators/monotonic_thompson_sampler_generator.py @@ -60,7 +60,7 @@ def gen( num_points (int, optional): Number of points to query. model (AEPsychMixin): Fitted model of the data. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. """ # Generate the points at which to sample diff --git a/aepsych/generators/optimize_acqf_generator.py b/aepsych/generators/optimize_acqf_generator.py index 77ab1a42d..2b01d9b57 100644 --- a/aepsych/generators/optimize_acqf_generator.py +++ b/aepsych/generators/optimize_acqf_generator.py @@ -80,7 +80,7 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape `[num_points x dim]`. """ if self.stimuli_per_trial == 2: From 61d068da6e9e3763512bfecf6a8eb910ea978b1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernanda=20De=20Le=C3=B3n?= Date: Wed, 9 Oct 2024 12:25:09 -0600 Subject: [PATCH 3/4] Fix lint --- aepsych/generators/acqf_thompson_sampler_generator.py | 4 ++-- aepsych/generators/manual_generator.py | 2 +- aepsych/generators/monotonic_rejection_generator.py | 2 +- aepsych/generators/optimize_acqf_generator.py | 3 ++- aepsych/generators/random_generator.py | 2 +- aepsych/generators/sobol_generator.py | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/aepsych/generators/acqf_thompson_sampler_generator.py b/aepsych/generators/acqf_thompson_sampler_generator.py index 510345aa2..455ee2433 100644 --- a/aepsych/generators/acqf_thompson_sampler_generator.py +++ b/aepsych/generators/acqf_thompson_sampler_generator.py @@ -76,8 +76,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim] or - shape [num_points x dim x stimuli_per_trial] if `stimuli_per_trial` is greater than 1. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. + or shape [num_points x dim x 2] if pairing is applied. """ if self.stimuli_per_trial == 2: diff --git a/aepsych/generators/manual_generator.py b/aepsych/generators/manual_generator.py index 100f5e0b5..1f3526501 100644 --- a/aepsych/generators/manual_generator.py +++ b/aepsych/generators/manual_generator.py @@ -57,7 +57,7 @@ def gen( Args: num_points (int): Number of points to query. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. """ if num_points > (len(self.points) - self._idx): warnings.warn( diff --git a/aepsych/generators/monotonic_rejection_generator.py b/aepsych/generators/monotonic_rejection_generator.py index 1317f07f4..d13108adf 100644 --- a/aepsych/generators/monotonic_rejection_generator.py +++ b/aepsych/generators/monotonic_rejection_generator.py @@ -80,7 +80,7 @@ def gen( num_points (int, optional): Number of points to query. model (AEPsychMixin): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. """ options = self.model_gen_options or {} diff --git a/aepsych/generators/optimize_acqf_generator.py b/aepsych/generators/optimize_acqf_generator.py index 2b01d9b57..6b07dba53 100644 --- a/aepsych/generators/optimize_acqf_generator.py +++ b/aepsych/generators/optimize_acqf_generator.py @@ -80,7 +80,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape `[num_points x dim]`. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim] + or shape [num_points x dim x 2] if pairing is applied. """ if self.stimuli_per_trial == 2: diff --git a/aepsych/generators/random_generator.py b/aepsych/generators/random_generator.py index 41acc8546..c64284f0e 100644 --- a/aepsych/generators/random_generator.py +++ b/aepsych/generators/random_generator.py @@ -45,7 +45,7 @@ def gen( Args: num_points (int, optional): Number of points to query. Currently, only 1 point can be queried at a time. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. """ X = self.bounds_[0] + torch.rand((num_points, self.bounds_.shape[1])) * ( self.bounds_[1] - self.bounds_[0] diff --git a/aepsych/generators/sobol_generator.py b/aepsych/generators/sobol_generator.py index ce54150f3..a46d34e51 100644 --- a/aepsych/generators/sobol_generator.py +++ b/aepsych/generators/sobol_generator.py @@ -55,7 +55,8 @@ def gen( Args: num_points (int, optional): Number of points to query. Returns: - np.ndarray: Next set of point(s) to evaluate, [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim] + or shape [num_points x dim x stimuli_per_trial] if `stimuli_per_trial` is greater than 1. """ grid = self.engine.draw(num_points) grid = self.lb + (self.ub - self.lb) * grid From e8a6bafa609967a1ef887175e66155fc81d3c934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernanda=20De=20Le=C3=B3n?= Date: Wed, 9 Oct 2024 12:44:30 -0600 Subject: [PATCH 4/4] Fix lint --- aepsych/generators/acqf_thompson_sampler_generator.py | 4 ++-- aepsych/generators/manual_generator.py | 2 +- aepsych/generators/monotonic_rejection_generator.py | 2 +- aepsych/generators/monotonic_thompson_sampler_generator.py | 2 +- aepsych/generators/optimize_acqf_generator.py | 4 ++-- aepsych/generators/random_generator.py | 2 +- aepsych/generators/sobol_generator.py | 4 ++-- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aepsych/generators/acqf_thompson_sampler_generator.py b/aepsych/generators/acqf_thompson_sampler_generator.py index 455ee2433..3e5ea7b68 100644 --- a/aepsych/generators/acqf_thompson_sampler_generator.py +++ b/aepsych/generators/acqf_thompson_sampler_generator.py @@ -76,8 +76,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. - or shape [num_points x dim x 2] if pairing is applied. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim] + or shape [num_points, dim, 2] if pairing is applied. """ if self.stimuli_per_trial == 2: diff --git a/aepsych/generators/manual_generator.py b/aepsych/generators/manual_generator.py index 1f3526501..079d3b938 100644 --- a/aepsych/generators/manual_generator.py +++ b/aepsych/generators/manual_generator.py @@ -57,7 +57,7 @@ def gen( Args: num_points (int): Number of points to query. Returns: - torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim]. """ if num_points > (len(self.points) - self._idx): warnings.warn( diff --git a/aepsych/generators/monotonic_rejection_generator.py b/aepsych/generators/monotonic_rejection_generator.py index d13108adf..d103d1845 100644 --- a/aepsych/generators/monotonic_rejection_generator.py +++ b/aepsych/generators/monotonic_rejection_generator.py @@ -80,7 +80,7 @@ def gen( num_points (int, optional): Number of points to query. model (AEPsychMixin): Fitted model of the data. Returns: - torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim]. """ options = self.model_gen_options or {} diff --git a/aepsych/generators/monotonic_thompson_sampler_generator.py b/aepsych/generators/monotonic_thompson_sampler_generator.py index 89a30c299..62a0bce6e 100644 --- a/aepsych/generators/monotonic_thompson_sampler_generator.py +++ b/aepsych/generators/monotonic_thompson_sampler_generator.py @@ -60,7 +60,7 @@ def gen( num_points (int, optional): Number of points to query. model (AEPsychMixin): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: The next set of point(s) to evaluate, with shape [num_points, dim]. """ # Generate the points at which to sample diff --git a/aepsych/generators/optimize_acqf_generator.py b/aepsych/generators/optimize_acqf_generator.py index 6b07dba53..a787c097c 100644 --- a/aepsych/generators/optimize_acqf_generator.py +++ b/aepsych/generators/optimize_acqf_generator.py @@ -80,8 +80,8 @@ def gen(self, num_points: int, model: ModelProtocol, **gen_options) -> torch.Ten num_points (int, optional): Number of points to query. model (ModelProtocol): Fitted model of the data. Returns: - torch.Tensor: The next set of point(s) to evaluate, with shape [num_points x dim] - or shape [num_points x dim x 2] if pairing is applied. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim] + or shape [num_points, dim, 2] if pairing is applied. """ if self.stimuli_per_trial == 2: diff --git a/aepsych/generators/random_generator.py b/aepsych/generators/random_generator.py index c64284f0e..f4f1cf849 100644 --- a/aepsych/generators/random_generator.py +++ b/aepsych/generators/random_generator.py @@ -45,7 +45,7 @@ def gen( Args: num_points (int, optional): Number of points to query. Currently, only 1 point can be queried at a time. Returns: - torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim]. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim]. """ X = self.bounds_[0] + torch.rand((num_points, self.bounds_.shape[1])) * ( self.bounds_[1] - self.bounds_[0] diff --git a/aepsych/generators/sobol_generator.py b/aepsych/generators/sobol_generator.py index a46d34e51..549b6308f 100644 --- a/aepsych/generators/sobol_generator.py +++ b/aepsych/generators/sobol_generator.py @@ -55,8 +55,8 @@ def gen( Args: num_points (int, optional): Number of points to query. Returns: - torch.Tensor: Next set of point(s) to evaluate, with shape [num_points x dim] - or shape [num_points x dim x stimuli_per_trial] if `stimuli_per_trial` is greater than 1. + torch.Tensor: Next set of point(s) to evaluate, with shape [num_points, dim] + or shape [num_points, dim , stimuli_per_trial] if `stimuli_per_trial` is greater than 1. """ grid = self.engine.draw(num_points) grid = self.lb + (self.ub - self.lb) * grid