+def _week_similarities(tempdir, term_colname, week):
+ print(f"loading matrix: {week}")
+ mat = read_tfidf_matrix_weekly(tempdir.name, term_colname, week)
+ print('computing similarities')
+ sims = column_similarities(mat)
+ del mat
+
+ names = subreddit_names.loc[subreddit_names.week == week]
+ sims = pd.DataFrame(sims.todense())
+
+ sims = sims.rename({i: sr for i, sr in enumerate(names.subreddit.values)}, axis=1)
+ sims['_subreddit'] = names.subreddit.values
+
+ write_weekly_similarities(outfile, sims, week, names)