An issue came up in the last DA, when Ryan led us through the latest version of Melissa’s 07a tutorial on DIAObject time series. In that notebook, a histogram plot was misrendered (a huge number of ticks). The problem ended up being caused by one of the attributes from a query being passed as a string to matplotlib, instead of as an array of floats.
About halfway through 07a, there’s an option to display the DiaObjs
table. The displayed table shows that all attributes have type float64
, except for rMagAmp
, which for some reason was returned with type object
(that’s what NumPy typically does for a column if it’s passed data of mixed types). It’s the rMagAmp
histogram that MPL couldn’t handle. Changing the plot command to use a cast fixed it:
ax[1].hist(numpy.asarray(DiaObjs['rMagAmp'], float), bins=20, color=plot_filter_colors['r'])
I posted about this in Zoom chat, asking why that column had the object
type, but it was at the end of the session and we didn’t get time to address it. This raises the question of understanding when a query may be expected to return a number, or instead a number rendered as a string.