![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1766289/image.png)
Does fileDatastore not implement "matlab.io.Datastore"?
1 回表示 (過去 30 日間)
古いコメントを表示
I'm currently developing a custom datastore that takes an existing datastore and adds some features.
In the constructor I would like to make sure that a passed argument is of type "matlab.io.Datastore" so I do:
assert(isa(ds, "matlab.io.Datastore"), ...)
This works fine for another custom datastore that directly implements "matlab.io.Datastore" but it does not work when das is created using
ds = fileDatastore(...)
fileDatastore. Form digging around in the source of "matlab.io.datastore.FileDatastore" I found out that it at some point implements "matlab.io.Datastore" but still above is not wokring. Am I missing somehting obvious?
0 件のコメント
回答 (1 件)
Shlok
2024 年 9 月 4 日
Hi Eike,
The “matlab.io.datastore.FileDatastore” class does not implement the “matlab.io.Datastore” interface. As a result, “assert(isa(ds, 'matlab.io.Datastore'), ...)” returns “false” when used for “fileDatastore()” instance.
You can verify this by using the “superclasses” function, which lists all the superclasses of a given class.
superclasses(ds)
Output:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1766289/image.png)
From the output above, you can see that “matlab.io.datastore.FileDatastore” implements “matlab.io.datastore.Datastore” instead of “matlab.io.Datastore”. Therefore, you need to modify the code as follows to return “true”:
assert(isa(ds, "matlab.io.datastore.Datastore"), ...);
To know more about “fileDatastore”, refer to the following documentation link:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!