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 pretty print for DimensionalArray #33
Conversation
I don't know if this is a bug, unwanted behavior, or wanted behavior, but this PR made me realize that:
reducing operations keep the dimensions even if reduced over them (in contrast to |
Codecov Report
@@ Coverage Diff @@
## master #33 +/- ##
=========================================
+ Coverage 88.15% 89.2% +1.04%
=========================================
Files 10 11 +1
Lines 515 528 +13
=========================================
+ Hits 454 471 +17
+ Misses 61 57 -4
Continue to review full report at Codecov.
|
That's because Julia keeps them! After a reducing operation you always have a length 1 dim. So we have to keep the dimension type too... I just change the step size and make it cover the whole original dim length. I'm not sure what python does. |
But otherwise that looks great. You might want to try it with a large vector of DateTime or something as Also maybe try it with larger grids. |
Good point and thankfully I know how to fix it since I've already done it in DynamicaSystems.jl. I'll check it tomorrow at the office. |
Yeah, you are right (although I have to admit I never liked that Julia decision). Regardless, what I do personally is implement
As you can see, for standard Julia arrays this is no big deal. But for DimensionalArray, I would imagine that the processes of "dropping" the singleton dimension is much more involved for the general user. Perhaps I should contribute Python's |
dropdims is actually easier with dimensions as you don't need to know the number: Look in the methods.jl tests to see everything that's implemented with dims. It's quite a lot. For your |
running Unfortunately, even though I've used the limiter function suggested by Sebastian, it works but not "precisely". It limits the vector output to a elements to fill the row, as it should, but its just goes a little overboard in Juno. Regardless, this is unrelated with this PR, and as far as Julia Base is concerned, I used all the correct tools to make it print the dimension values in 1 line. The rest is up to Juno, and I've reported it. This is good to go from my end. |
timespan = DateTime(2001):Month(1):DateTime(2001,12) | ||
t = Time(timespan) | ||
x = X(Vector(10:10:500)) | ||
A = DimensionalArray(rand(12,length(x)), (t, x)) |
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.
Can we run show
on these? We probably don't need an actual test, but it would be good to run the code to make sure it doesn't error.
The outputs look great. Thanks for working on the print limiting I'm happy with that. |
Thanks, you are welcome. Can I ask why you didn't merge it if you liked the PR? Seems pretty useful to have and I'd like to work on other features as well. |
See the inline comment above! Maybe you missed it. Just add |
Ah sorry, yes I missed it. I can add proper tests, hold on. |
Thanks thats even better |
Now from
one gets: