Re: Issues accessing class attributes of external package distance function
Peter Reutemann <[email protected]> Wed, 20 Jul 2022 15:38:16 +1200
| Newsgroups | gmane.comp.ai.weka |
|---|---|
| Message-ID | <CAHoQ12+8+4sV5wykNQBvXFBBPayRjDHN+7B6rac=M+VvVW0hSg@mail.gmail.com> |
> >> If the intention isn’t to include this in a Weka java based package I’m still unclear on how it is meant to be provided. Again possibly I don’t understand well enough how the Python works. > > > > Not quite sure what you mean. The DilcaDistance class (which is > > already available as a Weka package) has a protected field. OP wants > > to access this field directly and turn the stored matrices into numpy > > arrays with no precision loss which currently happens when parsing the > > toString() output of said class. > > How it is intended to use the earlier python without somehow adding them to a package is what isn’t clear to me. > A concern for how the research was going to be made available was indicated by the OP. > That this is somehow possible in a python way without a package or java involved is what I’m not quite understanding. The way I understand the OP, they only want to have to make their Python code available alongside the publication, not also an additional Weka package whose only purpose is to make the internal data structure of the DilcaDistance available. That Python code uses python-weka-wrapper3, so Weka will be used under the hood. So, yes, Java and Weka packages will be used, just not explicitly. > > Accessing non-public members/methods is not a very common use-case, > > but sometimes required when you need internally computed/held data > > structures for further processing. > > Over the years, I've had to sub-class plenty of classes to get access > > to such data structures. Annoying, but not really a biggie when you're > > already programming in Java. > > > Yes. As I mentioned I’ve done it before. Not plenty of times but once or twice. > Really pretty simple and would work well I’d think if a package were provided. Without the need for a cross-language hack. It's not really a cross-language hack. The "hack" happens purely on the Java side with "X.setAccessible(true);", giving access to a field/method. The Python code simply tells the Java process to execute the hack and then obtain the relevant data (and then convert it into Python data structures). ;-) > But I tend to a java bias anyhow. For some things Java is better, for other things Python. Whatever gets the job done, really. Cheers, Peter -- Peter Reutemann Dept. of Computer Science University of Waikato, NZ +64 (7) 858-5174 (office) +64 (7) 577-5304 (home office) https://www.cs.waikato.ac.nz/~fracpete/ http://www.data-mining.co.nz/ _______________________________________________ Wekalist mailing list -- [email protected] Send posts to [email protected] To unsubscribe send an email to [email protected] To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html