Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove deprecated functions before 1.0 #1352

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Conversation

Antonov548
Copy link
Contributor

@Antonov548 Antonov548 commented May 2, 2024

Deprecated

Updated

R side

  • hub_score() - added hits_scores. hub_score is deprecated and use hits_scores under the hood.
  • authority_score() - added hits_scores. authority_score is deprecated and use hits_scores under the hood.
  • make_lattice() - use square_lattice(). circular parameter is deprecated. Added periodic parameter. periodic should be logical vector with same length as dim or single value which will be converted to vector.
  • laplacian_matrix - use generated get_laplacian_sparse_impl and get_laplacian_impl instead of R_igraph_laplacian. normalized argument is deprecated with new normalization argument.
  • igraph_erdos_renyi_game() — not used in R.
  • igraph_random_edge_walk() — updated random_edge_walk to use random_walk_impl with edges return.

Copy link
Contributor

aviator-app bot commented May 2, 2024

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.

@Antonov548
Copy link
Contributor Author

@krlmlr
This is related to igraph/igraph#2575 (comment)

Is it right that we should just remove deprecated functions?

@Antonov548 Antonov548 changed the title chore: remove deprecated functions before 1.0 feat: remove deprecated functions before 1.0 May 2, 2024
@szhorvat
Copy link
Member

szhorvat commented May 2, 2024

I edited the top post and added information on what can / should be done.

NAMESPACE Outdated
@@ -483,8 +481,7 @@ export(hrg.fit)
export(hrg.game)
export(hrg.predict)
export(hrg_tree)
export(hub.score)
export(hub_score)
export(hub_and_authority_scores)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest hits_scores() here, see comment I linked

@Antonov548
Copy link
Contributor Author

I edited the top post and added information on what can / should be done.

Thanks!

@szhorvat
Copy link
Member

szhorvat commented May 2, 2024

Let me know if you need input here, for example on what parameters to set in the new function to get the behaviour of the old one.


Regarding hub and authority scores, I expect that removing these without deprecation would cause quite the uproar. What could be done is to implement hub_score() and authority_score() in pure R in terms of hits_scores() and keep them deprecated for a while.

There will also be another change in these two functions, as well as eigen_centrality() in 1.0: the scale parameter will be removed, and the function will always behave as if scale=TRUE was set. I'll open a new issue for preparing for this change, but I suggest NOT to expose the scale parameter at all when introducing hits_scores().

@Antonov548
Copy link
Contributor Author

@szhorvat

  • I think we still need to remove hub_score() and authority_score() because implementing same functions, but using hits_scores() still break interface on R side, so maybe it worth just to remove them.

  • Should then functions which are using igraph_get_laplacian to be extended with additional argument mode?

@szhorvat
Copy link
Member

szhorvat commented May 3, 2024

  • I think we still need to remove hub_score() and authority_score() because implementing same functions, but using hits_scores() still break interface on R side, so maybe it worth just to remove them.

Why would it break the interface? hits_scores() returns both scores. Just drop one and rewrite the result to the format that hub_score() used to return.

As for the scale parameter, allow the parameter but ignore its value. We never made any promises about the type of scaling used with scale=FALSE.

@Antonov548
Copy link
Contributor Author

  • I think we still need to remove hub_score() and authority_score() because implementing same functions, but using hits_scores() still break interface on R side, so maybe it worth just to remove them.

Why would it break the interface? hits_scores() returns both scores. Just drop one and rewrite the result to the format that hub_score() used to return.

As for the scale parameter, allow the parameter but ignore its value. We never made any promises about the type of scaling used with scale=FALSE.

Because hub_score() and authority score() returns not just a vector. Of course we can maybe try to keep previous behavior by creating the similar list.
https://github.com/igraph/rigraph/pull/1352/files#diff-aa8edbd6189f5557d42166c470f065672ba52363e61d84dcd7bd3200c3b3420cL3860-L3862

Sorry, I didn't get regarding laplacian. It has also mode=c("out", "in", "all", "total") and igraph_laplacian hasn't this argument.

@szhorvat
Copy link
Member

szhorvat commented May 3, 2024

  • Should then functions which are using igraph_get_laplacian to be extended with additional argument mode?

This will require a somewhat breaking change (which is why I kept pushing to do this for 2.0...)

