Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set half precision for numpy arrays #87

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open

set half precision for numpy arrays #87

wants to merge 2 commits into from

Conversation

lsantuari
Copy link
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
scripts/genome_wide/add_win_channels.py Show resolved Hide resolved
scripts/genome_wide/coverage.py Outdated Show resolved Hide resolved
@@ -74,7 +75,7 @@ def get_windows(carrays_dir, outDir, chrom_list, win, label_file_path, mode, npz
n_r = 10 ** 5
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)
Copy link
Contributor

@arnikz arnikz Jan 15, 2021

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
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.

@@ -32,7 +32,7 @@ def get_snv_number(query_seq_list, reference_base):
stop_pos = chrLen
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
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
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

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