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

bugfix(matrix): correct the loading and saving of empty matrices as TSV files #1746

Merged
merged 3 commits into from
Sep 28, 2023

Conversation

laurent-laporte-pro
Copy link
Contributor

Description

The purpose of this pull request is to address an issue encountered when generating empty matrices. In certain cases, empty matrices are saved in TSV format with a newline character instead of being saved as completely empty files.

The proposed solution involves modifying the code to save an empty file when the matrix is empty.

Additionally, when loading an empty file, it will be treated as a 2D empty matrix.

Technical Details

A 2D-NumPy array is considered empty if its size attribute is zero or if its shape is (1, 0). This corresponds to the Python array [[]].

Changes Made

  • Modified the code to save an empty file when an empty matrix is encountered during the saving process.
  • Updated the loading logic to correctly interpret empty files as 2D empty matrices.
  • Improved unit tests to ensure proper reading and writing of empty matrices in TSV format.

Testing

Unit tests have been enhanced to thoroughly validate the functionality of reading and writing empty matrices to disk in TSV format.

Related Issue

close #1731

Checklist

  • Code has been tested and is functioning as expected.
  • Unit tests have been added or updated to cover the changes.
  • Documentation has been updated to reflect these changes, if necessary.

@laurent-laporte-pro laurent-laporte-pro self-assigned this Sep 28, 2023
@commit-lint
Copy link

commit-lint bot commented Sep 28, 2023

Bug Fixes

  • matrix: create empty file if the matrix is empty (9155566)

Code Refactoring

  • matrix: improve implementation of dataframe saving (c156c3b)
  • matrix-service: improve implementation of create_by_importation (b054b8b)

Contributors

laurent-laporte-pro

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@laurent-laporte-pro laurent-laporte-pro merged commit 2b627db into dev Sep 28, 2023
@laurent-laporte-pro laurent-laporte-pro deleted the bugfix/fix-empty-array-dataframe-save branch September 28, 2023 16:13
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.

[ANT-848] Problem with np.savetxt creating non-empty files for empty 2D-NumPy arrays
2 participants