source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/props_template_spec.rb
Ruby
mit
199
main
9,223
require_relative "support/helper" require_relative "support/rails_helper" RSpec.describe "Props::Base" do it "initializes" do expect { Props::Base.new }.to_not raise_error end context "result!" do it "returns {} when empty" do json = Props::Base.new expect(json.result!.strip).to eq...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/prop_template_search_spec.rb
Ruby
mit
199
main
16,747
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe("searching the template") do before do @controller.request.path = "/some_url" end it "finds the correct node and merges it to the top" do json = render(<<~PROPS) json.data(dig: ['data', 'comment', 'detai...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/traveled_path_spec.rb
Ruby
mit
199
main
603
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template" do before do @controller.request.path = "/some_url" end it "returns the path of the node its called from" do json = render(<<~PROPS) json.data do json.comment do json....
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/partial_defer_extension_spec.rb
Ruby
mit
199
main
1,931
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template fragments" do before do Rails.cache.clear @controller.request.path = "/some_url" end it "defers work together with partials" do json = render(<<~PROPS) json.outer do json.inn...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/partial_render_spec.rb
Ruby
mit
199
main
9,597
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template" do it "renders on actionview" do json = render(<<~PROPS) json.hello 'world' PROPS expect(json).to eql_json({ hello: "world" }) end # it 'renders json escaped keys' do #...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/defer_extension_spec.rb
Ruby
mit
199
main
13,578
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template" do before do Rails.cache.clear @controller.request.path = "/some_url" end it "defers a block from loading" do json = render(<<~PROPS) json.outer do json.inner(defer: :auto) ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/rails_cache_spec.rb
Ruby
mit
199
main
6,556
require_relative "../support/helper" require_relative "../support/rails_helper" require "active_support/testing/time_helpers" require "active_support/core_ext/string" RSpec.describe "Props::Template caching" do include ActiveSupport::Testing::TimeHelpers before do Rails.cache.clear end it "caches an obje...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/partial_patch_spec.rb
Ruby
mit
199
main
520
require_relative "../support/helper" require_relative "../support/rails_helper" require "props_template/partial_patch" require "action_controller" RSpec.describe "Props::Template partial patch" do it "renders with a partial and layout" do result = @controller.render(partial: "comment", layout: "stream_message")....
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/key_extension_spec.rb
Ruby
mit
199
main
1,816
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template key extension" do it "renders an array of items with id using :key as the method_name" do json = render(<<~PROPS) klass = Struct.new(:email, :id) users = [ klass.new('joe@red.com',...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/extensions/fragments_spec.rb
Ruby
mit
199
main
6,102
require_relative "../support/helper" require_relative "../support/rails_helper" RSpec.describe "Props::Template fragments" do it "renders with a partial and populates fragments" do json = render(<<~PROPS) json.outer do json.inner(partial: ['simple', fragment: :simple]) do end json....
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
spec/support/rails_helper.rb
Ruby
mit
199
main
2,367
require "active_support" require "active_support/core_ext/array/access" require "active_support/core_ext/class/attribute_accessors" require "active_support/cache/memory_store" require "active_support/json" require "minitest" require "action_view" require "action_view/testing/resolvers" require "action_view/template/re...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template.rb
Ruby
mit
199
main
2,404
require "props_template/base" require "props_template/extensions/partial_renderer" require "props_template/extensions/cache" require "props_template/extensions/deferment" require "props_template/extensions/fragment" require "props_template/base_with_extensions" require "props_template/extension_manager" require "active...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/generators/props/views/views_generator.rb
Ruby
mit
199
main
1,685
require "rails/generators/named_base" require "rails/generators/resource_helpers" module Props module Generators class ViewsGenerator < Rails::Generators::NamedBase include Rails::Generators::ResourceHelpers source_root File.expand_path("../templates", __dir__) argument :attributes, type: :ar...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/handler.rb
Ruby
mit
199
main
473
require "active_support" module Props class Handler cattr_accessor :default_format self.default_format = :json def self.call(template, source = nil) source ||= template.source # this juggling is required to keep line numbers right in the error %{ __finalize = @__json.nil?; @__json ||= ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/base.rb
Ruby
mit
199
main
3,668
require "oj" require "active_support" module Props class InvalidScopeForArrayError < StandardError; end class InvalidScopeForObjError < StandardError; end class InvalidScopeForChildError < StandardError; end class Base attr_accessor :item_context def initialize(encoder = nil) @stream = Oj::St...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/layout_patch.rb
Ruby
mit
199
main
1,059
module Props module LayoutPatch def render_template(view, template, layout_name, locals) if !view.respond_to?(:active_template_virtual_path) && template.respond_to?(:virtual_path) view.instance_eval <<~RUBY, __FILE__, __LINE__ + 1 def active_template_virtual_path; @_active_template_virtual...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/searcher.rb
Ruby
mit
199
main
3,856
module Props class Searcher attr_reader :builder, :context, :fragments, :traveled_path def initialize(builder, path = [], context = nil) @search_path = path @depth = 0 @context = context @found_block = nil @found_options = nil @builder = builder @traveled_path = [] ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/railtie.rb
Ruby
mit
199
main
787
require "rails/railtie" require "props_template" module Props class Railtie < ::Rails::Railtie initializer :props_template do ActiveSupport.on_load :action_view do ActionView::Template.register_template_handler :props, Props::Handler ActionView::Base.include Props::Helper require "p...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/dependency_tracker.rb
Ruby
mit
199
main
1,363
# This was taken from jbuilder require "props_template" dependency_tracker = false begin require "action_view" require "action_view/dependency_tracker" dependency_tracker = ::ActionView::DependencyTracker rescue LoadError begin require "cache_digests" dependency_tracker = ::CacheDigests::DependencyTra...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/extension_manager.rb
Ruby
mit
199
main
2,908
module Props class ExtensionManager attr_reader :base, :builder, :context, :cache, :partialer delegate :load_cache, to: :cache delegate :find_and_add_template, to: :partialer def initialize(base, defered = [], fragments = []) @base = base @context = base.context @builder = base.bui...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/options.rb
Ruby
mit
199
main
940
module Props class Options < Hash class InvalidOptionError < StandardError; end def partial(partial_name, opts = {}) self[:partial] = [partial_name, opts] self end def defer(type, placeholder: {}, **opts) self[:defer] = [type, {placeholder: placeholder}.merge(opts)] self ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/partial_patch.rb
Ruby
mit
199
main
1,126
module Props module PartialPatch def render(partial, context, block) template = find_template(partial, template_keys(partial)) if !block && (layout = @options[:layout]) layout = find_template(layout.to_s, template_keys(partial)) end if template.respond_to?(:handler) && template.h...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/base_with_extensions.rb
Ruby
mit
199
main
2,392
module Props class BaseWithExtensions < Base attr_reader :builder, :context, :fragments, :traveled_path, :deferred, :stream def initialize(builder, context = nil, options = {}) @context = context @builder = builder @em = ExtensionManager.new(self) @traveled_path = [] super() ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/core_ext.rb
Ruby
mit
199
main
365
module Props module Extensions module Array module Member def member_at(index) at(index) end def member_by(attribute, value) raise NotImplementedError, "Implement member_by(attr, value) in your own delegate" end end end end end class Array ...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/extensions/fragment.rb
Ruby
mit
199
main
921
module Props class Fragment attr_reader :fragments def initialize(base, fragments = []) @base = base @fragments = fragments end def self.fragment_name_from_options(options, item = nil) return if !options[:partial] _, partial_opts = [*options[:partial]] return unless pa...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/extensions/deferment.rb
Ruby
mit
199
main
1,476
module Props class Deferment attr_reader :deferred, :disabled def initialize(base, deferred = []) @deferred = deferred @base = base @disabled = false end def disable! @disabled = true end def refine_options(options, item = nil) options.clone end def ex...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/extensions/cache.rb
Ruby
mit
199
main
2,684
module Props class Cache delegate :controller, :safe_concat, to: :@context attr_reader :results def initialize(context) @context = context @results = {} end def self.normalize_options(options, item = nil) key, rest = [*options] rest ||= {} if item && ::Proc === ke...
github
thoughtbot/props_template
https://github.com/thoughtbot/props_template
lib/props_template/extensions/partial_renderer.rb
Ruby
mit
199
main
4,451
require "action_view" module Props class RenderedTemplate attr_reader :body, :layout, :template def initialize(body, layout, template) @body = body @layout = layout @template = template end def format template.format end end class Partialer INVALID_PARTIAL_MESSA...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
Gemfile
Ruby
mit
199
main
761
source "https://rubygems.org" git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } # Specify your gem's dependencies in charty.gemspec gemspec group :development, :test do gem "bundler", ">= 1.16" gem "csv" gem "daru" gem "fiddle" gem "iruby", ">= 0.7.0" gem "matrix" # need for daru on Ru...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
charty.gemspec
Ruby
mit
199
main
1,354
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "charty/version" Gem::Specification.new do |spec| spec.name = "charty" version_components = [ Charty::Version::MAJOR.to_s, Charty::Version::MINOR.to_s, Charty::Version::MICRO.to_s, Ch...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/index_test.rb
Ruby
mit
199
main
11,776
class IndexTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("#union") do sub_test_case("arrays") do def test_union index_a = Charty::Index.new([1, 2, 3, 4, 5]) index_b = Charty::Index.new([4, 5, 6, 7, 8]) assert_equal([ [1, 2, 3, 4, 5], ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table_adapters_test.rb
Ruby
mit
199
main
2,592
class TableAdaptersTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case(".find_adapter_class") do test("for a hash of arrays") do data = { "foo" => [1, 2, 3, 4], "bar" => [5, 6, 7, 8], } assert_equal(Charty::TableAdapters::HashAdapter, ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/backends_test.rb
Ruby
mit
199
main
805
require "load_error_backend" class BackendsTest < Test::Unit::TestCase sub_test_case(".find_backend_class") do test("find by symbol") do backend_class = Charty::Backends.find_backend_class(:plotly) assert_equal(Charty::Backends::Plotly, backend_class) end test("find by string") do back...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/util_test.rb
Ruby
mit
199
main
1,913
class UtilTest < Test::Unit::TestCase sub_test_case(".filter_map") do test("for array") do assert_equal([20, 40, 60, 80], Charty::Util.filter_map([1, 2, 3, 4, 5, 6, 7, 8, 9]) {|x| x*10 if x.even? }) end test("for range") do assert_equal([20, 40, 60, 80], ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/helper.rb
Ruby
mit
199
main
5,419
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) require "charty" require "test/unit" require "tmpdir" require "active_record" require "bigdecimal" require "csv" require "daru" require "datasets" require "set" # NOTE: daru needs set require "iruby" require "iruby/logger" IRuby.logger = Logger.new(STDERR, le...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plotter_test.rb
Ruby
mit
199
main
944
class PlotterTest < Test::Unit::TestCase def setup @plotter = Charty::Plotter.new(:plotly) @data = { foo: [1, 2, 3, 4, 5, 6, 7], square: [1, 4, 9, 16, 25, 36, 49], cubic: [1, 8, 27, 64, 125, 216, 343], } end test("#table=") do @plotter.table = @da...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/dash_pattern_generator_test.rb
Ruby
mit
199
main
2,003
class DashPatternGeneratorTest < Test::Unit::TestCase def setup # Generated by the following python code: # [list(x) if x else x for x in seaborn._core.unique_dashes(30)] @expected_dashes = [ "", [4, 1.5], [1, 1], [3, 1.25, 1.5, 1.25], [5, 1, 1, 1], [3, 1.25, 1.25, 1.25...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/run.rb
Ruby
mit
199
main
358
#!/usr/bin/env ruby # TODO # $VERBOSE = true require "pathname" base_dir = Pathname(__dir__).parent.expand_path lib_dir = base_dir + "lib" test_dir = base_dir + "test" test_lib_dir = test_dir + "lib" $LOAD_PATH.unshift(lib_dir.to_s) $LOAD_PATH.unshift(test_lib_dir.to_s) require_relative "helper" exit(Test::Unit:...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/backends/plotly_test.rb
Ruby
mit
199
main
7,380
class BackendsPlotlyTest < Test::Unit::TestCase include Charty::TestHelpers include Charty::RenderingTestHelpers PNG_HEADER = "\x89PNG\x0D\x0A\x1A\x0A".b JPEG_MARKERS = ["\xFF\xD8".b, "\xFF\xD9".b] sub_test_case("#render") do sub_test_case("render not for notebook") do sub_test_case("without forma...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/narray_test.rb
Ruby
mit
199
main
7,492
class TableNArrayTest < Test::Unit::TestCase include Charty::TestHelpers def setup numo_required end sub_test_case("an array of vectors as records") do def setup super @data = [ Numo::DFloat[1, 2, 3, 4], Numo::DFloat[5, 6, 7, 8], ] @table...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_melt_test.rb
Ruby
mit
199
main
3,306
class TableMeltTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("generic table data") do data(:adapter_type, [:array_hash, :daru, :pandas], keep: true) data(:key_type, [:string, :symbol], keep: true) def test_melt_without_id_vars(data) setup_table(data[:adapter_type], dat...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/nmatrix_test.rb
Ruby
mit
199
main
7,108
class TableNMatrixTest < Test::Unit::TestCase include Charty::TestHelpers def setup nmatrix_required end sub_test_case("an array of vectors as records") do def setup super @data = [ NMatrix[1, 2, 3, 4], NMatrix[5, 6, 7, 8], ] @table = Cha...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_aref_test.rb
Ruby
mit
199
main
7,307
class TableArefTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("generic table data") do data(:adapter_type, [:array_hash, :daru, :pandas], keep: true) data(:key_type, [:string, :symbol], keep: true) def test_aref_by_string(data) table = setup_table(data[:adapter_type], d...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/pandas_test.rb
Ruby
mit
199
main
2,560
class TablePandasTest < Test::Unit::TestCase include Charty::TestHelpers def setup pandas_required @data = Pandas::DataFrame.new(data: [[1, 2, 3], [4, 5, 6]], columns: ["a", "b", "c"]) @table = Charty::Table.new(@data) end test("#column_names") do assert_equal(["a", "b", "c"], ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_sort_values_test.rb
Ruby
mit
199
main
5,431
class TableSortValuesTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("generic case") do data(:table_adapter, [:daru, :hash, :pandas], keep: true) def test_with_one_column(data) setup_table(data[:table_adapter]) assert_equal(@expected_one_column, @table.s...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_group_by_test.rb
Ruby
mit
199
main
7,094
class TableGroupByTest < Test::Unit::TestCase include Charty::TestHelpers data(:table_adapter, [:daru, :hash, :datasets, :pandas], keep: true) def test_class(data) setup_table(data[:table_adapter]) expected_class = group_by_class(data[:table_adapter]) assert_equal(expected_class, @ta...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/arrow_test.rb
Ruby
mit
199
main
3,388
class TableArrowTest < Test::Unit::TestCase include Charty::TestHelpers def setup arrow_required @data = Arrow::Table.new(a: [1, 2, 3, 4], b: [5, 6, 7, 8], c: [9, 10, 11, 12]) @table = Charty::Table.new(@data) end test("#column_names") do ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_equality_test.rb
Ruby
mit
199
main
5,859
class TableEqualityTest < Test::Unit::TestCase include Charty::TestHelpers data(:adapter_type, [:array_hash, :daru, :narray_hash, :nmatrix_hash, :numpy_hash, :pandas], keep: true) data(:other_adapter_type, [:array_hash, :daru, :narray_hash, :nmatrix_hash, :numpy_hash, :pandas], keep: true) def test_equal...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/activerecord_test.rb
Ruby
mit
199
main
8,854
class TableActiveRecordTest < Test::Unit::TestCase class TestRecord < ActiveRecord::Base end class TestRecordMigration < ActiveRecord::Migration[5.2] self.verbose = false def change create_table :test_records, id: false do |t| t.bigint :id, null: false, primary_key: true t.string :...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_reset_index_test.rb
Ruby
mit
199
main
3,221
class TableResetIndexTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("with unnamed index") do data(:table_adapter, [:daru, :hash, :pandas], keep: true) def test_reset_index(data) setup_table(data[:table_adapter]) assert_equal(@expected_result, @table.res...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/hash_test.rb
Ruby
mit
199
main
8,639
class TableHashTest < Test::Unit::TestCase include Charty::TestHelpers def setup @data = { foo: [1, 2, 3, 4, 5], bar: [10, 20, 30, 40, 50], baz: [100, 200, 300, 400, 500], } @table = Charty::Table.new(@data) end sub_test_case(".new") do sub_test_case("with an array of Charty:...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/red_datasets_test.rb
Ruby
mit
199
main
8,041
class TableRedDatasetsTest < Test::Unit::TestCase sub_test_case("CIFAR") do def setup @data = Datasets::CIFAR.new @table = Charty::Table.new(@data) end test("#column_names") do assert_equal([ :data, :label, :pixels, ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/daru_test.rb
Ruby
mit
199
main
5,785
class TableDaruTest < Test::Unit::TestCase def setup @data = Daru::DataFrame.new( "Beer" => [ "Kingfisher", "Snow", "Bud Light", "Tiger Beer", "Budweiser", ], "Gallons sold" => [ ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/csv_test.rb
Ruby
mit
199
main
579
class TableCSVTest < Test::Unit::TestCase def setup @data = CSV.parse(<<END_CSV, headers: true, converters: :all) foo,bar,baz 1,aaa,2021-01-02 2,bbb,2021-01-01 3,aaa,2021-01-04 4,ccc,2021-01-13 5,ccc,2021-01-20 6,aaa,2021-02-08 7,bbb,2021-02-23 8,ccc,2021-03-01 9,aaa,2021-02-28 10,ccc,2021-03-03 END_CSV @tabl...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/table_aset_test.rb
Ruby
mit
199
main
5,519
class TableAsetTest < Test::Unit::TestCase include Charty::TestHelpers if {}.respond_to?(:transform_keys) def transform_keys(h, &block) h.transform_keys(&block) end else def transform_keys(h) h.map {|k, v| [yield(k), v] }.to_h end end def raw_data(key_type) raw_data = { ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/table/array_test.rb
Ruby
mit
199
main
11,041
class TableArrayTest < Test::Unit::TestCase sub_test_case("an array of arrays as records") do def setup @data = [ [1, 2, 3, 4], [5, 6, 7, 8], ] @table = Charty::Table.new(@data) end def test_length assert_equal(2, @table.l...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/lib/load_error_backend.rb
Ruby
mit
199
main
209
module Charty module TestHelpers class LoadErrorBackend Backends.register(:load_error_backend, self) def self.prepare raise LoadError, "LoadErrorBackend" end end end end
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/box_plot_test.rb
Ruby
mit
199
main
2,809
class PlotMethodsBoxPlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("rendering") do include Charty::RenderingTestHelpers def setup_array_data @data = { y: Array.new(100) {|i| rand }, x: Array.new(100) {|i| ["foo", "bar"][rand(2)] }, c: Array.new(100)...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/hist_plot_test.rb
Ruby
mit
199
main
2,933
class PlotMethodHistPlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("rendering") do include Charty::RenderingTestHelpers data(:adapter, [:array, :arrow]) data(:backend, [:pyplot, :plotly]) def test_hist_plot_with_flat_vectors(data) backend_name = data[:backend] ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/scatter_plot_test.rb
Ruby
mit
199
main
7,876
class PlotMethodScatterPlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("function-call style") do def setup super do @x = Array.new(20) {|i| rand(i.to_f) } @y = Array.new(20) {|i| rand * @x[i] } @data = {x: @x, y: @y} yield end end s...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/count_plot_test.rb
Ruby
mit
199
main
3,197
class PlotMethodsCountPlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("function-call style") do # TODO: write tests here end sub_test_case("DSL style") do # TODO: write tests here end sub_test_case("rendering") do include Charty::RenderingTestHelpers def setup_a...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/bar_plot_test.rb
Ruby
mit
199
main
8,885
class PlotMethodsBarPlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("function-call style") do test("given x and y") do x = [1, 2, 3, 4, 5] y = [10, 20, 30, 25, 15] fig = Charty.bar_plot(x: x, y: y) assert_instance_of(Charty::Plotters::BarPlotter, fig) ass...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/plot_methods/line_plot_test.rb
Ruby
mit
199
main
3,865
class PlotMethodLinePlotTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("rendering") do include Charty::RenderingTestHelpers def test_line_plot_with_flat_vector backend_name = :pyplot setup_backend(backend_name) plot = Charty.line_plot(data: [1, 2, 3, 4, 5]) a...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/narray_test.rb
Ruby
mit
199
main
13,745
class VectorNArrayTest < Test::Unit::TestCase include Charty::TestHelpers def setup numo_required @classes = { Bit: Numo::Bit, Int64: Numo::Int64, DFloat: Numo::DFloat, RObject: Numo::RObject } @data = Numo::DFloat[1, 2, 3, 4, 5] @vector = Charty::Vector.new(@dat...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/vector_values_at_test.rb
Ruby
mit
199
main
1,271
class VectorValuesAtTest < Test::Unit::TestCase include Charty::TestHelpers data(:adapter_type, [:array, :daru, :narray, :nmatrix, :numpy, :pandas], keep: true) def test_values_at(data) vector = setup_vector(data[:adapter_type], [1, 2, 3, 4, 5], index: [1, 3, 5, 2, 4]) assert_equal([1, 2, 3, 5, 4, 3], ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/pandas_test.rb
Ruby
mit
199
main
15,612
class VectorPandasTest < Test::Unit::TestCase include Charty::TestHelpers def setup pandas_required @series = Pandas::Series.new([1, 2, 3, 4, 5], dtype: :float64) @vector = Charty::Vector.new(@series) end def test_length assert_equal(5, @vector.length) end def test_name values = [@ve...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/array_test.rb
Ruby
mit
199
main
11,088
class VectorArrayTest < Test::Unit::TestCase include Charty::TestHelpers def setup @data = [1, 2, 3, 4, 5] @vector = Charty::Vector.new(@data) end def test_length assert_equal(5, @vector.length) end def test_name values = [@vector.name] @vector.name = "abc" values << @vector.name ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/daru_test.rb
Ruby
mit
199
main
16,381
class VectorDaruTest < Test::Unit::TestCase include Charty::TestHelpers def setup begin require "daru" rescue LoadError omit("daru is unavailable") end @data = Daru::Vector.new([1, 2, 3, 4, 5]) @vector = Charty::Vector.new(@data) end def test_length assert_equal(5, @vector...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/nmatrix_test.rb
Ruby
mit
199
main
2,815
class VectorNMatrixTest < Test::Unit::TestCase include Charty::TestHelpers def setup nmatrix_required @data = NMatrix[1, 2, 3, 4, 5] @vector = Charty::Vector.new(@data) end def test_length assert_equal(5, @vector.length) end def test_name values = [@vector.name] @vector.name = "a...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/numpy_test.rb
Ruby
mit
199
main
15,669
class VectorNumpyTest < Test::Unit::TestCase include Charty::TestHelpers def setup pandas_required @data = Numpy.asarray([1, 2, 3, 4, 5], dtype: :float64) @vector = Charty::Vector.new(@data) end def test_length assert_equal(5, @vector.length) end def test_name values = [@vector.name]...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/iloc_test.rb
Ruby
mit
199
main
1,629
class VectorIlocTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("Charty::Vector#iloc") do data(:adapter_type, [:array, :daru, :narray, :numpy, :pandas], keep: true) test("with the default index") do |data| vector = setup_vector(data[:adapter_type], [10, 20, 30]) assert_eq...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/vector_equality_test.rb
Ruby
mit
199
main
2,845
class VectorEqualityTest < Test::Unit::TestCase include Charty::TestHelpers data(:adapter_type, [:array, :daru, :narray, :nmatrix, :numpy, :pandas], keep: true) data(:other_adapter_type, [:array, :daru, :narray, :nmatrix, :numpy, :pandas], keep: true) def test_equality(data) vector = setup_vector(dat...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/arrow_test.rb
Ruby
mit
199
main
10,757
class VectorArrowTest < Test::Unit::TestCase include Charty::TestHelpers def setup arrow_required @data = Arrow::Array.new([1, 2, nil, 4, 2]) @vector = Charty::Vector.new(@data) end def test_length assert_equal(5, @vector.length) end def test_name values = [@vector.name] @vector....
github
red-data-tools/charty
https://github.com/red-data-tools/charty
test/vector/vector_scale_test.rb
Ruby
mit
199
main
574
class VectorScaleTest < Test::Unit::TestCase include Charty::TestHelpers sub_test_case("linear") do data(:adapter_type, [:array, :daru, :narray, :nmatrix, :numpy, :pandas], keep: true) def test_scale_linear(data) omit("TODO") end def test_scale_inverse_linear(data) omit("TODO") end...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty.rb
Ruby
mit
199
main
696
require_relative "charty/version" require "colors" require "palette" require_relative "charty/cache_dir" require_relative "charty/util" require_relative "charty/iruby_helper" require_relative "charty/dash_pattern_generator" require_relative "charty/backends" require_relative "charty/backend_methods" require_relative ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/plotter.rb
Ruby
mit
199
main
6,160
module Charty class Plotter def initialize(backend_name) backend_class = Backends.find_backend_class(backend_name) @backend = backend_class.new end def table=(data, **kwargs) @table = Charty::Table.new(data) end attr_reader :table def to_bar(x, y, **args, &block) ser...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/table.rb
Ruby
mit
199
main
5,531
require 'forwardable' module Charty class ColumnAccessor def initialize(adapter) @adapter = adapter end def [](column_name) @adapter[nil, column_name] end end class Table extend Forwardable def initialize(data, **kwargs) adapter_class = TableAdapters.find_adapter_clas...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/cache_dir.rb
Ruby
mit
199
main
627
require "pathname" module Charty module CacheDir module_function def cache_dir_path platform_cache_dir_path + "charty" end def platform_cache_dir_path base_dir = case RUBY_PLATFORM when /mswin/, /mingw/ ENV.fetch("LOCALAPPDATA", "~/AppData/Local") ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/dash_pattern_generator.rb
Ruby
mit
199
main
1,288
module Charty module DashPatternGenerator NAMED_PATTERNS = { solid: "", dash: [4, 1.5], dot: [1, 1], dashdot: [3, 1.25, 1.5, 1.25], longdashdot: [5, 1, 1, 1], }.freeze def self.valid_name?(name) name = case name when Symbol, Strin...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/linspace.rb
Ruby
mit
199
main
507
module Charty class Linspace include Enumerable def initialize(range, num_step) @range = range @num_step = num_step end def each(&block) if @num_step == 1 block.call(@range.begin) else step = (@range.end - @range.begin).to_r / (@num_step - 1) (@num_ste...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters.rb
Ruby
mit
199
main
5,166
require "forwardable" module Charty module VectorAdapters class UnsupportedVectorData < StandardError; end @adapters = {} def self.register(name, adapter_class) @adapters[name] = adapter_class end def self.find_adapter_class(data, exception: true) @adapters.each_value do |adapter_c...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector.rb
Ruby
mit
199
main
2,264
require "forwardable" module Charty class Vector extend Forwardable include Enumerable def self.try_convert(obj) case obj when self obj else if VectorAdapters.find_adapter_class(obj, exception: false) new(obj) end end end def initialize(...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/layout.rb
Ruby
mit
199
main
1,520
module Charty class Layout def initialize(frontend, definition = :horizontal) @frontend = frontend @layout = parse_definition(definition) end def parse_definition(definition) case definition when :horizontal ArrayLayout.new when :vertical ArrayLayout.new(:ver...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/plotters.rb
Ruby
mit
199
main
577
require_relative "plotters/abstract_plotter" require_relative "plotters/random_support" require_relative "plotters/estimation_support" require_relative "plotters/categorical_plotter" require_relative "plotters/bar_plotter" require_relative "plotters/box_plotter" require_relative "plotters/count_plotter" require_relati...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/util.rb
Ruby
mit
199
main
563
module Charty module Util if [].respond_to?(:filter_map) module_function def filter_map(enum, &block) enum.filter_map(&block) end else module_function def filter_map(enum, &block) enum.inject([]) do |acc, x| y = block.call(x) if y acc.push(y) ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/backends.rb
Ruby
mit
199
main
1,825
module Charty class BackendError < RuntimeError; end class BackendNotFoundError < BackendError; end class BackendLoadError < BackendError; end module Backends @backends = {} @current = nil def self.current @current end def self.current=(backend_name) backend_class = Backends....
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/iruby_helper.rb
Ruby
mit
199
main
290
module Charty module IRubyHelper module_function def iruby_notebook? # TODO: This cannot distinguish notebook and console. defined?(IRuby) end def vscode? ENV.key?("VSCODE_PID") end def nteract? ENV.key?("NTERACT_EXE") end end end
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/statistics.rb
Ruby
mit
199
main
3,417
module Charty module Statistics begin require "enumerable/statistics" def self.mean(enum) enum.mean end def self.stdev(enum, population: false) enum.stdev(population: population) end def self.histogram(ary, *args, **kwargs) ary.histogram(*args, **kwar...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/table_adapters.rb
Ruby
mit
199
main
784
module Charty module TableAdapters @adapters = {} def self.register(name, adapter_class) @adapters[name] = adapter_class end def self.find_adapter_class(data) @adapters.each_value do |adapter_class| return adapter_class if adapter_class.supported?(data) end raise Argu...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/plot_methods.rb
Ruby
mit
199
main
13,521
module Charty module PlotMethods # Show the given data as rectangular bars. # # @param x x-dimension input for plotting long-form data. # @param y y-dimension input for plotting long-form data. # @param color color-dimension input for plotting long-form data. # @param data Dataset for plot...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/index.rb
Ruby
mit
199
main
5,194
require "forwardable" module Charty class Index extend Forwardable include Enumerable def initialize(values, name: nil) @values = values @name = name end attr_reader :values attr_accessor :name def_delegators :values, :length, :size, :each, :to_a def ==(other) ca...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/vector_adapter.rb
Ruby
mit
199
main
1,726
module Charty module VectorAdapters class VectorAdapter < BaseAdapter VectorAdapters.register(:vector, self) extend Forwardable include Enumerable def self.supported?(data) data.is_a?(Vector) end def initialize(data, index: nil) data = check_data(data) ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/daru_adapter.rb
Ruby
mit
199
main
3,748
module Charty module VectorAdapters class DaruVectorAdapter < BaseAdapter VectorAdapters.register(:daru_vector, self) def self.supported?(data) defined?(Daru::Vector) && data.is_a?(Daru::Vector) end def initialize(data) @data = check_data(data) end def_delega...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/array_adapter.rb
Ruby
mit
199
main
2,115
require "date" module Charty module VectorAdapters class ArrayAdapter < BaseAdapter VectorAdapters.register(:array, self) extend Forwardable include Enumerable def self.supported?(data) case data when Array case data[0] when Numeric, String, Time, Dat...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/numpy_adapter.rb
Ruby
mit
199
main
4,218
module Charty module VectorAdapters class NumpyAdapter < BaseAdapter VectorAdapters.register(:numpy, self) def self.supported?(data) return false unless defined?(Numpy::NDArray) case data when Numpy::NDArray true else false end end ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/narray_adapter.rb
Ruby
mit
199
main
4,271
module Charty module VectorAdapters class NArrayAdapter < BaseAdapter VectorAdapters.register(:narray, self) extend Forwardable include Enumerable def self.supported?(data) defined?(Numo::NArray) && data.is_a?(Numo::NArray) end def initialize(data) @data = ch...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/arrow_adapter.rb
Ruby
mit
199
main
4,130
module Charty module VectorAdapters class ArrowAdapter < BaseAdapter VectorAdapters.register(:arrow, self) include Enumerable include NameSupport include IndexSupport def self.supported?(data) (defined?(Arrow::Array) && data.is_a?(Arrow::Array)) || (defined?(Arrow...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/vector_adapters/pandas_adapter.rb
Ruby
mit
199
main
4,899
module Charty module VectorAdapters class PandasSeriesAdapter < BaseAdapter VectorAdapters.register(:pandas_series, self) def self.supported?(data) return false unless defined?(Pandas::Series) case data when Pandas::Series true else false en...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/plotters/random_support.rb
Ruby
mit
199
main
524
module Charty module Plotters module RandomSupport attr_reader :random def random=(random) @random = check_random(random) end module_function def check_random(random) case random when nil Random.new when Integer Random.new(random) ...
github
red-data-tools/charty
https://github.com/red-data-tools/charty
lib/charty/plotters/line_plotter.rb
Ruby
mit
199
main
9,840
module Charty module Plotters class EstimateAggregator def initialize(estimator, error_bar, n_boot, random) @estimator = estimator @method, @level = error_bar @n_boot = n_boot @random = random end # Perform aggregation # # @param data [Hash<Any, Chart...