Add new Alien
field type to denote "incompatible" fields that should crash
PyTree flatten / unflatten operations:
- New features:
- Added the
ojax.Alien
Field class. - Added
ojax.alien
for alien field type declaration. - Added
ojax.AlienException
which will be raised when flattening / unflattening PyTrees with alien fields.
- Added the
- Other changes:
- fixed wrong
NoAnnotationWarning
warnings when aproperty
is defined inojax.OTree
. - Updated the documentation to include the new alien field type.
- Added test coverage analysis and improved unit tests
- fixed wrong
Rework ojax.OTree
field type representation.
Using custom subclass of
dataclasses.Field
instead of setting custom metadata. This simplifies field
type checking and allows for further subclassing. Specifically:
- Classes
Aux
,Child
,Ignore
are added which indicates the type ofOTree
field. They all inherit from the abstract base classOTreeField
which is itself a subclass ofdataclasses.Field
. - The function
ojax.get_field_type
and the enum classojax.FieldType
is removed since they are now unnecessary.
Note that users should still use functions aux()
, child()
, ignore()
to
declare field types since directly using classes could generate confusion for
type checking. This is also in line with the standard dataclasses
usage.
Fixes unnecessary missing annotation warning for non-user-defined attributes.
Change doc theme. Improve documentation.
- Other changes
- Now uses the sphinx_book_theme for Sphinx documentation.
- Finetune documentation.
Rework API. Add unit tests.
- Breaking changes
- Renamed
ojax.OTree.infer_field_type()
toojax.OTree.__infer_otree_field_type__()
.
- Renamed
- New features
- Added the
ojax.fields()
function to get the fields from an OTree. It can also return fields of a certain field type.
- Added the
- Other changes
- Renamed
test/
folder totests/
. - Added unit tests.
- Added CHANGELOG.md (this file).
- Renamed
First version.