-
Notifications
You must be signed in to change notification settings - Fork 5
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
assertions not supported for parameter cdf in constriction.stream.model.CustomModel #27
Comments
Thanks for reporting! Please note that there's a bug in the following line: dummy_entropy_model = constriction.stream.model.CustomModel(cdf ,inverse_cdf, -10, 10) The argument Changing the argument from Side NodeAssertions generally can't be used to tell an interpreter or compiler not to do something. They are a tool for (i) documenting invariants for human readers of the source code and for (ii) bailing in case a program or library contains a logic error or is used incorrectly. This is nothing specific about def divide(a, b):
assert b != 0
return a / b
print([divide(1, x) for x in range(-10, 11)]) Preventing callers from calling a function unless certain conditions are met cannot be achieved with assertions inside the function body. It would instead require either a more expressive type system that makes invalid function arguments inexpressible, or a more elaborate mechanism such as design by contract. |
Ensures that `LeakilyQuantizedDistribution` probes the cdf only on mid-points between integers *strictly between* `min_symbol_inclusive` and `max_symbol_inclusive`. This fixes part of #27. It remains to improve error messages.
I tried to implement a custom entropy model that is only defined on positive numbers.
To make sure only positive numbers are encoded I used an assert statement to check for non-negativity.
To make my point I use a lognormal distribution in the following snippet.
thread '<unnamed>' panicked at 'TODO: PyErr { type: <class 'AssertionError'>, value: AssertionError(), traceback: Some(<traceback object at 0x7f22f0efac80>) }', src/pybindings/stream/model/internals.rs:380:14
PanicException: TODO: PyErr { type: , value: AssertionError(), traceback: Some() }
This problem is of course solved by deleting assertions from cdf.
A more permanent solution might be a change to the documentation or the error message.
The text was updated successfully, but these errors were encountered: