lsst-epo / citizen-science-notebooks

A collection Jupyter notebooks that can be used to associate Rubin Science Platform data to a Zooniverse citizen science project.
3 stars 1 forks source link

Remove 'filter' from the for loop of variable stars notebook #84

Closed beckynevin closed 5 months ago

beckynevin commented 7 months ago

From Eric:

Hey Becky, saw something in the variable stars notebook which will need to change. In this cell…


plot_filter_labels = ['u', 'g', 'r', 'i', 'z', 'y']
plot_filter_colors = {'u': '#56b4e9', 'g': '#008060', 'r': '#ff4000',
'i': '#850000', 'z': '#6600cc', 'y': '#000000'}
plot_filter_symbols = {'u': 'o', 'g': '^', 'r': 'v', 'i': 's', 'z': '*', 'y': 'p'}

pick = {} for filter in plot_filter_labels: pick[filter] = (source['band'] == filter)


…the name filter is used to represent each element of plot_filter_labels. Python actually has a built-in method called filter() and when the Python interpreter gets to this for-loop it overwrites the built-in filter() method and replaces it with a variable. After this cell the method filter is no longer callable and instead represents whatever the last value of the for loop was.
[12:36](https://lsstc.slack.com/archives/D049RJZCQP7/p1706034982711459)
Discovered this when I was using trying to use the filter() method to test something out later in the notebook
beckynevin commented 5 months ago

My solution (implemented in branch #70 ) is to rename filter --> band. Also delete plot_filter_colors and plot_filter_symbols, which are unused in the rest of the notebook.