feat: refactor dtypes as objects, add constants#11
Open
nicola-bastianello wants to merge 16 commits into
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
this PR refactors dtypes as objects; in particular:
dtypeinstantiated asdtype("float32"), with propertiesname,availableandbackend_dtype.backend_dtypeis bound to the corresponding backend dtype object atset_backend, and any dtype created afterwards is also boundBackendnow exposes one property for each of the supported dtypes; the property is abstract if the dtype is supported by all frameworks, non-abstract and returning None otherwise. subclasses ofBackendreturn a native dtype object if available, None otherwisedtypeobjectsfrom decent_array import float32dtypeobject is documented but the dtype instances are not in the API referenceother changes:
e,pi,inf,nanas aliases of the framework-native constants (afterset_backendis called, before they alias the correspondingmathconstants). to get the constants:from decent_array import eBackendthat need to return the framework-native constantsSupportedFrameworks,SupportedDevices,SupportedArrayTypesby removing "supported". I personally find them easier to read this way since the names start differently, but I'm open to discuss_utils.pyto storeunwrap, which was redefined in several placesthe dtype refactor has the following benefits:
Backend, ensuring that we handle them in the same way as all other framework-native itemsdtype("float32")closes #8