-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix missing autograd box schema and move schema creation code to comp…
…onents/type_util.py
- Loading branch information
1 parent
ba11a51
commit 474417d
Showing
3 changed files
with
18 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"""Utilities for type & schema creation.""" | ||
|
||
|
||
def _add_schema(arbitrary_type: type, title: str, field_type_str: str) -> None: | ||
"""Adds a schema to the ``arbitrary_type`` class without subclassing.""" | ||
|
||
@classmethod | ||
def mod_schema_fn(cls, field_schema: dict) -> None: | ||
"""Function that gets set to ``arbitrary_type.__modify_schema__``.""" | ||
field_schema.update(dict(title=title, type=field_type_str)) | ||
|
||
arbitrary_type.__modify_schema__ = mod_schema_fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters