Skip to content

Commit

Permalink
Fix Dataframe bug with numpy strings
Browse files Browse the repository at this point in the history
* small fix to append_column/ short col too long

* write_df_compat sole test

* fix bug for np.string not converted to vlen_str

* Revert "write_df_compat sole test" in this branch

This reverts commit a1c0ab1.
  • Loading branch information
hkchekc authored and achilleas-k committed Jan 14, 2019
1 parent 99b0e69 commit e04b9c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions nixio/block.py
Expand Up @@ -239,9 +239,10 @@ def create_data_frame(self, name, type_, col_dict=None, col_names=None,

if col_dict is not None:
for nam, dt in col_dict.items():
if isclass(dt) and any(issubclass(dt, st)
for st in string_types):
col_dict[nam] = util.vlen_str_dtype
if isclass(dt):
if any(issubclass(dt, st) for st in string_types) \
or issubclass(dt, np.string_):
col_dict[nam] = util.vlen_str_dtype
dt_arr = list(col_dict.items())
col_dtype = np.dtype(dt_arr)

Expand Down
2 changes: 1 addition & 1 deletion nixio/test/test_data_frame.py
Expand Up @@ -148,7 +148,7 @@ def test_append_column(self):
k = np.array(self.df1[0:10]["trial_col"], dtype=np.int64)
np.testing.assert_almost_equal(k, y)
# too short coulmn
sh_col = np.arange(start=16000, stop=16100, step=1)
sh_col = np.arange(start=16000, stop=16003, step=1)
self.assertRaises(ValueError, lambda:
self.df1.append_column(sh_col, name='sh_col'))
# too long column
Expand Down

0 comments on commit e04b9c4

Please sign in to comment.