Skip to content

Commit

Permalink
Merge pull request #254 from suchow/v0.6.0
Browse files Browse the repository at this point in the history
Release version v0.6.0
  • Loading branch information
suchow committed Nov 20, 2015
2 parents 6967c9f + 2f98f5c commit 6d51343
Show file tree
Hide file tree
Showing 9 changed files with 1,075 additions and 1,254 deletions.
14 changes: 5 additions & 9 deletions examples/bartlett1932/static/js/task.js
Expand Up @@ -65,9 +65,8 @@ var Bartlett1932Experiment = function() {
ensureSameWorker();

reqwest({
url: "/node",
url: "/node/" + uniqueId,
method: 'post',
data: { participant_id: uniqueId },
type: 'json',
success: function (resp) {
my_node_id = resp.node.id;
Expand All @@ -87,9 +86,9 @@ var Bartlett1932Experiment = function() {

getPendingTransmissions = function(my_node_id) {
reqwest({
url: "/transmission",
url: "/node/" + my_node_id + "/transmissions",
method: 'get',
data: { participant_id: uniqueId, node_id: my_node_id, status: "pending", direction: "incoming" },
data: { status: "pending", direction: "incoming" },
type: 'json',
success: function (resp) {
info_id = resp.transmissions[0].info_id;
Expand All @@ -105,9 +104,8 @@ var Bartlett1932Experiment = function() {

getInfo = function(info_id) {
reqwest({
url: "/info",
url: "/info/" + my_node_id + "/" + info_id,
method: 'get',
data: { participant_id: uniqueId, node_id: my_node_id, info_id: info_id },
type: 'json',
success: function (resp) {
story = resp.info.contents;
Expand Down Expand Up @@ -144,11 +142,9 @@ var Bartlett1932Experiment = function() {
$("#reproduction").val("");

reqwest({
url: "/info",
url: "/info/" + my_node_id,
method: 'post',
data: {
participant_id: uniqueId,
node_id: my_node_id,
contents: response,
info_type: "Info"
},
Expand Down
15 changes: 6 additions & 9 deletions examples/function-learning/static/js/task.js
Expand Up @@ -52,9 +52,8 @@ var FunctionLearningExperiment = function() {
ensureSameWorker();

reqwest({
url: "/node",
url: "/node/" + uniqueId,
method: 'post',
data: { participant_id: uniqueId },
type: 'json',
success: function (resp) {
my_node_id = resp.node.id;
Expand All @@ -74,9 +73,9 @@ var FunctionLearningExperiment = function() {

getPendingTransmissions = function(my_node_id) {
reqwest({
url: "/transmission",
url: "/transmission/" + uniqueId + "/" + my_node_id,
method: 'get',
data: { participant_id: uniqueId, node_id: my_node_id, status: "pending", direction: "incoming" },
data: { status: "pending", direction: "incoming" },
type: 'json',
success: function (resp) {
info_id = resp.transmissions[0].info_id;
Expand All @@ -92,9 +91,9 @@ var FunctionLearningExperiment = function() {

getInfo = function(info_id) {
reqwest({
url: "/info",
url: "/info/" + uniqueId + "/" + my_node_id,
method: 'get',
data: { participant_id: uniqueId, node_id: my_node_id, info_id: info_id },
data: { info_id: info_id },
type: 'json',
success: function (resp) {

Expand Down Expand Up @@ -205,11 +204,9 @@ var FunctionLearningExperiment = function() {
response = encodeURIComponent(JSON.stringify({"x": xTest, "y": yTest}));

reqwest({
url: "/info",
url: "/info/" + uniqueId + "/" + my_node_id,
method: 'post',
data: {
participant_id: uniqueId,
node_id: my_node_id,
contents: response,
info_type: "Info"
}
Expand Down
46 changes: 15 additions & 31 deletions tests/test_models.py
Expand Up @@ -138,50 +138,34 @@ def test_models(self):
# test Network.infos()

from wallace.information import Gene
assert len(net.infos(origin_failed="all")) == 10
assert len(net.infos(type=models.Info, origin_failed="all")) == 10
assert len(net.infos(type=Gene, origin_failed="all")) == 5
assert len(net.infos(failed="all")) == 10
assert len(net.infos(type=models.Info, failed="all")) == 10
assert len(net.infos(type=Gene, failed="all")) == 5

assert len(net.infos()) in [5, 6, 7, 8, 9, 10]
assert len(net.infos(origin_failed=False)) in [5, 6, 7, 8, 9, 10]
assert len(net.infos(failed=False)) in [5, 6, 7, 8, 9, 10]
assert len(net.infos(type=Gene)) in [5, 4, 3, 2, 1, 0]
assert len(net.infos(origin_failed=True)) in [0, 1, 2, 3, 4, 5]
assert len(net.infos(failed=True)) in [0, 1, 2, 3, 4, 5]

# test Network.transmissions()

assert len(net.transmissions(vector_failed="all")) == 5
assert len(net.transmissions(status="pending", vector_failed="all")) == 3
assert len(net.transmissions(status="received", vector_failed="all")) == 2
assert len(net.transmissions(vector_failed=True)) in [0, 1, 2, 3, 4, 5]
assert len(net.transmissions(vector_failed=False)) in [0, 1, 2, 3, 4, 5]
assert len(net.transmissions(vector_failed=True)) + len(net.transmissions(vector_failed=False)) == 5
assert len(net.transmissions(failed="all")) == 5
assert len(net.transmissions(status="pending", failed="all")) == 3
assert len(net.transmissions(status="received", failed="all")) == 2
assert len(net.transmissions(failed=True)) in [0, 1, 2, 3, 4, 5]
assert len(net.transmissions(failed=False)) in [0, 1, 2, 3, 4, 5]
assert len(net.transmissions(failed=True)) + len(net.transmissions(failed=False)) == 5

# test Network.transformations()

assert len(net.transformations(node_failed="all")) == 2
assert len(net.transformations(failed="all")) == 2
from wallace import transformations
assert len(net.transformations(node_failed="all", type=transformations.Mutation)) == 0
assert len(net.transformations(node_failed="all", type=models.Transformation)) == 2
assert len(net.transformations(failed="all", type=transformations.Mutation)) == 0
assert len(net.transformations(failed="all", type=models.Transformation)) == 2

for t in net.transformations(node_failed="all"):
for t in net.transformations(failed="all"):
assert type(t.node) == Agent

# test Network.latest_transmission_recipient()

agents = net.nodes(type=Agent, failed="all")
from operator import attrgetter
oldest_agent = min(agents, key=attrgetter('creation_time'))
other_agents = [a for a in agents if a != oldest_agent]
second_oldest_agent = min(other_agents, key=attrgetter('creation_time'))

assert net.latest_transmission_recipient(failed="all") == second_oldest_agent

if second_oldest_agent.failed:
if net.latest_transmission_recipient() is not None:
assert net.latest_transmission_recipient() != second_oldest_agent
else:
assert net.latest_transmission_recipient() == second_oldest_agent

print("Testing models: Network... done!")
sys.stdout.flush()

Expand Down

0 comments on commit 6d51343

Please sign in to comment.