From a933fbd383cb7d6151c8a9ddf35ef1d5194efe53 Mon Sep 17 00:00:00 2001 From: cynddl Date: Wed, 1 Jul 2015 16:40:06 -0400 Subject: [PATCH] Use binning to computer number_of_antennas --- bandicoot/spatial.py | 6 +++--- bandicoot/tests/samples/manual/A.json | 2 +- bandicoot/tests/samples/manual/B.json | 2 +- bandicoot/tests/samples/regressions/ego.json | 6 +++--- bandicoot/tests/samples/regressions/manual_a.json | 8 ++++---- .../samples/regressions/manual_a_orange_network.json | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bandicoot/spatial.py b/bandicoot/spatial.py index 2d10d01..a64c744 100755 --- a/bandicoot/spatial.py +++ b/bandicoot/spatial.py @@ -88,12 +88,12 @@ def entropy_of_antennas(positions, normalize=False): return raw_entropy -@spatial_grouping(use_records=True) -def number_of_antennas(records): +@spatial_grouping +def number_of_antennas(positions): """ The number of unique places visited. """ - return len(set(r.position for r in records)) + return len(set(positions)) @spatial_grouping diff --git a/bandicoot/tests/samples/manual/A.json b/bandicoot/tests/samples/manual/A.json index 77940c1..f67edaa 100644 --- a/bandicoot/tests/samples/manual/A.json +++ b/bandicoot/tests/samples/manual/A.json @@ -15,7 +15,7 @@ "text": {"mean": 120, "std": 103.92304}}}}, "number_of_contacts": {"allweek": {"allday": {"call": 2, "text": 1}}}, "number_of_interactions": {"allweek": {"allday": {"call": 2, "text": 5}}}, - "number_of_antennas": {"allweek": {"allday": 3 }}, + "number_of_antennas": {"allweek": {"allday": 2}}, "percent_at_home": {"allweek": {"allday": 0.666666 }}, "percent_initiated_conversations": {"allweek": {"allday": {"callandtext": 0}}}, "percent_initiated_interactions": {"allweek": {"allday": {"call": 0.5}}}, diff --git a/bandicoot/tests/samples/manual/B.json b/bandicoot/tests/samples/manual/B.json index 14a5be4..a7c4f51 100644 --- a/bandicoot/tests/samples/manual/B.json +++ b/bandicoot/tests/samples/manual/B.json @@ -41,7 +41,7 @@ "call": 1.0 }}}, "entropy_of_antennas": {"allweek": {"allday": 0.562 }}, - "number_of_antennas": {"allweek": {"allday": 3.0 }}, + "number_of_antennas": {"allweek": {"allday": 2.0 }}, "percent_at_home": {"allweek": {"allday": 0.75 }}, "number_of_interactions": {"allweek": {"allday": { "text": 5.0, diff --git a/bandicoot/tests/samples/regressions/ego.json b/bandicoot/tests/samples/regressions/ego.json index bde7f0d..079508e 100644 --- a/bandicoot/tests/samples/regressions/ego.json +++ b/bandicoot/tests/samples/regressions/ego.json @@ -1388,7 +1388,7 @@ "number_of_antennas__weekend__day__std": 0.5, "number_of_antennas__weekend__day__mean": 1.5, "number_of_antennas__weekend__night__std": 0.0, - "number_of_antennas__weekend__night__mean": 2.0, + "number_of_antennas__weekend__night__mean": 1.0, "number_of_antennas__weekday__allday__std": 0.4714045207910317, "number_of_antennas__weekday__allday__mean": 1.3333333333333333, "number_of_antennas__weekday__day__std": 0.0, @@ -1399,8 +1399,8 @@ "number_of_antennas__allweek__allday__mean": 1.5, "number_of_antennas__allweek__day__std": 0.9428090415820634, "number_of_antennas__allweek__day__mean": 1.6666666666666667, - "number_of_antennas__allweek__night__std": 0.5, - "number_of_antennas__allweek__night__mean": 1.5, + "number_of_antennas__allweek__night__std": 0.0, + "number_of_antennas__allweek__night__mean": 1.0, "entropy_of_antennas__weekend__allday__std": 0.3182570841474064, "entropy_of_antennas__weekend__allday__mean": 0.3182570841474064, "entropy_of_antennas__weekend__day__std": 0.34657359027997264, diff --git a/bandicoot/tests/samples/regressions/manual_a.json b/bandicoot/tests/samples/regressions/manual_a.json index cb74e68..a6e6477 100644 --- a/bandicoot/tests/samples/regressions/manual_a.json +++ b/bandicoot/tests/samples/regressions/manual_a.json @@ -1390,17 +1390,17 @@ "number_of_antennas__weekend__night__std": null, "number_of_antennas__weekend__night__mean": null, "number_of_antennas__weekday__allday__std": 0.0, - "number_of_antennas__weekday__allday__mean": 3.0, + "number_of_antennas__weekday__allday__mean": 2.0, "number_of_antennas__weekday__day__std": null, "number_of_antennas__weekday__day__mean": null, "number_of_antennas__weekday__night__std": 0.0, - "number_of_antennas__weekday__night__mean": 3.0, + "number_of_antennas__weekday__night__mean": 2.0, "number_of_antennas__allweek__allday__std": 0.0, - "number_of_antennas__allweek__allday__mean": 3.0, + "number_of_antennas__allweek__allday__mean": 2.0, "number_of_antennas__allweek__day__std": null, "number_of_antennas__allweek__day__mean": null, "number_of_antennas__allweek__night__std": 0.0, - "number_of_antennas__allweek__night__mean": 3.0, + "number_of_antennas__allweek__night__mean": 2.0, "entropy_of_antennas__weekend__allday__std": null, "entropy_of_antennas__weekend__allday__mean": null, "entropy_of_antennas__weekend__day__std": null, diff --git a/bandicoot/tests/samples/regressions/manual_a_orange_network.json b/bandicoot/tests/samples/regressions/manual_a_orange_network.json index 9986fa3..15ebf24 100644 --- a/bandicoot/tests/samples/regressions/manual_a_orange_network.json +++ b/bandicoot/tests/samples/regressions/manual_a_orange_network.json @@ -1390,17 +1390,17 @@ "number_of_antennas__weekend__night__std": null, "number_of_antennas__weekend__night__mean": null, "number_of_antennas__weekday__allday__std": 0.0, - "number_of_antennas__weekday__allday__mean": 3.0, + "number_of_antennas__weekday__allday__mean": 2.0, "number_of_antennas__weekday__day__std": null, "number_of_antennas__weekday__day__mean": null, "number_of_antennas__weekday__night__std": 0.0, - "number_of_antennas__weekday__night__mean": 3.0, + "number_of_antennas__weekday__night__mean": 2.0, "number_of_antennas__allweek__allday__std": 0.0, - "number_of_antennas__allweek__allday__mean": 3.0, + "number_of_antennas__allweek__allday__mean": 2.0, "number_of_antennas__allweek__day__std": null, "number_of_antennas__allweek__day__mean": null, "number_of_antennas__allweek__night__std": 0.0, - "number_of_antennas__allweek__night__mean": 3.0, + "number_of_antennas__allweek__night__mean": 2.0, "entropy_of_antennas__weekend__allday__std": null, "entropy_of_antennas__weekend__allday__mean": null, "entropy_of_antennas__weekend__day__std": null,