Skip to content

Commit

Permalink
testing; minor bugfixes; inline doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zzeppozz committed Oct 7, 2024
1 parent bcaae30 commit d9d1b5c
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 105 deletions.
2 changes: 1 addition & 1 deletion bison/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ANALYSIS_DIM:
"state_county", "census_state", "census_county", "taxonkey_species",
"species", "riis_assessment", "occ_count"
],
"key_fld": "census_county",
"key_fld": "state_county",
}
AIANNH = {
"code": "aiannh",
Expand Down
7 changes: 4 additions & 3 deletions bison/spnet/sparse_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,10 @@ def get_totals(self, axis):
all_totals (list): list of values for the axis.
"""
mtx = self._coo_array.sum(axis=axis)
# 2d Matrix is a list of rows
# Axis 0 produces a matrix shape (1, col_count), 1 row
# Axis 1 produces matrix shape (row_count, 1), row_count rows
# Axis 0 produces a matrix shape (1, col_count),
# 1 row of values, total for each column
# Axis 1 produces matrix shape (row_count, 1),
# 1 column of values, total for each row
if axis == 0:
all_totals = mtx.tolist()[0]
elif axis == 1:
Expand Down
9 changes: 7 additions & 2 deletions bison/spnet/summary_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,13 @@ def init_from_sparse_matrix(cls, sp_mtx, axis=0, logger=None):
datasetkey (for the column labels/x), species (for the row labels/y),
and occurrence count.
"""
# Column counts and totals (count along axis 0, each row)
# Row counts and totals (count along axis 1, each column)
# Total/Count down axis 0/row, rows for a column
# across axis 1/column, columns for a row (aka species)
# Axis 0 produces a matrix shape (col_count, 1),
# 1 row of values, total for each column
#
# Axis 1 produces matrix shape (row_count, 1),
# 1 column of values, total for each row
totals = sp_mtx.get_totals(axis=axis)
counts = sp_mtx.get_counts(axis=axis)
data = {COUNT_FLD: counts, TOTAL_FLD: totals}
Expand Down
Loading

0 comments on commit d9d1b5c

Please sign in to comment.