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

refactor: updates of documentation and extension of unit tests #753

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

jorainer
Copy link
Collaborator

@jorainer jorainer commented Jun 6, 2024

  • Small fixes and formatting changes in the code.
  • Expand unit tests to cover additional scenarios.
  • Update/restructure documentation.

- Small fixes and formatting changes in the code.
- Expand unit tests to cover additional scenarios.
- Update/restructure documentation.
old <- paste0(old, "/")
if (length(spectraPath) > 0) {
old <- common_path(dataStorage(b))
## if (nchar(old) > 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if we need this - I would skip since / and // work both, so better to be sure that there is a / before the file name.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm I need to test it, because I thought the result of common_path never resulted with a / at the end of the path, so i thought that was necessary

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After checking, isn't that how the function behave ? and we definitely need to add this / ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how I understood it (can be wrong), but yes, the result from common_path() never ends in a "/". so, assume we have "/some/path/some/file.txt", then the common path would be "/some/path/some" and assuming the user defines spectraPath = "/new/path". We would like to replace to get "/new/path/file.txt". If we always add a "/"at theold, oldwould be in this case"/some/path/some/"and thesub()call will replace"/some/path/some/"with"/new/path"- and we get"/new/pathfile.txt". that's why I would not append the trailing "/"` to the pattern we want to replace.

Also, "/new/path/file.txt" and "/new/path//file.txt" both work - so, if the user would provide spectraPath = "/new/path/" (i.e. with a trailing "/") it would/should still work.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooooh of course ! No that make complete sense, but ye I think that the less we have if statement the better so i will remove it.

@jorainer jorainer requested a review from philouail June 6, 2024 06:09
@jorainer
Copy link
Collaborator Author

jorainer commented Jun 6, 2024

really big thanks for the great code and contribution @philouail !

@@ -56,21 +94,38 @@ test_that("storeResults,loadResults,PlainTextParam,MsExperiment works", {
## Loading data again
load_mse <- loadResults(object = MsExperiment(), param)
expect_true(inherits(load_mse, "MsExperiment"))
expect_equal(sampleData(mse), sampleData(load_mse))
a <- spectra(mse)
expect_equal(sampleData(tmp), sampleData(load_mse))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask why you create a tmp object here ? is it because otherwise we permanently change the mse (or xmse_full) object for the later tests ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think testthat changes the variables within each unit test locally, not globally - it's more that when I evaluate the unit tests line by line I change the variables in my R session and then I get unexpected errors later. I generally avoid overwriting the "globally" defined variables where possible. Also, I specifically use a variable name tmp to remember that I will overwrite this variable for sure later...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oki fair thanks !

@philouail
Copy link
Collaborator

philouail commented Jun 6, 2024

Thanks so much @jorainer for polishing everything ! it looks so much better, I do have some questions in comments !

Also the checks don't pass because of the Spectra package update aha

@jorainer
Copy link
Collaborator Author

jorainer commented Jun 6, 2024

The updates in the Spectra package should become available later today or tomorrow I guess - I pushed yesterday to Bioconductor.

@philouail philouail merged commit 9d27594 into import_methods Jun 6, 2024
0 of 3 checks passed
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