408 questions
-1
votes
4
answers
117
views
sed works, but just for some files [closed]
I'm migrating a blog from Jekyll (source) to Hugo (source).
Both use Markdown, but their syntaxes are slightly different.
Let's say that in the old Jekyll blog I have this:
{% include image.html src=&...
0
votes
1
answer
126
views
In-place, strictly In-place, and O(1) space algorithms
How does one categorize an algorithm like this:
def foo(arr):
# original_len = len(arr)
tmp = []
while arr:
tmp.append(arr.pop())
while tmp:
arr.append(tmp.pop())
The ...
0
votes
0
answers
95
views
Why am I getting the error: one of the variables needed for gradient computation has been modified by an inplace operation while running backward
I am working on my YOLO model. When I try to train my model with the code below an error occured
def main():
# Initialize model, loss, and optimizer
model = Yolov5(version='l')
print(f&...
0
votes
0
answers
51
views
Gradient computation has been modified by an inplace operation in MADDPG model
I am working on multi-agent DDPG RL model. While running the model, it gives following error. Currently I'm working with the PyTorch version 2.6.0 and torchrl version 0.7.0.
---------------------------...
1
vote
1
answer
143
views
How to make my julia in-place function wrapper work without allocating new memory?
I am having a specific problem in julia, I cannot seem to figure out. I broke down my code to some minimal working example to demonstrate the problem:
using BenchmarkTools
function f!(u::Vector)
...
0
votes
0
answers
44
views
How to use Pandas.sort_index() and pd.index.searchsorted()?
I need to sort a Dataframe/Series along the Index, and then use searchsorted to find out the iloc of a target value, so as to do a slice.
If I do sort_index(ascending=True), I can get the results what ...
1
vote
0
answers
52
views
How does int() operate from memoryview -- does it create an intermediate bytes copy?
I'm very interested in zero-copy operations (and disappointed that memoryview doesn't have all the member functions that bytes does). My application will be pretty intensive in this regard.
Consider ...
2
votes
2
answers
95
views
How to change in place the values of a data class object through an iteration, Kotlin
I am looking for a way, without having to install a new library, to iterate through a Kotlin data class and to change the values according to their type.
The implementation I would like is the ...
4
votes
1
answer
154
views
I want to write an RISC-V assembly code that removes zeros from the given array and stores in the same exact memory address
I want to remove zero numbers from the given array that contains a sequence of numbers terminated with last element -1. For example:
arr2: .word 0 0 2 0 0 -1 ====> arr: .word 2 -1
arr: .word 0 3 0 ...
2
votes
1
answer
119
views
How to split variadic template arguments without additional copies?
Consider the following C++23 code:
#include <tuple>
#include <cstdio>
#include <iostream>
struct W1
{
int n;
bool b;
W1(int x, bool f) : n(x), b(f) {}
};
struct W2
{
...
-1
votes
1
answer
55
views
Why does drop_duplicates in_place = True not work in this case? [duplicate]
Sample data:
data = [[1, '[email protected]'], [2, '[email protected]'], [3, '[email protected]']]
person = pd.DataFrame(data, columns=['id', 'email']).astype({'id':'int64', 'email':'object'})
...
1
vote
1
answer
348
views
How to allow _inplacevar_ operations in RestrictedPython?
Expressions such as:
total_impact += impact
in my restricted env are not allowed by default and they cause the error:
NameError: name '_inplacevar_' is not defined
but I would like to allow such ...
0
votes
0
answers
72
views
In-place operation causes a memory leak. Why?
I have the following piece of code:
eigvecs = torch.randn(n, b, dtype=eigval_approximations.dtype, device=eigval_approximations.device)
eigvecs /= torch.linalg.norm(eigvecs, dim=0)
for _ in range(...
1
vote
2
answers
142
views
How to create AWK scripts with shebang that allows in-place modifications?
I want create a awk script with a shebang such that
./main.awk text.txt
performs in-place modification in text.txt. Inspired by a previous solution, I tried something like
#!/usr/bin/awk -i inplace -...
0
votes
1
answer
48
views
fundamental differences between in-place merging and in-place mergesort
I have been pondering the basic big O performance of the functions,
in isolation or in collaboration with each other.
So IPM(S) is a function that does an in-place merge of S,
and IPMS(S) is a ...