Skip to content

Commit

Permalink
Merge pull request #89 from silx-kit/bin
Browse files Browse the repository at this point in the history
Allow `bin` format for non-numeric content
  • Loading branch information
axelboc authored Mar 11, 2024
2 parents 4be8eb6 + d29177d commit cadc6c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ Once `h5grove` is installed in editable mode, run the tests with
invoke test
```

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/).
Expand Down
9 changes: 5 additions & 4 deletions h5grove/encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit cadc6c0

Please sign in to comment.