Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get_min_max() to Perspective API #1395

Merged
merged 2 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Better handling of view cancel
  • Loading branch information
texodus committed Apr 26, 2021
commit df129339df1904fcdc21caec2dc9dbcda658ea10
8 changes: 6 additions & 2 deletions python/perspective/perspective/table/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
get_row_delta_zero,
get_row_delta_one,
get_row_delta_two,
scalar_to_py
scalar_to_py,
)


Expand Down Expand Up @@ -148,7 +148,11 @@ def get_min_max(self, colname):
Returns:
:obj:`list` of 2 elements, the `min` and `max` of the
"""
return list(map(lambda x: scalar_to_py(x, False, False), self._view.get_min_max(colname)));
return list(
map(
lambda x: scalar_to_py(x, False, False), self._view.get_min_max(colname)
)
)

def num_rows(self):
"""The number of aggregated rows in the :class:`~perspective.View`.
Expand Down
24 changes: 13 additions & 11 deletions rust/perspective-vieux/src/rust/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ fn ignore_view_delete(f: JsValue) {
match f.clone().dyn_into::<js_sys::Error>() {
Ok(err) => {
if err.message() != "View is not initialized" {
wasm_bindgen::throw_val(f)
web_sys::console::log_1(&JsValue::from("A"));
wasm_bindgen::throw_val(f);
}
}
_ => {
if !js_sys::Reflect::has(&f, js_intern!("message")).unwrap()
|| js_sys::Reflect::get(&f, js_intern!("message"))
.unwrap()
.as_string()
.unwrap_or("".to_owned())
!= "View is not initialized"
{
wasm_bindgen::throw_val(f)
}
_ => match f.as_string() {
Some(x) if x == "View is not initialized" => {},
Some(_) => wasm_bindgen::throw_val(f),
_ => match js_sys::Reflect::has(&f, js_intern!("message")) {
Ok(true) if js_sys::Reflect::get(&f, js_intern!("message"))
.unwrap()
.as_string()
.unwrap_or("".to_owned())
== "View is not initialized" => {}
_ => wasm_bindgen::throw_val(f)
}
}
}
}
Expand Down