The big change is not mode but the normalization parameter, which is NOT the same as normalized. The old igraph_laplacian() normalized in an inconsistent way. You can see what it did here:

https://github.com/igraph/igraph/blob/223fd0e2c11b4c0a35452ffa68347206771dc0b4/src/properties/spectral.c#L403-L431

We need to transition from the old boolean normalized to the new normalization in some way. I'm not sure what the customary way is in R. I guess we can temporarily have both normalized and normalization at the same time. Deprecate normalized, i.e. any explicit use of normalized should trigger a deprecation warning. I'm not sure what to do when the user passes both normalized and normalization at the same time: I guess throw an error since this makes no sense?

@szhorvat
Copy link
Member

szhorvat commented May 3, 2024

Re hub and authority scores:

Currently the function returns a list with many named elements. The main result is in $vector. hits_scores() would return the same, except that instead of vector it'd have both $hub and $authority. hub_score() would call hits_scores(), would remove $authority and would rename $hub to $vector. The rest of the entries are the same between the two functions.

Is there anything I'm missing that may continue to be a problem?

@szhorvat
Copy link
Member

szhorvat commented May 8, 2024

I notice you were working on make_lattice. Please see this before going ahead: #994

The R interface shouldn't always directly mirror the raw C interface. The periodic parameter should accept either a single logical value or a vector. The circular parameter probably shouldn't be removed immediately, breaking compatibility, but should go through a gradual deprecation.

@Antonov548
Copy link
Contributor Author

I notice you were working on make_lattice. Please see this before going ahead: #994

The R interface shouldn't always directly mirror the raw C interface. The periodic parameter should accept either a single logical value or a vector. The circular parameter probably shouldn't be removed immediately, breaking compatibility, but should go through a gradual deprecation.

Sure. I think derpecation of old parameter name is quite easy.

Can you clarify please about single logical value or a vector? You mean it should be handled on R side?
Because in core as I understood it could be NULL or vector with exact same length as dimension.

@szhorvat
Copy link
Member

szhorvat commented May 8, 2024

Can you clarify please about single logical value or a vector? You mean it should be handled on R side?
Because in core as I understood it could be NULL or vector with exact same length as dimension.

Yes, it should be handled in R. I would not allow NULL at all. Instead:

  • it's either a logical vector of the same length as the dimension (which can be sent directly to C)
  • or a logical scalar, which will be replicated dimension times (which can't be implemented in C, so needs to be handled in R)

The default should be FALSE.

This is both very convenient (in most cases people will pass a scalar only) and it is compatible with how the old circular parameter behaved.

@szhorvat
Copy link
Member

szhorvat commented May 8, 2024

In the top post I linked to relevant issues where I tried to describe what's needed for the non-trivial upgrades. If anything's unclear (as in this case) please ask :-)

R/make.R Outdated
Comment on lines 1048 to 1050
#' @param circular Logical, if `TRUE` the lattice or ring will be
#' circular.
#' @param periodic Logical vector, Boolean vector, defines whether the generated lattice is
#' periodic along each dimension. This parameter may also be `NULL`, which
#' implies that the lattice will not be periodic.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docs need an update to match the new interface. The new interface looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szhorvat Do you mean description in the make.R of this function? Is current desciption not valid anymore?

#' `make_lattice()` is a flexible function, it can create lattices of
#' arbitrary dimensions, periodic or aperiodic ones. It has two
#' forms. In the first form you only supply `dimvector`, but not
#' `length` and `dim`. In the second form you omit
#' `dimvector` and supply `length` and `dim`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically the change I am commenting on is not valid anymore. It says that the parameter value has to be a logical vector or NULL, but in fact it is either a logical vector or a logical scalar, with specific interpretation for each.

@Antonov548
Copy link
Contributor Author

@maelle
May I ask you to help with documentation in this PR? I trying to update documentation and have error:

✖ In topic 'authority_score.Rd': Skipping; no name and/or title.
✖ In topic 'hub_score.Rd': Skipping; no name and/or title.

I don't get what is missing in documentation, mentioned functions have rdname.

@maelle maelle added this to the 2.0.4 milestone May 23, 2024
@maelle
Copy link
Contributor

maelle commented May 23, 2024

I'll come back to this next week!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants