From 508cbddbf782a4df657b91d2d35a3bfe1dd29ec9 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 7 Mar 2024 16:22:09 +0100 Subject: [PATCH 1/2] Document options of `invoke test` command --- CONTRIBUTING.md | 8 +++++++- tasks.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f126e6..3f173d4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,9 +31,15 @@ Tests are handled with [pytest](https://docs.pytest.org/en/stable/index.html). T Once `h5grove` is installed in editable mode, run the tests with ``` -invoke test +invoke test [--options] ``` +Available options (cf. `invoke --help test`): + +- `-c`, `--cov-lines`: display line numbers in coverage report +- `-k [keyword]`, `--keyword [keyword]`: filter tests by keyword +- `-v`, `--verbose`: enable verbose test output + ### Benchmarks Benchmarks of different formats (`json`, `.npy`) and web server frameworks (`flask`, `tornado`) are run as part of the tests. Those benchmarks are based on [pytest-benchmark](https://pytest-benchmark.readthedocs.io/en/latest/). diff --git a/tasks.py b/tasks.py index 8e851e7..e84ac07 100644 --- a/tasks.py +++ b/tasks.py @@ -31,7 +31,7 @@ def lint(c): mypy(c) -@task +@task(optional=["verbose", "keyword", "cov-lines"]) def test(c, verbose=False, keyword="", cov_lines=False): """Test without benchmark""" c.run( From d29177d4622842aae4e62e3ddcaf5750e685161f Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 7 Mar 2024 16:23:02 +0100 Subject: [PATCH 2/2] Allow `bin` enconding for non-numeric content --- CONTRIBUTING.md | 2 +- h5grove/encoders.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f173d4..6a52db4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,7 +31,7 @@ Tests are handled with [pytest](https://docs.pytest.org/en/stable/index.html). T Once `h5grove` is installed in editable mode, run the tests with ``` -invoke test [--options] +invoke test ``` Available options (cf. `invoke --help test`): diff --git a/h5grove/encoders.py b/h5grove/encoders.py index f054e99..4d20fe1 100644 --- a/h5grove/encoders.py +++ b/h5grove/encoders.py @@ -111,10 +111,6 @@ def encode(content: Any, encoding: Optional[str] = "json") -> Response: ) content_array = np.array(content, copy=False) - if not is_numeric_data(content_array): - raise QueryArgumentError( - f"Unsupported encoding {encoding} for non-numeric content" - ) if encoding == "bin": return Response( @@ -124,6 +120,11 @@ def encode(content: Any, encoding: Optional[str] = "json") -> Response: }, ) + if not is_numeric_data(content_array): + raise QueryArgumentError( + f"Unsupported encoding {encoding} for non-numeric content" + ) + if encoding == "csv": return Response( csv_encode(content_array),