-
Notifications
You must be signed in to change notification settings - Fork 55
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
Improve basic datatypes #1756
Improve basic datatypes #1756
Conversation
/bot run linux |
Hello again! Thank you for this new pull request 🤩. Please begin by requesting your checklist using the command |
/bot run linux |
/bot run linux |
…to devel-issue1729
This reverts commit 3903d8e.
/bot run pr_tests |
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.
Good job ! Your PR is using all the code it added/changed.
@yguclu, @EmilyBourne has been working hard and thinks that they have now replied to or fixed all your comments. Could you take another look at the PR and see if you can approve now? |
@yguclu, @EmilyBourne has been working hard and thinks that they have now replied to or fixed all your comments. Could you take another look at the PR and see if you can approve now? |
/bot run pr_tests |
/bot show tests |
The following is a list of keywords which can be used to run tests. Tests in bold are run by pull requests when they are marked as ready for review:
These tests can be run with the command |
/bot run coverage |
1 similar comment
/bot run coverage |
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.
Good job ! Your PR is using all the code it added/changed.
Add missing cast when creating an array from an object with a different datatype. Fixes #1785 In order to call the cast on the argument passed to `np.array` (which may be a `InhomogeneousTupleType`) fix the type of the cast functions. Modify `InhomogeneousTupleType.datatype` to return a `FixedSizeType` if the datatypes of all elements are equivalent. Also fix some minor bugs after #1756
This PR rewrites the datatyping system. Fixes #1729.
As described in the issue, the existing superclass
Datatype
is replaced with 2 superclasses representing slightly different concepts:PrimitiveType
: Representing the category of datatype (integer/floating point/etc)PyccelType
: Representing the actual type of the object in PythonSubclasses of
PyccelType
generally fall into one of two categories:FixedSizeType
ContainerType
These types are described in
developer_docs/type_inference.md
(it is recommended to read this file first before reviewing this pull request.The
precision
is removed fromast.basic.TypedAstNode
and is stored in theFixedSizeType
s where it is relevant. This allows us to remove the necessity for negative precision values as defaults, as the types can now be easily differentiated using the differentFixedSizeType
s.The attribute
_dtype
is removed fromast.basic.TypedAstNode
instances. It is still accessible via thedtype
property but is extracted from the class type. This ensures that the two do not deviate from one another.The NumPy type deduction is significantly improved due to two major improvements. Firstly an assertion is added to
NumpyNDArrayType
to ensure that the internal datatypes are NumPy types. This uncovered a few bugs where the native Python types were used in our current code. Thus the wrong type would be returned if an element of one of these objects was returned.Secondly
np.result_type
is now used to deduce the result type of NumPy functions. This function is implemented by NumPy which guarantees that it handles all corner cases and matches the expected behaviour of NumPy. Fixes #1763.The
CustomDatatype
is simplified slightly to remove the unused parameters.The printing of floats/complexes in Fortran is improved to stop printing decimal digits beyond the precision of the number. Additionally printing the return value of functions returning multiple results of different types is fixed.
Unfortunately these changes have a huge effect on the code as datatypes appear almost everywhere. I have tried my best to find all the places where the code has changed however it is possible that some places were missed if coverage is missing.