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

isXXX methods and integer_valued #3054

Closed
simonbyrne opened this issue May 8, 2013 · 7 comments
Closed

isXXX methods and integer_valued #3054

simonbyrne opened this issue May 8, 2013 · 7 comments

Comments

@simonbyrne
Copy link
Contributor

I guess this can get filed under bikeshedding, but should integer_valued (and real_valued) have an is prefix (like isfinite)? There is already isinteger (testing for an integer type), so should it be isintegervalued?

On a related note, the naming of the isXXX methods are somewhat ambiguous: some are determined by values (e.g. isfinite, isempty, islower, iseven, issym), and some are determined by type (e.g. isinteger, isreal, isbool): perhaps the type ones would be clearer as isXXXtype?

@johnmyleswhite
Copy link
Member

I like all of these ideas, although it's a pretty substantial change.

@JeffBezanson
Copy link
Member

Revisiting this, it now seems reasonable to only have isinteger and isa(x,Integer).

@pao
Copy link
Member

pao commented May 9, 2013

To clarify--isinteger would be the value test, and isa(x, Integer) would be the type test, right?

@JeffBezanson
Copy link
Member

Yes.

@StefanKarpinski
Copy link
Member

+1

@simonbyrne
Copy link
Contributor Author

I should point out that the current isinteger(x) is slightly different than isa(x,Integer) in that it also applies to AbstractArrays, e.g.

isinteger(1:10) == true

This usage matches that of Matlab and Octave. Arguably, such a function is not very "Julian" anyway, in that if you want different behaviour for an integer array, this should be defined at dispatch, and not within a function.

@simonbyrne
Copy link
Contributor Author

I just did a quick scan through base:

  • isinteger isn't used at all
  • isreal is used twice in linalg/dense.jl (once on arrays, once on numbers)
  • iscomplex used quite a bit in linalg, particularly for interfaces to Lapack and factorizations (most of these seem to operate on arrays)
  • isbool is used once in sparse.jl (i'm not sure on this usage, but I assume it is to operate on individual elements).

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

No branches or pull requests

5 participants