Skip to content

set half precision for numpy arrays#87

Open
lsantuari wants to merge 2 commits into
devfrom
change_prec
Open

set half precision for numpy arrays#87
lsantuari wants to merge 2 commits into
devfrom
change_prec

Conversation

@lsantuari

Copy link
Copy Markdown
Contributor

It reduces the file size for numpy arrays by setting half precision.

@lsantuari lsantuari added the code label Jan 15, 2021
@lsantuari lsantuari added this to the 0.1.0 milestone Jan 15, 2021
@lsantuari lsantuari self-assigned this Jan 15, 2021
Comment thread scripts/genome_wide/add_win_channels.py
Comment thread scripts/genome_wide/coverage.py Outdated
last_t = time()
i = 1
padding = np.zeros(shape=(padding_len, n_channels), dtype=np.float32)
padding = np.zeros(shape=(padding_len, n_channels), dtype=np.half)

@arnikz arnikz Jan 15, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this precision sufficient? I would keep the former.

>>> np.finfo(np.float32).precision
6
>>> np.finfo(np.half).precision
3
``

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the result on the test data it seems to be sufficient, but I need to try it on the real data.

reference_sequence = twobit.TwoBitFile(itwobit)
snv_list = ['BQ', 'SNV', 'MAPQ']
snv_array = np.zeros(shape=(stop_pos, len(snv_list)), dtype=np.float32)
snv_array = np.zeros(shape=(stop_pos, len(snv_list)), dtype=np.half)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw aren't all channel values counts only?

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants