4

While looking at this question, I asked myself the question given in the title. I post the results of my investigation in the question as an answer.

I used the example code given in the referenced question to carry out my investigation.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

1 Answers1

4
pts = {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}};
f = Interpolation[pts]

interp_func

I extracted the property values from the property list with PropertyValue and made an association with the properties names as keys for ease of examination and access.

propAssoc = Association[{# -> PropertyValue[f, #]} & /@ PropertyList[f]]

warning

assoc

The association can be queried to get individual property values.

propAssoc @ "Domain"

{{0, 5}}

but, of course, if we don't want the bother of making an association just to get one or a few property values, we can use

PropertyValue[f, "Domain"]

{{0, 5}}

which seems always to be safe.

However, be aware that f itself acts like an association when given a valid property name and, also being safe, should probably be considered the standard practice for accessing properties.

f @ "Domain"

{{0, 5}}

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
  • Is this meant to be sort of a canonical question/answer that we can point to whenever someone is wondering how to extract information from an InterpolatingFunction? And, if so, isn't the canonical answer just your very last paragraph? – march Feb 08 '19 at 18:41
  • @march I didn't intend for it a canonical question but as an example of how to go about finding and using the properties of functions that have them. If it is useful as a canonical that'a a bonus. However, I think the 1st part, about how extract info on the properties, is as useful as the final conclusion. – m_goldberg Feb 08 '19 at 19:00
  • I mean, I definitely like the Association construction, since it has both the possible property names and their values all in one object, easily accessible and readable (rather than having to remember what properties there are). So, I get it! – march Feb 08 '19 at 19:09