dnychka / fieldsRPackage

GNU General Public License v2.0
14 stars 1 forks source link

Replace `viridis` dependency by `viridisLite` #3

Closed etiennebacher closed 1 year ago

etiennebacher commented 1 year ago

Hello, I see that fields is used as a dependency in a lot of packages. Therefore, I think it would be a good idea to reduce the number of fields's dependencies to reduce the risk of failures for all these packages.

fields depends on viridis which itself depends on ggplot2, which has a large number of dependencies:

pak::pkg_deps_tree("fields")
#> ℹ Loading metadata database✔ Loading metadata database ... done
#> fields 14.1 [new][dl] (4.03 MB)
#> ├─spam 2.9-1 [new][dl] (2.69 MB)
#> │ └─dotCall64 1.0-2 [new][dl] (129.04 kB)
#> ├─viridis 0.6.2 [new][dl] (3.00 MB)
#> │ ├─viridisLite 0.4.1 [new][dl] (1.30 MB)
#> │ ├─ggplot2 3.4.1 [new][dl] (4.23 MB)
#> │ │ ├─cli 3.6.0 [new][dl] (1.30 MB)
#> │ │ ├─glue 1.6.2 [new][dl] (161.94 kB)
#> │ │ ├─gtable 0.3.1 [new][dl] (164.53 kB)
#> │ │ ├─isoband 0.2.7 [new][dl] (1.96 MB)
#> │ │ ├─lifecycle 1.0.3 [new][dl] (138.94 kB)
#> │ │ │ ├─cli
#> │ │ │ ├─glue
#> │ │ │ └─rlang 1.1.0 [new][dl] (1.58 MB)
#> │ │ ├─MASS 7.3-58.3 
#> │ │ ├─mgcv 1.8-42 
#> │ │ │ ├─nlme 3.1-162 
#> │ │ │ │ └─lattice 0.20-45 
#> │ │ │ └─Matrix 1.5-3 
#> │ │ │   └─lattice
#> │ │ ├─rlang
#> │ │ ├─scales 1.2.1 [new][dl] (615.91 kB)
#> │ │ │ ├─farver 2.1.1 [new][dl] (1.51 MB)
#> │ │ │ ├─labeling 0.4.2 [new]
#> │ │ │ ├─lifecycle
#> │ │ │ ├─munsell 0.5.0 [new][dl] (244.63 kB)
#> │ │ │ │ └─colorspace 2.1-0 [new][dl] (2.62 MB)
#> │ │ │ ├─R6 2.5.1 [new][dl] (84.27 kB)
#> │ │ │ ├─RColorBrewer 1.1-3 [new]
#> │ │ │ ├─rlang
#> │ │ │ └─viridisLite
#> │ │ ├─tibble 3.2.0 [new]
#> │ │ │ ├─fansi 1.0.4 [new][dl] (313.51 kB)
#> │ │ │ ├─lifecycle
#> │ │ │ ├─magrittr 2.0.3 [new][dl] (227.24 kB)
#> │ │ │ ├─pillar 1.8.1 [new][dl] (689.95 kB)
#> │ │ │ │ ├─cli
#> │ │ │ │ ├─fansi
#> │ │ │ │ ├─glue
#> │ │ │ │ ├─lifecycle
#> │ │ │ │ ├─rlang
#> │ │ │ │ ├─utf8 1.2.3 [new][dl] (149.94 kB)
#> │ │ │ │ └─vctrs 0.6.0 [new][dl] (1.38 MB)
#> │ │ │ │   ├─cli
#> │ │ │ │   ├─glue
#> │ │ │ │   ├─lifecycle
#> │ │ │ │   └─rlang
#> │ │ │ ├─pkgconfig 2.0.3 [new][dl] (22.54 kB)
#> │ │ │ ├─rlang
#> │ │ │ └─vctrs
#> │ │ ├─vctrs
#> │ │ └─withr 2.5.0 [new][dl] (232.14 kB)
#> │ └─gridExtra 2.3 [new][dl] (1.11 MB)
#> │   └─gtable
#> └─maps 3.4.1 [new][dl] (3.10 MB)
#> 
#> Key:  [new] new | [dl] download

viridis imports ggplot2 because it provides some scale_ functions. However it seems that fields only uses viridis to create some colour palettes. This can be done with viridisLite (which has no dependencies):

vir <- viridis::viridis(256)
virLite <- viridisLite::viridis(256)
identical(vir, virLite)
#> [1] TRUE

pak::pkg_deps_tree("viridisLite")
#> ℹ Loading metadata database✔ Loading metadata database ... done
#> viridisLite 0.4.1 [new][dl] (1.30 MB)
#> 
#> Key:  [new] new | [dl] download

I quickly skimmed through the code so maybe I missed something, but could you replace viridis by viridisLite in the Depends?

etiennebacher commented 1 year ago

Looks like fields was updated, thanks @dnychka

pak::pkg_deps_tree("fields")
#> fields 15.2 [new][dl] (4.05 MB)
#> ├─spam 2.9-1 [new][dl] (2.70 MB)
#> │ └─dotCall64 1.0-2 [new][dl] (138.21 kB)
#> ├─viridisLite 0.4.2 [new][dl] (1.30 MB)
#> └─maps 3.4.1 [new][dl] (3.10 MB)
#> 
#> Key:  [new] new | [dl] download

Created on 2023-08-30 with reprex v2.0.2