Skip to content

Commit df7d6d1

Browse files
committed
Implement sum over axis
1 parent e0742b7 commit df7d6d1

File tree

6 files changed

+226
-55
lines changed

6 files changed

+226
-55
lines changed

scripts/client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ def display(response, verbose=False):
116116
#print(response.content)
117117
dtype = response.headers['x-activestorage-dtype']
118118
shape = json.loads(response.headers['x-activestorage-shape'])
119-
result = np.frombuffer(response.content, dtype=dtype)
120-
result = result.reshape(shape)
119+
counts = json.loads(response.headers['x-activestorage-count'])
120+
counts = np.array(counts).reshape(shape)
121+
result = np.frombuffer(response.content, dtype=dtype).reshape(shape)
121122
if verbose:
123+
sep = "\n" if len(counts.shape) > 1 else " "
122124
print("\nResponse headers:", response.headers)
123-
print("\nResult:", result)
125+
print("\nNon-missing count(s):", counts, sep=sep)
126+
print("\nResult:", result, sep=sep)
124127
else:
125128
print(result)
126129

scripts/upload_sample_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import s3fs
77
import zlib
88

9-
NUM_ITEMS = 10
9+
NUM_ITEMS = 12
1010
OBJECT_PREFIX = "data"
1111
COMPRESSION_ALGS = [None, "gzip", "zlib"]
1212
FILTER_ALGS = [None, "shuffle"]

src/models.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,12 @@ pub struct Response {
263263
/// Shape of the response
264264
pub shape: Vec<usize>,
265265
/// Number of non-missing elements operated on to generate response
266-
pub count: i64,
266+
pub count: Vec<i64>,
267267
}
268268

269269
impl Response {
270270
/// Return a Response object
271-
pub fn new(body: Bytes, dtype: DType, shape: Vec<usize>, count: i64) -> Response {
271+
pub fn new(body: Bytes, dtype: DType, shape: Vec<usize>, count: Vec<i64>) -> Response {
272272
Response {
273273
body,
274274
dtype,

src/operation.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ mod tests {
111111
data.into(),
112112
request_data.dtype,
113113
vec![3],
114-
3,
114+
vec![3],
115115
))
116116
}
117117
}
@@ -125,7 +125,7 @@ mod tests {
125125
assert_eq!(&[1, 2, 3, 4][..], response.body);
126126
assert_eq!(models::DType::Uint32, response.dtype);
127127
assert_eq!(vec![3], response.shape);
128-
assert_eq!(3, response.count);
128+
assert_eq!(vec![3], response.count);
129129
}
130130

131131
struct TestNumOp {}
@@ -141,7 +141,7 @@ mod tests {
141141
body.into(),
142142
request_data.dtype,
143143
vec![1, 2],
144-
2,
144+
vec![2],
145145
))
146146
}
147147
}
@@ -155,6 +155,6 @@ mod tests {
155155
assert_eq!("i64", response.body);
156156
assert_eq!(models::DType::Int64, response.dtype);
157157
assert_eq!(vec![1, 2], response.shape);
158-
assert_eq!(2, response.count);
158+
assert_eq!(vec![2], response.count);
159159
}
160160
}

0 commit comments

Comments
 (0)