Repository navigation
Trial implementation of __repr__ and __str__ - #13
Conversation
There was a problem hiding this comment.
Can this be changed to something slightly more descriptive like array_names or data_names or similar? I know you have it as private, but anyone wanting to subclass will need to implement it, so it can't be private.
@astrofrog or @Cadair, does the use of _names seem fine to you? Or was there some other way you had in mind for how to sniff out the names of the data attributes?
|
I like this in general, but I'm confused by the output you're showing: why are there four entries for each, when there are only three coordinates? |
|
Oh wait, I get it... it's a list of each of the coordinates, not a list of the elements of the arrays. So that are we ok with the fact that this is in contrast to the low-level classes |
|
@eteq, others: the implementation really was extremely quick & dirty -- I would definitely like to clean it up before you give detailed comments! |
|
Hmm, well, as I said, I see the merits of both, so I'm willing to accept this way for the representations, and the other way for the low-level classes (there it makes more sense anyway, because they actually have useful names, and the frame attributes have to be in a similar form). But other opinions would be to have registered before a final decsion. |
|
Oh, and FYI in case it's an oversight, it seems to fail for scalars, @mhvk |
|
@eteq - the single elements are working now too. I tried a slightly different approach to And the different approach, which I felt was rather ugly, was: |
|
I like this version, @mhvk, now that I've gotten used to the idea. Two things:
How would you feel about special-casing the scalar version to instead give and |
|
Oh, and it will be easy to adjust the frame classes to make a similar-looking repr by reusing this code, so that's a good thing (TM). |
|
@eteq - OK, like that idea, so next iteration. Also realised that once component names are known, Anyway, |
|
@mhvk - I like how that looks, but I'm seeing a new error, which I demonstrate below. I think the problem is that |
|
Alright, this now seems fine to me @mhvk - if no one else voices an opion, I'll merge it tomorrow. |
|
Alright, I'm going to go ahead and merge this now. Thanks @mhvk! |
Implementation of representations' __repr__ and __str__
Lazyproperty for cache / easier scale setting in __add__, __sub__
To have
reprandstrproduce at least something, I combined the looks ofrecarrayandQuantity, a bit like happens now forEarthLocation. The current implementation is far from fast & perfect, but suffices perhaps to show what it will look like (also, it seems impossible to raise an issue, so one has to do a PR...).cc @eteq, @taldcroft, @astrofrog, @Cadair, @adrn
In action (note how the angle units get lost; bit of a pity, but not essential for now):