-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[MATLAB] Make arrow.type.Type
inherit from matlab.mixin.Heterogeneous
#37591
Comments
take |
kevingurney
pushed a commit
that referenced
this issue
Sep 6, 2023
…Heterogeneous` (#37593) ### Rationale for this change We should modify `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous` so that it's possible to create a nonscalar array containing different concrete subclasses of `arrow.type.Type`. **Example** ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` Currently, running the example above results in an error: ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] Error using horzcat The following error occurred converting from arrow.type.TimestampType to arrow.type.Float32Type: Invalid argument at position 1. Value must be of type libmexclass.proxy.Proxy or be convertible to libmexclass.proxy.Proxy. ``` ### What changes are included in this PR? 1. Updated `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous`. Previously, it only inherited from `matlab.mixin.CustomDisplay`. 2. Because `arrow.type.Type` is now `heterogeneous`, its subclasses cannot override the protected method `getPropertyGroups` - which is inherited from `matlab.mixin.CustomDisplay`. This method must be `Sealed` and defined on `Type` because only `Sealed` methods can be called on nonscalar `heterogeneous` arrays. To get around this limitation, I defined a new abstract template method called `getDisplayPropertyGroups`, which `getPropertyGroups` invokes if the array is either scalar or nonscalar and `homogeneous`. Refer to [this link](https://www.mathworks.com/help/matlab/matlab_oop/custom-display-for-heterogeneous-arrays.html) for more details. **Displaying a nonscalar *heterogeneous* `arrow.type.Type`** ```matlab >> float32Type = arrow.timestamp(TimeUnit="Second"); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` **Displaying a nonscalar *homogeneous* `arrow.type.Type`** ```matlab >> timestampType1 = arrow.timestamp(TimeUnit="Second"); >> timestampType2 = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [timestampType1 timestampType2] typeArray = 1×2 TimestampType array with properties: ID TimeUnit TimeZone ``` ### Are these changes tested? Yes 1. Added a new test class in `test/arrow/type` called `tDisplay.m` 2. Added display unit tests for all concrete subclasses of `arrow.type.Type` if they did not already exist. 3. Added a new test class in `test/arrow/type` called `tIsEqual.m`. This class contains unit tests verifying the `isequal` method of `arrow.type.Type` behaves as expected when called on heterogeneous arrays. ### Are there any user-facing changes? Yes. Users can now create nonscalar arrays with different concrete subclasses of `arrow.type.Type`. ### Future Directions 1. Move all display unit tests to `tDisplay.m` 2. Add an `arrow.type.NumericType` class from which all numeric types inherit. This class will define `getDisplayPropertyGroups` for all numeric types. * Closes: #37591 Authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
loicalleyne
pushed a commit
to loicalleyne/arrow
that referenced
this issue
Nov 13, 2023
…mixin.Heterogeneous` (apache#37593) ### Rationale for this change We should modify `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous` so that it's possible to create a nonscalar array containing different concrete subclasses of `arrow.type.Type`. **Example** ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` Currently, running the example above results in an error: ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] Error using horzcat The following error occurred converting from arrow.type.TimestampType to arrow.type.Float32Type: Invalid argument at position 1. Value must be of type libmexclass.proxy.Proxy or be convertible to libmexclass.proxy.Proxy. ``` ### What changes are included in this PR? 1. Updated `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous`. Previously, it only inherited from `matlab.mixin.CustomDisplay`. 2. Because `arrow.type.Type` is now `heterogeneous`, its subclasses cannot override the protected method `getPropertyGroups` - which is inherited from `matlab.mixin.CustomDisplay`. This method must be `Sealed` and defined on `Type` because only `Sealed` methods can be called on nonscalar `heterogeneous` arrays. To get around this limitation, I defined a new abstract template method called `getDisplayPropertyGroups`, which `getPropertyGroups` invokes if the array is either scalar or nonscalar and `homogeneous`. Refer to [this link](https://www.mathworks.com/help/matlab/matlab_oop/custom-display-for-heterogeneous-arrays.html) for more details. **Displaying a nonscalar *heterogeneous* `arrow.type.Type`** ```matlab >> float32Type = arrow.timestamp(TimeUnit="Second"); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` **Displaying a nonscalar *homogeneous* `arrow.type.Type`** ```matlab >> timestampType1 = arrow.timestamp(TimeUnit="Second"); >> timestampType2 = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [timestampType1 timestampType2] typeArray = 1×2 TimestampType array with properties: ID TimeUnit TimeZone ``` ### Are these changes tested? Yes 1. Added a new test class in `test/arrow/type` called `tDisplay.m` 2. Added display unit tests for all concrete subclasses of `arrow.type.Type` if they did not already exist. 3. Added a new test class in `test/arrow/type` called `tIsEqual.m`. This class contains unit tests verifying the `isequal` method of `arrow.type.Type` behaves as expected when called on heterogeneous arrays. ### Are there any user-facing changes? Yes. Users can now create nonscalar arrays with different concrete subclasses of `arrow.type.Type`. ### Future Directions 1. Move all display unit tests to `tDisplay.m` 2. Add an `arrow.type.NumericType` class from which all numeric types inherit. This class will define `getDisplayPropertyGroups` for all numeric types. * Closes: apache#37591 Authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
dgreiss
pushed a commit
to dgreiss/arrow
that referenced
this issue
Feb 19, 2024
…mixin.Heterogeneous` (apache#37593) ### Rationale for this change We should modify `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous` so that it's possible to create a nonscalar array containing different concrete subclasses of `arrow.type.Type`. **Example** ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` Currently, running the example above results in an error: ```matlab >> float32Type = arrow.float32(); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] Error using horzcat The following error occurred converting from arrow.type.TimestampType to arrow.type.Float32Type: Invalid argument at position 1. Value must be of type libmexclass.proxy.Proxy or be convertible to libmexclass.proxy.Proxy. ``` ### What changes are included in this PR? 1. Updated `arrow.type.Type` to inherit from `matlab.mixin.Heterogeneous`. Previously, it only inherited from `matlab.mixin.CustomDisplay`. 2. Because `arrow.type.Type` is now `heterogeneous`, its subclasses cannot override the protected method `getPropertyGroups` - which is inherited from `matlab.mixin.CustomDisplay`. This method must be `Sealed` and defined on `Type` because only `Sealed` methods can be called on nonscalar `heterogeneous` arrays. To get around this limitation, I defined a new abstract template method called `getDisplayPropertyGroups`, which `getPropertyGroups` invokes if the array is either scalar or nonscalar and `homogeneous`. Refer to [this link](https://www.mathworks.com/help/matlab/matlab_oop/custom-display-for-heterogeneous-arrays.html) for more details. **Displaying a nonscalar *heterogeneous* `arrow.type.Type`** ```matlab >> float32Type = arrow.timestamp(TimeUnit="Second"); >> timestampType = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [float32Type timestampType] typeArray = 1×2 heterogeneous FixedWidthType (Float32Type, TimestampType) array with properties: ID ``` **Displaying a nonscalar *homogeneous* `arrow.type.Type`** ```matlab >> timestampType1 = arrow.timestamp(TimeUnit="Second"); >> timestampType2 = arrow.timestamp(TimeZone="Pacific/Fiji"); >> typeArray = [timestampType1 timestampType2] typeArray = 1×2 TimestampType array with properties: ID TimeUnit TimeZone ``` ### Are these changes tested? Yes 1. Added a new test class in `test/arrow/type` called `tDisplay.m` 2. Added display unit tests for all concrete subclasses of `arrow.type.Type` if they did not already exist. 3. Added a new test class in `test/arrow/type` called `tIsEqual.m`. This class contains unit tests verifying the `isequal` method of `arrow.type.Type` behaves as expected when called on heterogeneous arrays. ### Are there any user-facing changes? Yes. Users can now create nonscalar arrays with different concrete subclasses of `arrow.type.Type`. ### Future Directions 1. Move all display unit tests to `tDisplay.m` 2. Add an `arrow.type.NumericType` class from which all numeric types inherit. This class will define `getDisplayPropertyGroups` for all numeric types. * Closes: apache#37591 Authored-by: Sarah Gilmore <sgilmore@mathworks.com> Signed-off-by: Kevin Gurney <kgurney@mathworks.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the enhancement requested
We should modify
arrow.type.Type
to inherit frommatlab.mixin.Heterogeneous
so that it's possible to create a nonscalar array containing different concrete subclasses ofarrow.type.Type
.Example
Currently, running the example above results in an error:
Component(s)
MATLAB
The text was updated successfully, but these errors were encountered: