Closed Yunuuuu closed 9 months ago
This is expected behavior, inherent in the precision limitations of using a float (aka float32) vs a double (aka float64) -- for instance this wikipedia table lists the precision limitations, among them the fact that floats cannot represent numbers larger than 3.4e38.
BPCells does in general default to using double precision math for its transformations. If users explicitly convert to floats, it's their responsibility to ensure their inputs fall within the representable range for floats. (One slight tripping hazard in this respect is that the default log1p
implementation uses single-precision math in intermediate stages because the 2x speed boost of floats seems worth the tradeoff -- a log1p_slow
function is available that operates fully in double precision)
I appreciate the detailed checks, but I think for this one I'm considering it within the expected behavior. Though if you find a case where it converts a number to Inf that should be representable as a float then do let me know.
Although
float
matrix anddouble
both are equal, some large values infloat
matrix becomeInf
after subset assign, I don't know if this is a issue, maybe we should recomment the usage ofdouble
matrix type?Created on 2024-02-10 with reprex v2.0.2
Session info
``` r sessioninfo::session_info() #> ─ Session info ─────────────────────────────────────────────────────────────── #> setting value #> version R version 4.3.1 (2023-06-16) #> os Ubuntu 22.04.3 LTS #> system x86_64, linux-gnu #> ui X11 #> language en #> collate C.UTF-8 #> ctype C.UTF-8 #> tz Asia/Shanghai #> date 2024-02-10 #> pandoc 2.9.2.1 @ /usr/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> BiocGenerics 0.46.0 2023-04-25 [1] Bioconductor #> bitops 1.0-7 2021-04-24 [1] CRAN (R 4.3.1) #> BPCells * 0.1.0 2024-02-06 [1] Github (bnprks/BPCells@919983d) #> cli 3.6.2 2023-12-11 [1] CRAN (R 4.3.1) #> crayon 1.5.2 2022-09-29 [1] CRAN (R 4.3.1) #> diffobj 0.3.5 2021-10-05 [1] CRAN (R 4.3.1) #> digest 0.6.33 2023-07-07 [1] CRAN (R 4.3.1) #> evaluate 0.23 2023-11-01 [1] CRAN (R 4.3.1) #> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.3.1) #> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.3.1) #> fs 1.6.3 2023-07-20 [1] CRAN (R 4.3.1) #> GenomeInfoDb 1.36.1 2023-06-21 [1] Bioconductor #> GenomeInfoDbData 1.2.10 2023-08-08 [1] Bioconductor #> GenomicRanges 1.52.0 2023-04-25 [1] Bioconductor #> glue 1.6.2 2022-02-24 [1] CRAN (R 4.3.1) #> htmltools 0.5.7 2023-11-03 [1] CRAN (R 4.3.1) #> IRanges 2.34.1 2023-06-22 [1] Bioconductor #> knitr 1.45 2023-10-30 [1] CRAN (R 4.3.1) #> lattice 0.22-5 2023-10-24 [1] CRAN (R 4.3.1) #> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.3.1) #> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.3.1) #> Matrix 1.6-4 2023-11-30 [1] CRAN (R 4.3.1) #> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.3.1) #> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.3.1) #> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.3.1) #> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.3.1) #> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.3.1) #> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.3.1) #> R.utils 2.12.2 2022-11-11 [1] CRAN (R 4.3.1) #> Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.3.1) #> RCurl 1.98-1.12 2023-03-27 [1] CRAN (R 4.3.1) #> rematch2 2.1.2 2020-05-01 [1] CRAN (R 4.3.1) #> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.3.1) #> rlang 1.1.2 2023-11-04 [1] CRAN (R 4.3.1) #> rmarkdown 2.25 2023-09-18 [1] CRAN (R 4.3.1) #> RSpectra 0.16-1 2022-04-24 [1] CRAN (R 4.3.1) #> S4Vectors 0.38.1 2023-05-02 [1] Bioconductor #> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.3.1) #> styler 1.10.2 2024-01-13 [1] Github (r-lib/styler@17f91fc) #> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.3.1) #> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.3.1) #> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.3.1) #> waldo 0.5.2 2023-11-02 [1] CRAN (R 4.3.1) #> withr 2.5.2 2023-10-30 [1] CRAN (R 4.3.1) #> xfun 0.41 2023-11-01 [1] CRAN (R 4.3.1) #> XVector 0.40.0 2023-04-25 [1] Bioconductor #> yaml 2.3.8 2023-12-11 [1] CRAN (R 4.3.1) #> zlibbioc 1.46.0 2023-04-25 [1] Bioconductor #> #> [1] /home/yun/Rlibrary/4.3 #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library #> #> ────────────────────────────────────────────────────────────────────────────── ```