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

Replace all references to Fixnum and Bignum with Integer (Fixnum and Bignum are deprecated) #604

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/nmatrix/io/mat5_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize(stream = nil, byte_order = nil, content_or_bytes = nil)
if content_or_bytes.is_a?(String)
@content = content_or_bytes

elsif content_or_bytes.is_a?(Fixnum)
elsif content_or_bytes.is_a?(Integer)
@padded_bytes = content_or_bytes
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/nmatrix/monkeys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Array
# You must provide a shape for the matrix as the first argument.
#
# == Arguments:
# <tt>shape</tt> :: Array describing matrix dimensions (or Fixnum for square).
# <tt>shape</tt> :: Array describing matrix dimensions (or Integer for square).
# If not provided, will be intuited through #shape.
# <tt>dtype</tt> :: Override data type (e.g., to store a Float as :float32
# instead of :float64) -- optional.
Expand All @@ -46,7 +46,7 @@ def to_nm(shape = nil, dtype = nil, stype = :dense)

guess_dtype = ->(type) {
case type
when Fixnum then :int64
when Integer then :int64
Copy link
Member

Choose a reason for hiding this comment

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

This may present a problem further down the road. Bignum can store more than int64, and this method should probably check for overflow and be able to choose :object instead of :int64. I think the solution is probably to make :object the default dtype for Integer.

With that said, I'm not sure this is your job. It's a spec change. It needs additional consideration. I just wanted to mention it here.

when Float then :float64
when Complex then :complex128
end
Expand Down
14 changes: 7 additions & 7 deletions lib/nmatrix/nmatrix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ def pretty_print(q) #:nodoc:
#
# If your dtype is :object and you are converting from :dense to a sparse type, it is recommended that you
# provide a :default, as 0 may behave differently from its Float or Complex equivalent. If no option
# is given, Fixnum 0 will be used.
# is given, Integer 0 will be used.
def cast(*params)
if (params.size > 0 && params[0].is_a?(Hash))
opts = {
Expand Down Expand Up @@ -419,7 +419,7 @@ def to_flat_array

#
# call-seq:
# size -> Fixnum
# size -> Integer
#
# Returns the total size of the NMatrix based on its shape.
#
Expand Down Expand Up @@ -566,12 +566,12 @@ def last
# the new and old shapes' components must be equal.
#
# * *Arguments* :
# - +new_shape+ -> Array of positive Fixnums.
# - +new_shape+ -> Array of positive Integers.
# * *Returns* :
# - A copy with a different shape.
#
def reshape new_shape,*shapes
if new_shape.is_a?Fixnum
if new_shape.is_a?Integer
newer_shape = [new_shape]+shapes
else # new_shape is an Array
newer_shape = new_shape
Expand All @@ -593,13 +593,13 @@ def reshape new_shape,*shapes
# the new and old shapes' components must be equal.
#
# * *Arguments* :
# - +new_shape+ -> Array of positive Fixnums.
# - +new_shape+ -> Array of positive Integer.
#
def reshape! new_shape,*shapes
if self.is_ref?
raise(ArgumentError, "This operation cannot be performed on reference slices")
else
if new_shape.is_a?Fixnum
if new_shape.is_a?Integer
shape = [new_shape]+shapes
else # new_shape is an Array
shape = new_shape
Expand Down Expand Up @@ -690,7 +690,7 @@ def transpose(permute = nil)
#
# * *Arguments* :
# - +matrices+ -> one or more matrices
# - +rank+ -> Fixnum (for rank); alternatively, may use :row, :column, or
# - +rank+ -> Integer (for rank); alternatively, may use :row, :column, or
# :layer for 0, 1, 2, respectively
def concat(*matrices)
rank = nil
Expand Down