HenrikBengtsson / R.devices

🎨 R package: Unified Handling of Graphics Devices
https://henrikbengtsson.github.io/R.devices/
18 stars 5 forks source link

capturePlot.R fails on PPC #40

Open barracuda156 opened 1 year ago

barracuda156 commented 1 year ago
  Running ‘capturePlot.R’
 ERROR
Running the tests in ‘tests/capturePlot.R’ failed.
Last 13 lines of output:
  [1] "powerpc"

  $ptrsize
  [1] 4

  $endian
  [1] "big"

  - replay
  - display
  - toDefault()
  - devEval()
  Error in value[[3L]](cond) : invalid graphics state
  Calls: devEval ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
  Execution halted

R version 4.2.2 (2022-10-31) -- "Innocent and Trusting"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: powerpc-apple-darwin10.8.0 (32-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library("R.devices")
R.devices v2.17.1 successfully loaded. See ?R.devices for help.
> 
> message("*** capturePlot() ...")
*** capturePlot() ...
> 
> cat("Default graphics device:\n")
Default graphics device:
> str(getOption("device"))
function (file = if (onefile) "Rplots.pdf" else "Rplot%03d.pdf", width, 
    height, onefile, family, title, fonts, version, paper, encoding, bg, 
    fg, pointsize, pagecentre, colormodel, useDingbats, useKerning, fillOddEven, 
    compress)  
> 
> message("*** capturePlot() - as.architecture() ...")
*** capturePlot() - as.architecture() ...
> 
> path <- system.file("exdata", package="R.devices")
> pattern <- "^capturePlot,.*[.]rds$"
> pathnames <- dir(path=path, pattern=pattern, full.names=TRUE)
> 
> for (kk in seq_along(pathnames)) {
+   pathname <- pathnames[kk]
+   message(sprintf("- File #%d ('%s') ...", kk, pathname))
+   
+   g <- readRDS(pathname)
+   arch <- architecture(g)
+   str(arch)
+ 
+   ## Currently, as.architecture() cannot coerce endianess
+   if (arch$endian == .Platform$endian) {
+     ## Currently, as.architecture() cannot change pointer size
+ #   if (arch$ptrsize == .Machine$sizeof.pointer) {
+       g8_1 <- as.architecture(g, ptrsize=8L)
+       arch8_1 <- architecture(g8_1)
+       str(arch8_1)
+     
+       g8_1b <- as.architecture(g8_1, ptrsize=8L)
+       arch8_1b <- architecture(g8_1b)
+       str(arch8_1b)
+       stopifnot(identical(arch8_1b, arch8_1))
+       stopifnot(identical(g8_1b, g8_1))
+     
+       g4_1 <- as.architecture(g8_1, ptrsize=4L)
+       arch4_1 <- architecture(g4_1)
+       str(arch4_1)
+     
+       g8_2 <- as.architecture(g4_1, ptrsize=8L)
+       arch8_2 <- architecture(g8_2)
+       str(arch8_2)
+       stopifnot(identical(g8_2, g8_1))
+     
+       g_2 <- as.architecture(g)
+       arch_2 <- architecture(g_2)
+       str(arch_2)
+     
+       if (getRversion() >= "3.3.0") {
+         try(replayPlot(g_2))
+       }
+ #   } ## if (arch$ptrsize == .Machine$sizeof.pointer)
+   } ## if (arch$endian == .Platform$endian)
+ } ## for (kk ...)
- File #1 ('/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-R.devices/R-R.devices/work/R.devices-2.17.1/R.devices.Rcheck/R.devices/exdata/capturePlot,engine=11,ostype=unix,arch=i686,ptrsize=4,endian=little.rds') ...
List of 4
 $ ostype : chr "unix"
 $ arch   : chr "i686"
 $ ptrsize: int 4
 $ endian : chr "little"
- File #2 ('/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-R.devices/R-R.devices/work/R.devices-2.17.1/R.devices.Rcheck/R.devices/exdata/capturePlot,engine=11,ostype=unix,arch=x86_64,ptrsize=8,endian=little.rds') ...
List of 4
 $ ostype : chr "unix"
 $ arch   : chr "x86_64"
 $ ptrsize: int 8
 $ endian : chr "little"
- File #3 ('/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-R.devices/R-R.devices/work/R.devices-2.17.1/R.devices.Rcheck/R.devices/exdata/capturePlot,engine=11,ostype=windows,arch=i386,ptrsize=4,endian=little.rds') ...
List of 4
 $ ostype : chr "windows"
 $ arch   : chr "i386"
 $ ptrsize: int 4
 $ endian : chr "little"
- File #4 ('/opt/local/var/macports/build/_opt_PPCRosettaPorts_R_R-R.devices/R-R.devices/work/R.devices-2.17.1/R.devices.Rcheck/R.devices/exdata/capturePlot,engine=11,ostype=windows,arch=x86_64,ptrsize=8,endian=little.rds') ...
List of 4
 $ ostype : chr "windows"
 $ arch   : chr "x86_64"
 $ ptrsize: int 8
 $ endian : chr "little"
> 
> message("*** capturePlot() - as.architecture() ... DONE")
*** capturePlot() - as.architecture() ... DONE
> 
> message("*** capturePlot() - capture and replay ...")
*** capturePlot() - capture and replay ...
> 
> if (getRversion() >= "3.3.0") {
+   message("- capture")
+   g <- capturePlot({
+     plot(1:10)
+   })
+ 
+   message("- system information")
+   system <- attr(g, "system")
+   print(system)
+ 
+   message("- saving")
+   ## Record for troubleshooting
+   tags <- sprintf("%s=%s", names(system), system)
+   pathname <- sprintf("capturePlot,%s.rds", paste(tags, collapse=","))
+   saveRDS(g, file=pathname)
+ 
+   message("- architecture")
+   print(architecture(g))
+ 
+   message("- replay")
+   ## Replay
+   replayPlot(g)
+ 
+   message("- display")
+   ## Display
+   print(g)
+ 
+   message("- toDefault()")
+   ## Display with a 2/3 aspect ratio
+   toDefault(aspectRatio=2/3, print(g))
+ 
+   message("- devEval()")
+   ## Redraw to many output formats
+   devEval(c("{png}", "{eps}", "{pdf}"), aspectRatio=2/3, print(g))
+ 
+ } ## if (getRversion() >= "3.3.0")
- capture
- system information
$ostype
[1] "unix"

$arch
[1] "powerpc"

$ptrsize
[1] 4

$endian
[1] "big"

- saving
- architecture
$ostype
[1] "unix"

$arch
[1] "powerpc"

$ptrsize
[1] 4

$endian
[1] "big"

- replay
- display
- toDefault()
- devEval()
Error in value[[3L]](cond) : invalid graphics state
Calls: devEval ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
barracuda156 commented 1 year ago

@HenrikBengtsson Or is it simply because there is not PPC here? https://github.com/HenrikBengtsson/R.devices/tree/develop/inst/exdata