1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-07-22 18:57:39 +02:00

Fix Python tests and static checker warnings

This commit is contained in:
q-posev 2022-09-28 12:48:18 +02:00
parent b36b63347f
commit bdf770d617
3 changed files with 13 additions and 17 deletions

View File

@ -182,15 +182,11 @@ class TestIO:
assert int_num == int64_num assert int_num == int64_num
# write the data for the ground state # write the data for the ground state
offset = 0 offset = 0
trexio.write_state_id(self.test_file, 0)
trexio.write_determinant_list(self.test_file, offset, det_num, dets) trexio.write_determinant_list(self.test_file, offset, det_num, dets)
assert trexio.has_determinant_list(self.test_file) assert trexio.has_determinant_list(self.test_file)
trexio.write_determinant_coefficient(self.test_file, offset, det_num, coeffs) trexio.write_determinant_coefficient(self.test_file, offset, det_num, coeffs)
assert trexio.has_determinant_coefficient(self.test_file) assert trexio.has_determinant_coefficient(self.test_file)
# write the data for some other state
self.test_file.set_state(2)
trexio.write_determinant_coefficient(self.test_file, offset, det_num, coeffs_s2)
assert trexio.has_determinant_coefficient(self.test_file)
self.test_file.set_state(0)
# manually check the consistency between coefficient_size and number of determinants # manually check the consistency between coefficient_size and number of determinants
assert trexio.read_determinant_coefficient_size(self.test_file) == trexio.read_determinant_num(self.test_file) assert trexio.read_determinant_coefficient_size(self.test_file) == trexio.read_determinant_num(self.test_file)

View File

@ -3178,7 +3178,7 @@ trexio_read_$group_dset$(trexio_t* const file,
/* Find the maximal value along all dimensions to define the compression technique in the back end */ /* Find the maximal value along all dimensions to define the compression technique in the back end */
int64_t max_dim = unique_dims[0]; int64_t max_dim = unique_dims[0];
if (unique_rank != 1) { if (unique_rank != 1) {
for (int i = 1; i < unique_rank; i++) { for (uint32_t i = 1; i < unique_rank; i++) {
if (unique_dims[i] > max_dim) max_dim = unique_dims[i]; if (unique_dims[i] > max_dim) max_dim = unique_dims[i];
} }
} }
@ -3310,7 +3310,7 @@ trexio_write_$group_dset$(trexio_t* const file,
/* Find the maximal value along all dimensions to define the compression technique in the back end */ /* Find the maximal value along all dimensions to define the compression technique in the back end */
int64_t max_dim = unique_dims[0]; int64_t max_dim = unique_dims[0];
if (unique_rank != 1) { if (unique_rank != 1) {
for (int i = 1; i < unique_rank; i++) { for (uint32_t i = 1; i < unique_rank; i++) {
if (unique_dims[i] > max_dim) max_dim = unique_dims[i]; if (unique_dims[i] > max_dim) max_dim = unique_dims[i];
} }
} }

View File

@ -1364,9 +1364,9 @@ trexio_exit_code trexio_text_read_$group_dset$(trexio_t* const file,
/* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */ /* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */
char file_full_path[TREXIO_MAX_FILENAME_LENGTH]; char file_full_path[TREXIO_MAX_FILENAME_LENGTH];
/* Copy directory name in file_full_path */ /* Copy directory name in file_full_path */
strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name)); strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH);
/* Append name of the file with sparse data */ /* Append name of the file with sparse data */
strncat (file_full_path, file_name, sizeof(file_name)); strncat (file_full_path, file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name));
/* Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads */ /* Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads */
FILE* f = fopen(file_full_path, "r"); FILE* f = fopen(file_full_path, "r");
@ -1426,9 +1426,9 @@ trexio_text_read_$group_dset$_size(trexio_t* const file, int64_t* const size_max
/* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */ /* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */
char file_full_path[TREXIO_MAX_FILENAME_LENGTH]; char file_full_path[TREXIO_MAX_FILENAME_LENGTH];
/* Copy directory name in file_full_path */ /* Copy directory name in file_full_path */
strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name)); strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH);
/* Append name of the file with sparse data */ /* Append name of the file with sparse data */
strncat (file_full_path, file_name, sizeof(file_name)); strncat (file_full_path, file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name));
/* Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads */ /* Open the file in "r" (read) mode to guarantee that no truncation happens upon consecutive reads */
FILE* f = fopen(file_full_path, "r"); FILE* f = fopen(file_full_path, "r");
@ -1476,9 +1476,9 @@ trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file,
/* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */ /* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */
char file_full_path[TREXIO_MAX_FILENAME_LENGTH]; char file_full_path[TREXIO_MAX_FILENAME_LENGTH];
/* Copy directory name in file_full_path */ /* Copy directory name in file_full_path */
strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name) - append_str_len); strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH);
/* Append name of the file with sparse data */ /* Append name of the file with sparse data */
strncat (file_full_path, file_name, sizeof(file_name)); strncat (file_full_path, file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name));
/* Open the file in "a" (append) mode to guarantee that no truncation happens upon consecutive writes */ /* Open the file in "a" (append) mode to guarantee that no truncation happens upon consecutive writes */
FILE* f = fopen(file_full_path, "a"); FILE* f = fopen(file_full_path, "a");
@ -1523,9 +1523,9 @@ trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file,
memset (file_full_path, 0, TREXIO_MAX_FILENAME_LENGTH); memset (file_full_path, 0, TREXIO_MAX_FILENAME_LENGTH);
/* Copy directory name in file_full_path */ /* Copy directory name in file_full_path */
strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(group_file_name)); strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH);
/* Append name of the file with sparse data */ /* Append name of the file with sparse data */
strncat (file_full_path, group_file_name, sizeof(group_file_name)); strncat (file_full_path, group_file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(group_file_name));
bool file_exists = trexio_text_file_exists(file_full_path); bool file_exists = trexio_text_file_exists(file_full_path);
@ -1551,9 +1551,9 @@ trexio_exit_code trexio_text_has_$group_dset$(trexio_t* const file)
/* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */ /* The full path to the destination TXT file with sparse data. This will include TREXIO directory name. */
char file_full_path[TREXIO_MAX_FILENAME_LENGTH]; char file_full_path[TREXIO_MAX_FILENAME_LENGTH];
/* Copy directory name in file_full_path */ /* Copy directory name in file_full_path */
strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name)); strncpy (file_full_path, file->file_name, TREXIO_MAX_FILENAME_LENGTH);
/* Append name of the file with sparse data */ /* Append name of the file with sparse data */
strncat (file_full_path, file_name, sizeof(file_name)); strncat (file_full_path, file_name, TREXIO_MAX_FILENAME_LENGTH - sizeof(file_name));
/* Check the return code of access function to determine whether the file with data exists or not */ /* Check the return code of access function to determine whether the file with data exists or not */
if (access(file_full_path, F_OK) == 0){ if (access(file_full_path, F_OK) == 0){