sisl / GridInterpolations.jl

Multidimensional grid interpolation in arbitrary dimensions
Other
52 stars 12 forks source link

Base.show() doesn't differentiate between simplex and rectangular grids #4

Closed zsunberg closed 9 years ago

zsunberg commented 9 years ago

Hi all,

I've been using GridInterpolations in one of my projects, and I have been saving string representations of the grids that I've been using so that I can remember what I did later. As the code stands, Base.show() simply returns a vector of vectors representing the grid, but it doesn't indicate whether the grid uses simplex or rectangular interpolation. Can we change Base.show() so that it returns an unambiguous description of the grid, or, even more ideally a string that can be parsed and used directly to construct an identical grid object?

i.e. Base.show(mySimplexGrid) returns "SimplexGrid([1.0,2.0,3.0],[1.0,2.0,3.0])"

If this sounds like a good idea, I'll submit a pull request for it this afternoon.

Thanks,

Zach

tawheeler commented 9 years ago

Thoughts:

mykelk commented 9 years ago

I agree with @tawheeler. Feel free to submit a PR. Thanks!

zsunberg commented 9 years ago

Hi guys,

After thinking about it, here's what I'll try to do:

Implement a repr function that returns a valid constructor incantation Change show to return something more concise showall will return the same thing as repr for now

I'm assuming repr means the same thing in julia as it does in python, but I haven't found any central guidelines for what the various string-conversion methods should return. Any objections/comments?

As a side note, I believe that there are actually good reasons to store a minimal text representation* rather than the raw structured data in a binary format, especially when storing complex abstract data like descriptions of functions. The main reason is that, if the implementation changes, you can more easily recover your data or convert it to work with the new implementation. In the Beginning was the Command Line discusses this quite a bit (especially the "Metaphor Shear" section). In fact, one may think of source files themselves as a text representation of complex binary data (a program). Also, the presence of the repr() function in python is evidence that many programmers think that having access to a text representation of an object is useful.

*btw I'm actually storing the strings within HDF5 to keep things organized

tawheeler commented 9 years ago

I think you only need to write a showall function; repr uses showall to produce a string version of the output.

You are right - having a text version can often be a good thing. I should not have said 'bad idea'. My knee-jerk reaction was merely that large arbitrary triangulations would be hard to interpret in text format and so the benefit would be minimal. There is no reason not to support a text format.

mykelk commented 9 years ago

Sounds good.

zsunberg commented 9 years ago

[I know this isn't the right place to ask about this] How does SISL do pull requests? I made a local branch, but I can't push it to this repo to create the pull request. Do I need to make a fork of this entire repo to my github profile? That seems unnecessary, but maybe that's the way it's typically done.