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

Truncate numpy arrays with ndim >= 2 so that the total printed does not exceed max_seq_len #63

Merged
merged 1 commit into from
Jun 22, 2019

Conversation

crowsonkb
Copy link
Contributor

When I tried to pretty-print an array I was working with, np.eye(100), it took a large number of lines! It turns out max_seq_len is the maximum subsequence length and that ndarrays are being considered simply as nested lists. I altered this behavior: for ndarrays where ndim >= 2, a temporary ctx_new.max_seq_len is determined for each print, which is the maximum subsequence length l such that np.prod(np.minimum(l, value.shape)) <= ctx.max_seq_len. It is determined through binary search (following the pseudocode here).

@tommikaikkonen tommikaikkonen merged commit 180e6c5 into tommikaikkonen:master Jun 22, 2019
@tommikaikkonen
Copy link
Owner

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants