-
Notifications
You must be signed in to change notification settings - Fork 60
WIP: generator accepts NdArray attribute #575
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #575 +/- ##
==========================================
+ Coverage 79.86% 80.09% +0.22%
==========================================
Files 229 231 +2
Lines 16239 16452 +213
==========================================
+ Hits 12970 13177 +207
- Misses 3269 3275 +6
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks very good, only a few small comments.
@@ -382,6 +383,45 @@ def to_field_value(self): | |||
return self.name | |||
|
|||
|
|||
class NdArrayProperty(Property): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need some docstring for the class. I understand that many other classes in this file don't have that, but that's a historical mistake, let's add docstring as much as possible for future code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree
@@ -95,6 +95,14 @@ | |||
"value_type": { | |||
"description": "Item type for the case of Dice attributes", | |||
"type": "string" | |||
}, | |||
"ndarray_dtype": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have some tests to validate a JSON spec with this schema, hopefully, both success and failure cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test against invalid shape.
Do you think we can rely on numpy to validate dtype?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it'd be great if schema can check the possible dtype values. Since this is done without actually running the code, while numpy validation happens late at run time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good.
I've added more tests against dtype and shape
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the validation looks awesome, and thanks for the tests
tests/forte/data/ontology/test_specs/test_invalid_ndarray_shape.json
Outdated
Show resolved
Hide resolved
* added static methods to infer pack type * added unit tests for datapack type inference. * fixed issue#558 * fixed black: forte/data/selector.py * fixed import-outside-toplevel * WIP: waiting for ndarray supported * Ndarray -> ndarray * values -> value * added ndarray to SUPPORTED_PRIMITIVES * WIP: generator accepts NdArray attribute * remove breakpoints * fixed None -> "None" * WIP: designing NdArrayProperty * WIP: ndarray_size -> ndarray_shape * fixed lint * fixed lint * added ndarray property test cases * removed irrelevant onto spec * fixed lint * fixed lint * fixed black * fixed description * added FNdArray, a wrapper class for NdArray metric * handle None dtype * removed Optional typing * fixed description * added unit tests for ndarray attribute * fixed black * added doc string and more tests * fixed type * added reference to np.ndarray * added unit tests for ndarray attribute against dtype, shape, and warning Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com>
* added static methods to infer pack type * added unit tests for datapack type inference. * fixed issue#558 * fixed black: forte/data/selector.py * fixed import-outside-toplevel * WIP: waiting for ndarray supported * Ndarray -> ndarray * values -> value * added ndarray to SUPPORTED_PRIMITIVES * WIP: generator accepts NdArray attribute * remove breakpoints * fixed None -> "None" * WIP: designing NdArrayProperty * WIP: ndarray_size -> ndarray_shape * fixed lint * fixed lint * added ndarray property test cases * removed irrelevant onto spec * fixed lint * fixed lint * fixed black * fixed description * added FNdArray, a wrapper class for NdArray metric * handle None dtype * removed Optional typing * fixed description * added unit tests for ndarray attribute * fixed black * added doc string and more tests * fixed type * added reference to np.ndarray * added unit tests for ndarray attribute against dtype, shape, and warning Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com>
* added static methods to infer pack type * added unit tests for datapack type inference. * fixed issue#558 * fixed black: forte/data/selector.py * fixed import-outside-toplevel * WIP: waiting for ndarray supported * Ndarray -> ndarray * values -> value * added ndarray to SUPPORTED_PRIMITIVES * WIP: generator accepts NdArray attribute * remove breakpoints * fixed None -> "None" * WIP: designing NdArrayProperty * WIP: ndarray_size -> ndarray_shape * fixed lint * fixed lint * added ndarray property test cases * removed irrelevant onto spec * fixed lint * fixed lint * fixed black * fixed description * added FNdArray, a wrapper class for NdArray metric * handle None dtype * removed Optional typing * fixed description * added unit tests for ndarray attribute * fixed black * added doc string and more tests * fixed type * added reference to np.ndarray * added unit tests for ndarray attribute against dtype, shape, and warning Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com>
* added static methods to infer pack type * added unit tests for datapack type inference. * fixed issue#558 * fixed black: forte/data/selector.py * fixed import-outside-toplevel * WIP: waiting for ndarray supported * Ndarray -> ndarray * values -> value * added ndarray to SUPPORTED_PRIMITIVES * WIP: generator accepts NdArray attribute * remove breakpoints * fixed None -> "None" * WIP: designing NdArrayProperty * WIP: ndarray_size -> ndarray_shape * fixed lint * fixed lint * added ndarray property test cases * removed irrelevant onto spec * fixed lint * fixed lint * fixed black * fixed description * added FNdArray, a wrapper class for NdArray metric * handle None dtype * removed Optional typing * fixed description * added unit tests for ndarray attribute * fixed black * added doc string and more tests * fixed type * added reference to np.ndarray * added unit tests for ndarray attribute against dtype, shape, and warning Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com>
* Add AudioAnnotation entry to ontology system * WIP: generator accepts NdArray attribute (#575) * added static methods to infer pack type * added unit tests for datapack type inference. * fixed issue#558 * fixed black: forte/data/selector.py * fixed import-outside-toplevel * WIP: waiting for ndarray supported * Ndarray -> ndarray * values -> value * added ndarray to SUPPORTED_PRIMITIVES * WIP: generator accepts NdArray attribute * remove breakpoints * fixed None -> "None" * WIP: designing NdArrayProperty * WIP: ndarray_size -> ndarray_shape * fixed lint * fixed lint * added ndarray property test cases * removed irrelevant onto spec * fixed lint * fixed lint * fixed black * fixed description * added FNdArray, a wrapper class for NdArray metric * handle None dtype * removed Optional typing * fixed description * added unit tests for ndarray attribute * fixed black * added doc string and more tests * fixed type * added reference to np.ndarray * added unit tests for ndarray attribute against dtype, shape, and warning Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com> * Resolve comments * Fix confusing types of range_annotation * Add test case for AudioAnnotation Co-authored-by: Suqi Sun <suqi.sun@petuum.com> Co-authored-by: Zhanyuan Zhang <32000378+zhanyuanucb@users.noreply.github.com> Co-authored-by: Zhanyuan Zhang <zhanyuan.zhang@petuum.com>
This PR fixes #567.
Description of changes
In ontology_code_const.py:
Add “NdArray” to COMPOSITE
Add “shape” and “dtype” to SchemaKeyWords
In ontology_code_generator.py:
In code_generation_objects.py
In forte.data.ontology.core.py
validation_schema.json
Possible influences of this PR.
Describe what are the possible side-effects of the code change.
Test Conducted
tests/forte/data/ontology/ontology_code_generator_test.py
tests/forte/data/ontology/ndarray_attribute_test.py
:array
property