cmap / cmapPy

Assorted tools for interacting with .gct, .gctx files and other Connectivity Map (Broad Institute) data/tools
https://clue.io/cmapPy/index.html
BSD 3-Clause "New" or "Revised" License
126 stars 76 forks source link

fix bug where floats where written out with maximum decimal places and data_float_parameter was ignored #33

Closed dllahr closed 6 years ago

dllahr commented 6 years ago

Hello friends! I noticed that when I was using write_gct the resulting text files were written out with the maximum number of decimal places (based on the float type used) and the data_float_format parameter was ignored.

Short version: this pull request fixes that problem.

Long version: pandas.DataFrame.to_csv was ignoring the float_format option because in the method write_bottom_half the dataframe that is written is entirely of type object - it only applies the float_format parameter to floats. So I changed how we make that dataframe, keeping the left bottom half as type object and making the right bottom half exactly what the contents of data_df are.

EDIT: Also I fixed a bug in write_gct.write_gct where it was ignoring all input arguments and using hard-coded ones in its call to write. Might consider deleting write_gct since it is redundant?

oena commented 6 years ago

Hi Dave! Good catch, and thanks for adding tests too! :)

levlitichev commented 6 years ago

Thanks for the fix, @dllahr.

EDIT: Also I fixed a bug in write_gct.write_gct where it was ignoring all input arguments and using hard-coded ones in its call to write. Might consider deleting write_gct since it is redundant?

I vote in favor.

oena commented 6 years ago

Whoops my bad, missed the edit. According to the docstrings it's for backwards compatibility though...? Not super familiar

levlitichev commented 6 years ago

I think that addition was for some init.py things that we had been working on: 5c933fc

I done it. https://github.com/cmap/cmapPy/commit/9f03dd2b5c860fbd5d7e5567b6c3209399150ff1