Sha256: d1cde600b652cbafc2a350bc7c1969086cdf63d3dce1b82f5dfac08fceeb2414

Contents?: true

Size: 782 Bytes

Versions: 17

Compression:

Stored size: 782 Bytes

Contents

require "narray"

class NArray

  @@dump_size_limit = -1  # max len to allow dump / no limit if negative
  def self.dump_size_limit=(lmt)
    @@dump_size_limit = lmt
  end
  def self.dump_size_limit
    @@dump_size_limit
  end

  def self.endian
    NArray[1].to_s[1] == 1 ? :little : :big
  end

  def _dump(limit)
    if (@@dump_size_limit <= 0) || (size <= @@dump_size_limit)
      Marshal.dump([typecode, shape, NArray.endian, to_s])
    else
      raise "size of the NArray (#{size}) is too large to dump "+
            "(limit: #{DUMP_SIZE_LIMIT})"
    end
  end

  def self._load(str)
    ary = Marshal.load(str)
    typecode, shape, endian, str = ary
    na = NArray.to_na(str, typecode, *shape)
    na = na.swap_byte unless endian == NArray.endian
    return na
  end

end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gphys-1.5.6 lib/numru/gphys/narray_ext.rb
gphys-1.5.5 lib/numru/gphys/narray_ext.rb
gphys-1.5.4 lib/numru/gphys/narray_ext.rb
gphys-1.5.3 lib/numru/gphys/narray_ext.rb
gphys-1.5.2 lib/numru/gphys/narray_ext.rb
gphys-1.5.1 lib/numru/gphys/narray_ext.rb
gphys-1.5.0 lib/numru/gphys/narray_ext.rb
gphys-1.4.3.2 lib/numru/gphys/narray_ext.rb
gphys-1.4.3.1 lib/numru/gphys/narray_ext.rb
gphys-1.4.3 lib/numru/gphys/narray_ext.rb
gentooboontoo-gphys-1.3.1.1 lib/numru/gphys/narray_ext.rb
gphys-1.2.2.1a lib/numru/gphys/narray_ext.rb
gphys-1.2.2.1 lib/numru/gphys/narray_ext.rb
gphys-1.2.2 lib/numru/gphys/narray_ext.rb
gphys-1.1.1b lib/numru/gphys/narray_ext.rb
gphys-1.1.1a lib/numru/gphys/narray_ext.rb
gphys-1.1.1 lib/numru/gphys/narray_ext.rb