julia

Read CSV files faster in Julia

不羁岁月 提交于 2021-01-27 05:40:50
问题 I have noticed that loading a CSV file using CSV.read is quite slow. For reference, I am attaching one example of time benchmark: using CSV, DataFrames file = download("https://github.com/foursquare/twofishes") @time CSV.read(file, DataFrame) Output: 9.450861 seconds (22.77 M allocations: 960.541 MiB, 5.48% gc time) 297 rows × 2 columns This is a random dataset, and a python alternate of such operation compiles in fraction of time compared to Julia. Since, julia is faster than python why is

Exporting all symbols in Julia

烈酒焚心 提交于 2021-01-27 04:31:26
问题 Is there a way to export all symbols in a Julia module (something like the semantic counterpart to importall )? Such a functionality would be very useful when the number of symbols to be exported grows large. TIA. 回答1: There's the Reexport.jl package that provides a form of this; it's use case is when you have a submodule and you want to reexport all of the exported symbols from the inner module into your current module. I know, not exportall , but part of the functionality. 回答2: I wrote a

Show all methods of a function in Julia

一世执手 提交于 2021-01-26 04:46:21
问题 How can I show all the methods of a function in Julia ( multiple dispatch )? For example, all the methods that exist in the namespace for the function abs . 回答1: The methods function will return the method table for the given function: julia> methods(abs) # 13 methods for generic function "abs": [1] abs(a::Pkg.Resolve.FieldValue) in Pkg.Resolve at /home/david/pkg/julia-bin/julia-1.4.0-rc1/share/julia/stdlib/v1.4/Pkg/src/Resolve/fieldvalues.jl:61 [2] abs(a::Pkg.Resolve.VersionWeight) in Pkg

Show all methods of a function in Julia

若如初见. 提交于 2021-01-26 04:43:20
问题 How can I show all the methods of a function in Julia ( multiple dispatch )? For example, all the methods that exist in the namespace for the function abs . 回答1: The methods function will return the method table for the given function: julia> methods(abs) # 13 methods for generic function "abs": [1] abs(a::Pkg.Resolve.FieldValue) in Pkg.Resolve at /home/david/pkg/julia-bin/julia-1.4.0-rc1/share/julia/stdlib/v1.4/Pkg/src/Resolve/fieldvalues.jl:61 [2] abs(a::Pkg.Resolve.VersionWeight) in Pkg

Scraping string from a large number of URLs with Julia

╄→尐↘猪︶ㄣ 提交于 2021-01-24 06:58:50
问题 Happy New Year! I have just started to learn Julia and my first mini challenge I have set myself is to scrape data from a large list of URLs. I have ca 50k URLs (which I successfully parsed from a JSON with Julia using Regex) in a CSV file. I want to scrape each one and return a matched string ("/page/12345/view" - where 12345 is any integer). I managed to do so using HTTP and Queryverse (although had started with CSV and CSVFiles but looking at packages for learning purposes) but the script

Scraping string from a large number of URLs with Julia

我的未来我决定 提交于 2021-01-24 06:57:00
问题 Happy New Year! I have just started to learn Julia and my first mini challenge I have set myself is to scrape data from a large list of URLs. I have ca 50k URLs (which I successfully parsed from a JSON with Julia using Regex) in a CSV file. I want to scrape each one and return a matched string ("/page/12345/view" - where 12345 is any integer). I managed to do so using HTTP and Queryverse (although had started with CSV and CSVFiles but looking at packages for learning purposes) but the script

When to interpolate in benchmarking expressions

人走茶凉 提交于 2021-01-23 02:11:07
问题 The BenchmarkTools documentation recommends interpolating global variables into benchmarking expressions. However, the gap in run times for the example that they provide seems to have closed considerably. In their example, they have a global variable A = rand(1000) , and they compare @benchmark [i*i for i in A] to @benchmark [i*i for i in $A] , and get 13.806 μs versus 1.348 μs , respectively. However, when I run that example now, the run times are very close: julia> using Statistics,

When to interpolate in benchmarking expressions

杀马特。学长 韩版系。学妹 提交于 2021-01-23 02:10:27
问题 The BenchmarkTools documentation recommends interpolating global variables into benchmarking expressions. However, the gap in run times for the example that they provide seems to have closed considerably. In their example, they have a global variable A = rand(1000) , and they compare @benchmark [i*i for i in A] to @benchmark [i*i for i in $A] , and get 13.806 μs versus 1.348 μs , respectively. However, when I run that example now, the run times are very close: julia> using Statistics,

When to interpolate in benchmarking expressions

可紊 提交于 2021-01-23 02:08:19
问题 The BenchmarkTools documentation recommends interpolating global variables into benchmarking expressions. However, the gap in run times for the example that they provide seems to have closed considerably. In their example, they have a global variable A = rand(1000) , and they compare @benchmark [i*i for i in A] to @benchmark [i*i for i in $A] , and get 13.806 μs versus 1.348 μs , respectively. However, when I run that example now, the run times are very close: julia> using Statistics,

How to resolve “UndefVarError: T not defined” in function signature

浪子不回头ぞ 提交于 2021-01-22 12:37:54
问题 I am trying to run (someone else's code) that looks like function f{T<:Number}(n::Int, alpha::T, beta::T) ... end When "using" that file I get UndefVarError: T not defined Stacktrace: [1] top-level scope at [file location]:[line number of function definition above] From what I've read in the documentation (https://docs.julialang.org/en/v1/base/numbers/), it looks like the syntax above is correct. Any idea why I'm getting this error? 回答1: This is old Julia syntax. This function should be re