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

Avoid type promotion in increment/decrement #27

Merged
merged 1 commit into from
Mar 20, 2024

Conversation

dmbates
Copy link
Contributor

@dmbates dmbates commented Mar 19, 2024

An operation on an integer array, mat, like

mat .+ 1

will promote the eltype of the result to Int64. A safer way of doing this so as to avoid needless promotion of types is

mat .+ true

because true the Bool value will always be promoted to eltype(mat).

An in-place increment/decrement operation can safely be written as

mat .+= 1

because it is in-place

While making these changes I also changed the Project.toml file to allow later versions of CategoricalArrays and added [extras] and [targets] sections which can replace test/Project.toml. Finally I rewrote the make_testvalues function in test/index.jl to use a comprehension.

@ilia-kats ilia-kats merged commit cbe74a1 into scverse:main Mar 20, 2024
3 checks passed
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.

2 participants