Skip to content

Commit

Permalink
MAINT: adjust to change in pd.DataFrame interaction with > (#940)
Browse files Browse the repository at this point in the history
* MAINT: adjust to change in pd.DataFrame interaction with >

* STY: adjust for flake8
  • Loading branch information
wasade authored Nov 8, 2023
1 parent d3f82fe commit 5d1c921
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion biom/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,7 +1593,7 @@ def test_to_dataframe_is_sparse(self):
df = example_table.to_dataframe()
density = (float(example_table.matrix_data.getnnz()) /
np.prod(example_table.shape))
df_density = (df > 0).sum().sum() / np.prod(df.shape)
df_density = (df.values > 0).sum().sum() / np.prod(df.shape)
assert np.allclose(df_density, density)

def test_to_dataframe_dense(self):
Expand Down
4 changes: 2 additions & 2 deletions biom/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,11 +441,11 @@ def biom_open(fp, permission='r'):
opener = h5py.File

if mode in ['U', 'r', 'rb'] and is_gzip(fp):
def opener(fp, mode):
def opener(fp, mode): # noqa
return codecs.getreader('utf-8')(gzip_open(fp, mode))
mode = 'rb' if permission in ['U', 'r'] else permission
elif mode in ['w', 'wb'] and str(fp).endswith('.gz'):
def opener(fp, mode):
def opener(fp, mode): # noqa
codecs.getwriter('utf-8')(gzip_open(fp, mode))

f = opener(fp, mode)
Expand Down

0 comments on commit 5d1c921

Please sign in to comment.