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

Add a ULAB_PRINT_DTYPE constant #602

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions code/ndarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ void ndarray_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
ndarray_print_bracket(print, 0, self->shape[ULAB_MAX_DIMS-4], "]");
#endif
}
#if ULAB_PRINT_DTYPE
mp_print_str(print, ", dtype=");
if(self->boolean) {
mp_print_str(print, "bool)");
Expand All @@ -549,6 +550,9 @@ void ndarray_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t ki
mp_print_str(print, "float64)");
#endif
}
#else
mp_print_str(print, ")");
#endif
}

void ndarray_assign_elements(ndarray_obj_t *ndarray, mp_obj_t iterable, uint8_t dtype, size_t *idx) {
Expand Down
5 changes: 5 additions & 0 deletions code/ulab.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
#define NDARRAY_PRINT_THRESHOLD 10
#define NDARRAY_PRINT_EDGEITEMS 3

// determines whether an array's dtype should be printed with the array
#ifndef ULAB_PRINT_DTYPE
#define ULAB_PRINT_DTYPE (1)
#endif

// determines, whether the dtype is an object, or simply a character
// the object implementation is numpythonic, but requires more space
#ifndef ULAB_HAS_DTYPE_OBJECT
Expand Down