Open RobinHankin opened 1 year ago
Might be better to enforce disordR
discipline from the dependent packages, see:
https://github.com/RobinHankin/stokes/commit/76d9d20fb3ed54d9ad77fcac724d3a2a112814c6
I have started work on the dismat
package which might resolve this.
Obervation: a note at spray.Rd
states that index()
breaks disordR
discipline.
I have been reminding myself about the dismat package, https://github.com/RobinHankin/dismat, which emphasises rownames and colnames of matrices when multiplying them. But index()
returns a matrix with no dimnames
attribute. It might be better to create a new class of matrices that does everything regular R matrices do, but forbids idiom such as M[1,]
.
Note that the columns have no such problem (not being affected by disordR
discipline), and idiom such as M[,1]
is fine.
If we wanted some disord-type functionality for index()
then the following should work:
library("spray")
#>
#> Attaching package: 'spray'
#> The following objects are masked from 'package:base':
#>
#> pmax, pmin
(a <- rspray())
#> val
#> 0 1 1 = 9
#> 2 0 1 = 6
#> 0 1 0 = 7
#> 0 0 1 = 5
#> 2 2 2 = 4
#> 0 1 2 = 3
#> 1 1 1 = 10
#> 2 2 0 = 1
cbind(index(a),coeffs(a))
#> rbind() and cbind() not currently implemented for disord objects (even if the hash codes match)
#>
#> disordR discipline error in:
#> NULL
#> Error in check_matching_hash(x, y):
#> cannot combine disord object with hash code 86a85578733844f47c46e1f2623ebaef0cefdec0 with a vector
[note the sub-optimal error message]. We would need index()
to return an object with a hash code that would have to match that of coeffs(a)
for the cbind()
to work. Also note that the columns are not subject to any disord-type discipline.
And I am not sure what to do about it.
Created on 2023-07-01 with reprex v2.0.2
Above, trying to extract the first element of
coeffs(A)
correctly throws an error. But trying to find the first row ofindex(A)
returns a result which is technically implementation-specific.