rigraph icon indicating copy to clipboard operation
rigraph copied to clipboard

refactor: use assert_character() instead of as.character()

Open maelle opened this issue 1 year ago • 4 comments

maelle avatar May 14 '24 11:05 maelle

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes. Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue label.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

aviator-app[bot] avatar May 14 '24 11:05 aviator-app[bot]

I'm not experienced enough with R to be able to follow the code without considerable time investment, but I wanted to point out that in many cases, numerical vertex IDs or vertex names are auto-converted to characters. This is convenient and probably desirable. I do not know if this change breaks any of the relevant use cases, but it's good to pay attention here.

szhorvat avatar May 14 '24 11:05 szhorvat

@szhorvat thanks! Yes, I'm hoping the revdeps checks would help with that. If this breaks too many things, I won't merge it.

maelle avatar May 14 '24 11:05 maelle

And just another reminder that our users are not just dependent packages, but also individuals who use igraph for research, often interactively. Unfortunately it is difficult to track this second kind of user, even though IMO they are the majority.

szhorvat avatar May 14 '24 11:05 szhorvat

@schochastics curious to hear what you think about this. We might also close the PR.

maelle avatar Mar 25 '25 11:03 maelle

I think this PR is a good idea, because it forces user to be rational on naming attributes. But given that the reprex below currently works, I am not sure if we are opening some pandoras box with it?

library(igraph)
#> 
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#> 
#>     decompose, spectrum
#> The following object is masked from 'package:base':
#> 
#>     union
g <- sample_gnp(10,0.2)
g$`5` <- 4
g
#> IGRAPH 9a520e7 U--- 10 3 -- Erdos-Renyi (gnp) graph
#> + attr: name (g/c), type (g/c), loops (g/l), p (g/n), 5 (g/n)
#> + edges from 9a520e7:
#> [1] 2--3 1--4 1--8
graph_attr(g,5)
#> [1] 4
delete_graph_attr(g,5)
#> IGRAPH 9a520e7 U--- 10 3 -- Erdos-Renyi (gnp) graph
#> + attr: name (g/c), type (g/c), loops (g/l), p (g/n)
#> + edges from 9a520e7:
#> [1] 2--3 1--4 1--8

Created on 2025-03-25 with reprex v2.1.1

schochastics avatar Mar 25 '25 19:03 schochastics

set_graph_attr should also use the assert function

maelle avatar Mar 27 '25 09:03 maelle

Crazy idea: add a lifecycle compatibility layer that doesn't break existing code (which I'd consider off-label use, but keeping compat is a gesture of goodwill)?

krlmlr avatar Apr 03 '25 09:04 krlmlr

Crazy idea: add a lifecycle compatibility layer that doesn't break existing code (which I'd consider off-label use, but keeping compat is a gesture of goodwill)?

can we decide after we've seen the revdeps results?

maelle avatar Apr 09 '25 12:04 maelle

Thanks!

krlmlr avatar Jun 05 '25 09:06 krlmlr