From noreply at r-forge.r-project.org Fri Aug 1 05:35:57 2025 From: noreply at r-forge.r-project.org (noreply at r-forge.r-project.org) Date: Fri, 1 Aug 2025 05:35:57 +0200 (CEST) Subject: [CHNOSZ-commits] r933 - in pkg/CHNOSZ: . R inst inst/tinytest Message-ID: <20250801033557.23CB11859A6@r-forge.r-project.org> Author: jedick Date: 2025-08-01 05:35:56 +0200 (Fri, 01 Aug 2025) New Revision: 933 Modified: pkg/CHNOSZ/DESCRIPTION pkg/CHNOSZ/R/mosaic.R pkg/CHNOSZ/README.md pkg/CHNOSZ/inst/NEWS.Rd pkg/CHNOSZ/inst/tinytest/test-mosaic.R Log: Fix mosaic() to form H2O Modified: pkg/CHNOSZ/DESCRIPTION =================================================================== --- pkg/CHNOSZ/DESCRIPTION 2025-07-25 06:06:38 UTC (rev 932) +++ pkg/CHNOSZ/DESCRIPTION 2025-08-01 03:35:56 UTC (rev 933) @@ -1,4 +1,4 @@ -Date: 2025-07-25 +Date: 2025-08-01 Package: CHNOSZ Version: 2.2.0-3 Title: Thermodynamic Calculations and Diagrams for Geochemistry Modified: pkg/CHNOSZ/R/mosaic.R =================================================================== --- pkg/CHNOSZ/R/mosaic.R 2025-07-25 06:06:38 UTC (rev 932) +++ pkg/CHNOSZ/R/mosaic.R 2025-08-01 03:35:56 UTC (rev 933) @@ -47,7 +47,7 @@ if(length(stable) == 2) { # Use only predominant basis species for mosaic stacking 20220723 stable2.orig <- stable2 <- stable[[2]] - # Why c(1, ? + # Why c(1, ...) ? # The first basis species should always be included (because it has to be swapped out for the others) istable2 <- sort(unique(c(1, as.numeric(stable2)))) for(i in seq_along(istable2)) stable2[stable2.orig == istable2[i]] <- i @@ -152,6 +152,7 @@ } put.basis(allbases[i, ], thislogact) # Load the formed species using the current basis + species(delete = TRUE) species(species0$ispecies, species0$logact) # If mosaic() changes variables on the diagram, argument names for affinity() also have to be changed 20230809 Modified: pkg/CHNOSZ/README.md =================================================================== --- pkg/CHNOSZ/README.md 2025-07-25 06:06:38 UTC (rev 932) +++ pkg/CHNOSZ/README.md 2025-08-01 03:35:56 UTC (rev 933) @@ -1,5 +1,5 @@ -[![CRAN/METACRAN Version](https://img.shields.io/cran/v/CHNOSZ?label=CRAN&color=4bc51e)](https://cran.r-project.org/package=CHNOSZ) +[![CRAN status](https://www.r-pkg.org/badges/version/CHNOSZ)](https://CRAN.R-project.org/package=CHNOSZ) [![R-CMD-check](https://github.com/jedick/CHNOSZ/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jedick/CHNOSZ/actions/workflows/R-CMD-check.yaml) Modified: pkg/CHNOSZ/inst/NEWS.Rd =================================================================== --- pkg/CHNOSZ/inst/NEWS.Rd 2025-07-25 06:06:38 UTC (rev 932) +++ pkg/CHNOSZ/inst/NEWS.Rd 2025-08-01 03:35:56 UTC (rev 933) @@ -22,6 +22,8 @@ \item \code{label.plot()} and \code{label.figure()} now handle logarithmic scales for x and y axes. + \item Fix bug preventing \code{mosaic()} from being used to form \H2O. + } } Modified: pkg/CHNOSZ/inst/tinytest/test-mosaic.R =================================================================== --- pkg/CHNOSZ/inst/tinytest/test-mosaic.R 2025-07-25 06:06:38 UTC (rev 932) +++ pkg/CHNOSZ/inst/tinytest/test-mosaic.R 2025-08-01 03:35:56 UTC (rev 933) @@ -152,3 +152,17 @@ #title(main = "A(single basis species) - A(all basis species)") #legend("topleft", legend = describe.reaction(s1$reaction)) expect_equivalent(as.numeric(Adiff), rep(0, length(Adiff)), info = info) + +# Test added on 20250801 +info <- "mosaic() can be used to form H2O" +# This wasn't working because a call to species(1) (for the species index of H2O) +# failed to replace pre-existing specie definition (for the basis species). +# Now mosaic() uses species(delete = TRUE) to always start with a new species definition. +basis(c("H3PO4", "H4P2O7", "O2", "H+")) +bases <- list( + c("H3PO4", "H2PO4-", "HPO4-2", "PO4-3"), + c("H4P2O7", "H3P2O7-", "H2P2O7-2", "HP2O7-3", "P2O7-4") +) +species("H2O") +m <- mosaic(bases) +expect_identical(m$A.species$species$name, "water", info = info)