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

Allow bin format for non-numeric content #89

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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):
axelboc marked this conversation as resolved.
Show resolved Hide resolved
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
Loading