Skip to content

Commit

Permalink
add missing copyright headers; fix matlab client copyright (#316)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #316

X-link: facebookexternal/aepsych_prerelease#36

Reviewed By: tymmsc

Differential Revision: D48871034

fbshipit-source-id: 0d8dfb3470a02664bb7a0971cf8cace0be419281
  • Loading branch information
crasanders authored and facebook-github-bot committed Aug 31, 2023
1 parent 2c2d01b commit f123018
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 34 deletions.
13 changes: 10 additions & 3 deletions aepsych/models/multitask_regression.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.

# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

from __future__ import annotations

from typing import Optional
Expand Down Expand Up @@ -61,7 +68,7 @@ def __init__(
likelihood=likelihood,
*args,
**kwargs,
) # type: ignore # mypy issue 4335
) # type: ignore # mypy issue 4335

self.mean_module = gpytorch.means.MultitaskMean(
self.mean_module, num_tasks=num_outputs
Expand Down Expand Up @@ -106,7 +113,7 @@ def __init__(
likelihood: Optional[gpytorch.likelihoods.Likelihood] = None,
*args,
**kwargs,
):
):
"""Initialize independent multitask GPR model.
Args:
Expand Down Expand Up @@ -140,7 +147,7 @@ def __init__(
likelihood=likelihood,
*args,
**kwargs,
) # type: ignore # mypy issue 4335
) # type: ignore # mypy issue 4335

def forward(self, x):
base_mvn = super().forward(x) # do transforms
Expand Down
9 changes: 8 additions & 1 deletion aepsych/models/ordinal_gp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.

# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

import gpytorch
import torch
from aepsych.likelihoods import OrdinalLikelihood
Expand Down Expand Up @@ -62,4 +69,4 @@ def calculate_probs(self, fmean, fvar):
probs[..., -1] = 1 - self.likelihood.link(
(self.likelihood.cutpoints[-1] - fmean) / fsd
)
return probs
return probs
7 changes: 7 additions & 0 deletions aepsych/server/message_handlers/handle_setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.

# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.

import logging

import aepsych.utils_logging as utils_logging
Expand Down
35 changes: 17 additions & 18 deletions clients/matlab/AEPsychClient.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
% Copyright (c) Meta Platforms. and its affiliates.
% All rights reserved.

% This source code is licensed under the license found in the
% LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -50,7 +49,7 @@ function configure(self, config)
config_long_string = sprintf('%s', config{:});
self.setup(config_long_string);
end

function configure_by_file(self, filename, metadata_dict)
% Read a file into a string to send to the server
if nargin < 3
Expand All @@ -60,14 +59,14 @@ function configure_by_file(self, filename, metadata_dict)
config_string='';
tline = fgetl(fid);
while ischar(tline)
config_string = strcat(config_string, tline,'\n');
config_string = strcat(config_string, tline,'\n');
tline = fgetl(fid);
end
fclose(fid);
config_string = strrep(config_string, '"', '\"');
self.setup(config_string, metadata_dict);
end

function setup(self, config_string, metadata_dict)
% Send the server a configuration string detailing the
% experiment to be run
Expand All @@ -78,16 +77,16 @@ function setup(self, config_string, metadata_dict)
response = self.send_recv(config_msg);
self.strat_indices(end+1) = str2num(response);
end

function [fmax,loc] = get_max(self)
% Get the model maximum point and its location
% Get the model maximum point and its location
msg = sprintf('{"type":"query", "message":{"query_type":"max"}}');
response = jsondecode(self.send_recv(msg));
loc = response.x;
fmax = response.y;
fmax = response.y;
end


function [prob,loc] = find_val(self, val, prob_space)
% Find a point in the model closest to the given val val.
% If prob_space is true, input a probability and this function
Expand All @@ -96,10 +95,10 @@ function setup(self, config_string, metadata_dict)
response = self.send_recv(jsonencode(msg));
response = jsondecode(response)
loc = response.x;
prob = response.y;
prob = response.y;
end


function [fval, loc] = predict(self, config, prob_space)
% Model predict at the location given in the {param : value} dict
% defined in the in config
Expand All @@ -109,13 +108,13 @@ function setup(self, config_string, metadata_dict)
loc = response.x;
fval = response.y;
end

function can_model = get_can_model(self)
msg = '{"type":"can_model","message":""}';
msg = '{"type":"can_model","message":""}';
full_response = jsondecode(self.send_recv(msg));
can_model = full_response.can_model;
end

function response=ask(self)
% Request from the server the next trial configuration to be
% run
Expand All @@ -130,15 +129,15 @@ function setup(self, config_string, metadata_dict)
response.(fn{k}) = num2cell(full_response.config.(fn{k}));
end
end

function tell(self, config, outcome)
% Report back to the server a trial configuration that was run
% and an outcome (0 or 1). Note that this need not be the same
% as a configuration previously received from the server.
tell_msg = struct("type", "tell", "message", struct("config",config, "outcome", outcome));
self.send_recv(jsonencode(tell_msg));
end

function resume(self, strat_id)
% Resume a past strategy used in the current session,
% corresponding to a different model and data. Each strategy is
Expand All @@ -150,7 +149,7 @@ function resume(self, strat_id)
fprintf("Requested strat %d, got strat %d\n", strat_id, response);
end
end

% private methods
methods (Access='private')
function response=send_recv(self, msg)
Expand Down
17 changes: 13 additions & 4 deletions website/pages/demos/ParticleEffectDemo.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the scripts directory.
*
* @format
*/

const CWD = process.cwd();

const React = require('react');
const Demo = require(`${CWD}/core/Demo.js`);

class DemoPage extends React.Component {
render() {
const {config: siteConfig} = this.props;
const {baseUrl} = siteConfig;
return <Demo baseUrl={baseUrl} demoID="ParticleEffectDemo" hasWinDemo="False"
hasMacDemo="False"/>;
const { config: siteConfig } = this.props;
const { baseUrl } = siteConfig;
return <Demo baseUrl={baseUrl} demoID="ParticleEffectDemo" hasWinDemo="False"
hasMacDemo="False" />;
}
}

Expand Down
17 changes: 13 additions & 4 deletions website/pages/demos/ThrowOptimizerDemo.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the scripts directory.
*
* @format
*/

const CWD = process.cwd();

const React = require('react');
const Demo = require(`${CWD}/core/Demo.js`);

class DemoPage extends React.Component {
render() {
const {config: siteConfig} = this.props;
const {baseUrl} = siteConfig;
return <Demo baseUrl={baseUrl} demoID="ThrowOptimizerDemo" hasWinDemo="False"
hasMacDemo="False"/>;
const { config: siteConfig } = this.props;
const { baseUrl } = siteConfig;
return <Demo baseUrl={baseUrl} demoID="ThrowOptimizerDemo" hasWinDemo="False"
hasMacDemo="False" />;
}
}

Expand Down
17 changes: 13 additions & 4 deletions website/pages/demos/YannyLaurelDemo.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the scripts directory.
*
* @format
*/

const CWD = process.cwd();

const React = require('react');
const Demo = require(`${CWD}/core/Demo.js`);

class DemoPage extends React.Component {
render() {
const {config: siteConfig} = this.props;
const {baseUrl} = siteConfig;
return <Demo baseUrl={baseUrl} demoID="YannyLaurelDemo" hasWinDemo="False"
hasMacDemo="False"/>;
const { config: siteConfig } = this.props;
const { baseUrl } = siteConfig;
return <Demo baseUrl={baseUrl} demoID="YannyLaurelDemo" hasWinDemo="False"
hasMacDemo="False" />;
}
}

Expand Down

0 comments on commit f123018

Please sign in to comment.