# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=316

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 317

---

## [Iterator says \`Channel is closed\`](https://discourse.julialang.org/t/iterator-says-channel-is-closed/95702)

<div class="topic-metadata">

**Author:** [@Ross\_Boylan](https://discourse.julialang.org/u/Ross_Boylan)\
**Replies:** 3\
**Last updated:** [March 13, 2023, 7:06am UTC](https://discourse.julialang.org/t/iterator-says-channel-is-closed/95702 "2023-03-13T07:06:36Z")

</div>

A custom iterator throws the subject error every time I run the code below. It does so when run plain or under VSCode, and it does so with one thread or many. It is odd for several reasons: The line throwing the erro…

---

## [How to load Requires.jl code of dependency while precompiling](https://discourse.julialang.org/t/how-to-load-requires-jl-code-of-dependency-while-precompiling/95962)

<div class="topic-metadata">

**Author:** [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Replies:** 4\
**Last updated:** [March 13, 2023, 5:50am UTC](https://discourse.julialang.org/t/how-to-load-requires-jl-code-of-dependency-while-precompiling/95962 "2023-03-13T05:50:13Z")

</div>

This question came up in update to StaticArrayInterface by ChrisRackauckas · Pull Request #165 · ranocha/SummationByPartsOperators.jl · GitHub. @ChrisRackauckas submitted a patch to update my package from ArrayInterface.…

---

## [Save data into mysql database in batch mode on transaction basis](https://discourse.julialang.org/t/save-data-into-mysql-database-in-batch-mode-on-transaction-basis/95838)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 2\
**Last updated:** [March 13, 2023, 4:43am UTC](https://discourse.julialang.org/t/save-data-into-mysql-database-in-batch-mode-on-transaction-basis/95838 "2023-03-13T04:43:13Z")

</div>

I am trying to load data(from df) into mysql database in batch mode, Loading should be on single transaction and data should be rolled back if load fails at any stage during batch processing. I’ve coded currently by usin…

---

## [Chain the transformation without @chain macro](https://discourse.julialang.org/t/chain-the-transformation-without-chain-macro/95955)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 4\
**Last updated:** [March 12, 2023, 10:24pm UTC](https://discourse.julialang.org/t/chain-the-transformation-without-chain-macro/95955 "2023-03-12T22:24:40Z")

</div>

Reading the DataFramesMeta.jl document helps me learn a clean way to chain the transformation with the @chain macro. From its document: @chain msleep begin @select :name :sleep\_total @rsubset :sleep\_total \> 16…

---

## [How to convert the String15 datatype in DataFrames.jl to Float64](https://discourse.julialang.org/t/how-to-convert-the-string15-datatype-in-dataframes-jl-to-float64/95907)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 9\
**Last updated:** [March 12, 2023, 5:52pm UTC](https://discourse.julialang.org/t/how-to-convert-the-string15-datatype-in-dataframes-jl-to-float64/95907 "2023-03-12T17:52:14Z")

</div>

I have a DataFrame with 2 columns in type String15 and String31, respectively. Now I want to convert element type from 2 columns to Float64 but I can’t found any document or example in DataFrames.jl’s document. My f…

---

## [Serialization format allow incremental write to file](https://discourse.julialang.org/t/serialization-format-allow-incremental-write-to-file/95464)

<div class="topic-metadata">

**Author:** [@Roger-luo](https://discourse.julialang.org/u/Roger-luo)\
**Replies:** 10\
**Last updated:** [March 12, 2023, 7:11pm UTC](https://discourse.julialang.org/t/serialization-format-allow-incremental-write-to-file/95464 "2023-03-12T19:11:50Z")

</div>

Is there any data format that supports incremental writes and allows flush to the file after the write? I find julia-arrow support incremental writes here: refactor Arrow.write to support incremental writes by baumgold ·…

---

## [When can one expect assignment to an array to run in parallel?](https://discourse.julialang.org/t/when-can-one-expect-assignment-to-an-array-to-run-in-parallel/95971)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 6\
**Last updated:** [March 12, 2023, 6:50pm UTC](https://discourse.julialang.org/t/when-can-one-expect-assignment-to-an-array-to-run-in-parallel/95971 "2023-03-12T18:50:08Z")

</div>

Consider N = 8\_000\_000\_000 a = zeros(Int64, N) a .= 1 For some reason I expected the broadcast assignment to run in parallel on multiple threads. According to my experiments, that is not happening. Does anyone have an…

---

## [Weighted\_similarity and tabu search](https://discourse.julialang.org/t/weighted-similarity-and-tabu-search/95968)

<div class="topic-metadata">

**Author:** [@Andre1](https://discourse.julialang.org/u/Andre1)\
**Replies:** 1\
**Last updated:** [March 12, 2023, 5:54pm UTC](https://discourse.julialang.org/t/weighted-similarity-and-tabu-search/95968 "2023-03-12T17:54:59Z")

</div>

data = \[\["O", "U", "V", "buss", "bsh"\], \["NA", "hand", "machine", "other", "mis"\], \["NA", "simple", "medium", "full", "mis"\], \["NA", "shoulder-elbow", "elbow", "elbow-wrist", "wrist"\], \["NA", "curfed", "relaxed",…

---

## [Lazy broadcasting speed issues](https://discourse.julialang.org/t/lazy-broadcasting-speed-issues/94218)

<div class="topic-metadata">

**Author:** [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Replies:** 13\
**Last updated:** [March 12, 2023, 4:52pm UTC](https://discourse.julialang.org/t/lazy-broadcasting-speed-issues/94218 "2023-03-12T16:52:22Z")

</div>

I am working on a new package called SeparableFunctions.jl with the aim to boost the performance for functions which are expensive to calculate on multidimensional grids, but can profit a lot from broadcasting. To this…

---

## [What is the best way to solve a ill-conditioned linear problem?](https://discourse.julialang.org/t/what-is-the-best-way-to-solve-a-ill-conditioned-linear-problem/95894)

<div class="topic-metadata">

**Author:** [@linwaytin](https://discourse.julialang.org/u/linwaytin)\
**Replies:** 15\
**Last updated:** [March 12, 2023, 12:59pm UTC](https://discourse.julialang.org/t/what-is-the-best-way-to-solve-a-ill-conditioned-linear-problem/95894 "2023-03-12T12:59:29Z")

</div>

Some background first: I’m a physicist and have little knowledge about numerical analysis and linear algebra, so maybe this is a meaningless question. I have a matrix A in double precision, which has elements ranging fr…

---

## [An Issue in Defining a Mutating Function](https://discourse.julialang.org/t/an-issue-in-defining-a-mutating-function/95933)

<div class="topic-metadata">

**Author:** [@HoldenCaulfield](https://discourse.julialang.org/u/HoldenCaulfield)\
**Replies:** 6\
**Last updated:** [March 12, 2023, 9:33am UTC](https://discourse.julialang.org/t/an-issue-in-defining-a-mutating-function/95933 "2023-03-12T09:33:45Z")

</div>

This might sound a stupid question to experienced Julia users. When I define a simple mutating function as: function foo!(x) x = x + 1 end I expect the function to change the value of its argument. However when I e…

---

## [Readdlm, comments=true instead of false](https://discourse.julialang.org/t/readdlm-comments-true-instead-of-false/95810)

<div class="topic-metadata">

**Author:** [@marllos](https://discourse.julialang.org/u/marllos)\
**Replies:** 2\
**Last updated:** [March 12, 2023, 1:57am UTC](https://discourse.julialang.org/t/readdlm-comments-true-instead-of-false/95810 "2023-03-12T01:57:04Z")

</div>

Wouldn’t that be better? This would allow adding (commented) information to the end of a data file, without having to change the code.

---

## [Are "Closures should be avoided whenever possible" still valid in Julia v1.9+?](https://discourse.julialang.org/t/are-closures-should-be-avoided-whenever-possible-still-valid-in-julia-v1-9/95893)

<div class="topic-metadata">

**Author:** [@singularitti](https://discourse.julialang.org/u/singularitti)\
**Replies:** 5\
**Last updated:** [March 12, 2023, 12:32am UTC](https://discourse.julialang.org/t/are-closures-should-be-avoided-whenever-possible-still-valid-in-julia-v1-9/95893 "2023-03-12T00:32:39Z")

</div>

I have posted the same question on Are the examples in "Closures should be avoided whenever possible" still valid in Julia v1.9+? · Issue #34 · SciML/SciMLStyle · GitHub. I just tested the examples in the section “Closu…

---

## [The step-by-step of the SymPy package procedure](https://discourse.julialang.org/t/the-step-by-step-of-the-sympy-package-procedure/95901)

<div class="topic-metadata">

**Author:** [@maoc](https://discourse.julialang.org/u/maoc)\
**Replies:** 3\
**Last updated:** [March 11, 2023, 8:08pm UTC](https://discourse.julialang.org/t/the-step-by-step-of-the-sympy-package-procedure/95901 "2023-03-11T20:08:49Z")

</div>

I am reading the tutorial of the SymPy package. I would like to know if there is a way to show the step-by-step calculations that the package performs. For example, we know that this works well: using SymPy x = symbols(…

---

## [Problem with using Distributed for a Monte Carlo simulation](https://discourse.julialang.org/t/problem-with-using-distributed-for-a-monte-carlo-simulation/95508)

<div class="topic-metadata">

**Author:** [@greivin](https://discourse.julialang.org/u/greivin)\
**Replies:** 6\
**Last updated:** [March 11, 2023, 4:07pm UTC](https://discourse.julialang.org/t/problem-with-using-distributed-for-a-monte-carlo-simulation/95508 "2023-03-11T16:07:53Z")

</div>

I’m using the Distributed package to parallelize a for loop during a Monte Carlo simulation, this for loop is running over several initial conditions to generate a CSV file of L/2 x N entries where L is the size of the s…

---

## [Performance of a transpose compared to c and cache friendliness](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883)

<div class="topic-metadata">

**Author:** [@sneakyturtle](https://discourse.julialang.org/u/sneakyturtle)\
**Replies:** 6\
**Last updated:** [March 11, 2023, 3:33pm UTC](https://discourse.julialang.org/t/performance-of-a-transpose-compared-to-c-and-cache-friendliness/95883 "2023-03-11T15:33:01Z")

</div>

In a quest to learn good HPC principles, I am trying to understand how to implement cache friendly loops in Julia. I found this code loop\_blocking that compares performance of loop blocking techniques between c and Rust…

---

## [Docstring: how to format returns](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850)

<div class="topic-metadata">

**Author:** [@AdamWysokinski](https://discourse.julialang.org/u/AdamWysokinski)\
**Replies:** 3\
**Last updated:** [March 11, 2023, 8:36am UTC](https://discourse.julialang.org/t/docstring-how-to-format-returns/95850 "2023-03-11T08:36:50Z")

</div>

Hi, I wonder if there is any standardized way of reporting function return in its docstring for something like this: """ test(x) Test whether \`x\` is greater than 0. # Arguments - \`x::Int64\`: the number to test …

---

## [Type Nothing has no field match](https://discourse.julialang.org/t/type-nothing-has-no-field-match/95904)

<div class="topic-metadata">

**Author:** [@hungpham3112](https://discourse.julialang.org/u/hungpham3112)\
**Replies:** 1\
**Last updated:** [March 11, 2023, 5:57am UTC](https://discourse.julialang.org/t/type-nothing-has-no-field-match/95904 "2023-03-11T05:57:27Z")

</div>

I’m learning Linear Regression model with housing dataset from Kaggle. Dealing with a problem to extract int or float from string make me some confusing. # rename columns renamed\_df = rename(df2, Dict("Diện tích" =\> "A…

---

## [Raw HTML in docstring](https://discourse.julialang.org/t/raw-html-in-docstring/95491)

<div class="topic-metadata">

**Author:** [@pedromxavier](https://discourse.julialang.org/u/pedromxavier)\
**Replies:** 3\
**Last updated:** [March 11, 2023, 3:33am UTC](https://discourse.julialang.org/t/raw-html-in-docstring/95491 "2023-03-11T03:33:03Z")

</div>

I’m using Documenter.jl to generate online docs for my package. I want to include raw HTML in a method docstring such as: @doc raw""" my\_method(x, y) This is my method. Now some raw HTML: \`\`\`@raw html \<svg style="…

---

## [FFTW plan gets clobbered when module is compiled](https://discourse.julialang.org/t/fftw-plan-gets-clobbered-when-module-is-compiled/95896)

<div class="topic-metadata">

**Author:** [@Jake](https://discourse.julialang.org/u/Jake)\
**Replies:** 1\
**Last updated:** [March 11, 2023, 1:53am UTC](https://discourse.julialang.org/t/fftw-plan-gets-clobbered-when-module-is-compiled/95896 "2023-03-11T01:53:22Z")

</div>

I have a function that calls fft() repeatedly. For performance I implemented an FFT plan. In some situations the length of data will remain the same, in other cases the the length changes. For this reason the plan is …

---

## [Best way to avoid singular matrix crashing optimization routine](https://discourse.julialang.org/t/best-way-to-avoid-singular-matrix-crashing-optimization-routine/95897)

<div class="topic-metadata">

**Author:** [@jrhalket](https://discourse.julialang.org/u/jrhalket)\
**Replies:** 1\
**Last updated:** [March 11, 2023, 12:18am UTC](https://discourse.julialang.org/t/best-way-to-avoid-singular-matrix-crashing-optimization-routine/95897 "2023-03-11T00:18:57Z")

</div>

I have a log likelihood function I’m trying to maximize and as part of the computation of the log likelihood I call a function ScalcAll which performs the following calcs, including inverting a matrix. up and down are da…

---

## [Vector of Rational{Int64}](https://discourse.julialang.org/t/vector-of-rational-int64/95891)

<div class="topic-metadata">

**Author:** [@Cougar](https://discourse.julialang.org/u/Cougar)\
**Replies:** 1\
**Last updated:** [March 10, 2023, 10:14pm UTC](https://discourse.julialang.org/t/vector-of-rational-int64/95891 "2023-03-10T22:14:56Z")

</div>

Does anyone know why the following … rationalVector::Vector{Rational{Int64}} = \[ (2//3), (5//8), (11//17), (44/101) \] for rational in rationalVector println(rational) end # for rational … prints the following … 600…

---

## [Sieving for Bsmooth values](https://discourse.julialang.org/t/sieving-for-bsmooth-values/95404)

<div class="topic-metadata">

**Author:** [@x13420x](https://discourse.julialang.org/u/x13420x)\
**Replies:** 15\
**Last updated:** [March 9, 2023, 9:26pm UTC](https://discourse.julialang.org/t/sieving-for-bsmooth-values/95404 "2023-03-09T21:26:25Z")

</div>

I am playing around with a quadratic sieve for factorization of large numbers. Most of the work of this algorithm is searching for Bsmooth numbers. If you know the sieve of eratosthenes you can use this process to siev…

---

## [How to read only the last line of a file (.txt)?](https://discourse.julialang.org/t/how-to-read-only-the-last-line-of-a-file-txt/68005)

<div class="topic-metadata">

**Author:** [@guilhermebodin](https://discourse.julialang.org/u/guilhermebodin)\
**Replies:** 24\
**Last updated:** [September 12, 2021, 6:48pm UTC](https://discourse.julialang.org/t/how-to-read-only-the-last-line-of-a-file-txt/68005 "2021-09-12T18:48:45Z")

</div>

Hello, I have a very large txt file and would like to read only the last line of it. What is the best way to do it? For example if I have this file some header option header other option random metadata A,B,C,X,Y,Z 1,…

---

## [Serverless framework](https://discourse.julialang.org/t/serverless-framework/10255)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 7\
**Last updated:** [March 10, 2023, 7:29pm UTC](https://discourse.julialang.org/t/serverless-framework/10255 "2023-03-10T19:29:18Z")

</div>

Anyone thought about making Julia available on serverless framework? https://github.com/serverless/serverless

---

## [Code compiles each time it triggered](https://discourse.julialang.org/t/code-compiles-each-time-it-triggered/95839)

<div class="topic-metadata">

**Author:** [@Sandy45](https://discourse.julialang.org/u/Sandy45)\
**Replies:** 6\
**Last updated:** [March 10, 2023, 6:08pm UTC](https://discourse.julialang.org/t/code-compiles-each-time-it-triggered/95839 "2023-03-10T18:08:37Z")

</div>

I’ve deployed my Julia code to AWS using Docker containers with enabling multiple threads, The issue we are facing is whenever HTTP end point (Julia) has been triggered process is compiling every time since because of us…

---

## [Equivalent of \`last\` for iterators](https://discourse.julialang.org/t/equivalent-of-last-for-iterators/95874)

<div class="topic-metadata">

**Author:** [@Dan](https://discourse.julialang.org/u/Dan)\
**Replies:** 1\
**Last updated:** [March 10, 2023, 5:13pm UTC](https://discourse.julialang.org/t/equivalent-of-last-for-iterators/95874 "2023-03-10T17:13:05Z")

</div>

While responding to a different topic, I needed the last element of an iterator. This has at least one fairly simple and efficient solution which has appeared elsewhere: itrlast(itr) = foldl((\_,y)-\>y,itr) but last can …

---

## [How can I assing an Unitful.jl quantity in an idempotent way?](https://discourse.julialang.org/t/how-can-i-assing-an-unitful-jl-quantity-in-an-idempotent-way/95864)

<div class="topic-metadata">

**Author:** [@bertulli](https://discourse.julialang.org/u/bertulli)\
**Replies:** 4\
**Last updated:** [March 10, 2023, 5:11pm UTC](https://discourse.julialang.org/t/how-can-i-assing-an-unitful-jl-quantity-in-an-idempotent-way/95864 "2023-03-10T17:11:04Z")

</div>

Hi all! So I need to manipulate some physical quantities. Unitful.jl seems to do a very good job at it, but IIUC the idiomatic way to “build” a physical quantity is to multiply the number and the unit: 12 \* u"m". The …

---

## [Using Enzyme with DE.jl](https://discourse.julialang.org/t/using-enzyme-with-de-jl/95302)

<div class="topic-metadata">

**Author:** [@tomkimpson](https://discourse.julialang.org/u/tomkimpson)\
**Replies:** 3\
**Last updated:** [March 10, 2023, 1:30pm UTC](https://discourse.julialang.org/t/using-enzyme-with-de-jl/95302 "2023-03-10T13:30:11Z")

</div>

I am playing with using Enzyme.jl to try to get the derivative of some numerical function with respect to the initial condition. The function is solved using DifferentialEquations.jl. For example: using DifferentialEqua…

---

## [Improving for loop speed in recursive calculation](https://discourse.julialang.org/t/improving-for-loop-speed-in-recursive-calculation/95848)

<div class="topic-metadata">

**Author:** [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Replies:** 1\
**Last updated:** [March 10, 2023, 12:15pm UTC](https://discourse.julialang.org/t/improving-for-loop-speed-in-recursive-calculation/95848 "2023-03-10T12:15:04Z")

</div>

Hi all. I am building a little function that does some recursive computation. it will be working in very large datasets and I want to speed it up. Maybe someone can give a helping hand? :slight\_smile: function rec\_ho…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=315)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=317)
