-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unsuccessful assignment without any error #56163
Comments
hi, to increase the probability of getting a resolution to your issue, could you please format the example code in a way that makes it easier to replicate and understand exactly what you're running into? In particular, I would like to able to copy-paste your MWE into my REPL and observe the exact behavior you do, without having to guess at the different parameters / values you're using. |
I don't understand either. That "fix" gives me the same resulting shape object:
And testing assignment by creating
I see the same result from assigning either |
Here is the reproducible example: a=spzeros(120,120) isl=5 a[10,isl]=1 |
Smaller MWE: using SparseArrays
A = zeros(3, 1)
sparseA = sparse(A)
b = ones(1, 3)
A[:, 1] = b
sparseA[:, 1] = b
# A is:
# 3×1 Matrix{Float64}:
# 1.0
# 1.0
# 1.0
# sparseA is:
# 3×1 SparseMatrixCSC{Float64, Int64} with 1 stored entry:
# 1.0
# ⋅
# ⋅ Notice that |
the smaller MWE doesn't show the problem correctly. I understood that if we make vector before, everything is fine and solved my issue in the same way. Just for the others who will use the package, in the case of a matrix, it cannot do assignment, and I suppose it should raise an error (which it doesn't). |
ooie yeah something looks super wrong. I'm not that familiar with sparse arrays but seems like |
Oh Sorry. Actually, I thought I am writing the issue for SparseArrays.jl. I will create an issue there. |
Moved to JuliaSparse/SparseArrays.jl#569 |
Hi,
I tried to run this line in one of my functions:
J[:, isl]=[ki... zeros(length(setdiff(1:nBus,ipq)))...]
J is a sparse matrix with size
120*120
. J[:, isl] is a column with only four values, which are [11.00 -11.00 44.00 -44.00]. [ki... zeros(length(setdiff(1:nBus,ipq)))...] is a matrix120*1
, of which 23 elements are 50.00 and the others equal to zero. The result of running this code is again a column with only four values, which are [0.00 0.00 0.00 0.00]. However, I expect it to be a column with 23, 24,..., or 27 values, which includes 23 values equal to 50.00.I didn't encounter any error. I believe it should be a bug. By chance I understood that this assignment doesn't work correctly, But it could be in fact dangerous for the others.
I fixed it in this way:
J[:, isl]=[ki... zeros(length(setdiff(1:nBus,ipq)))...]**[:,1]**
Best,
Arman
The text was updated successfully, but these errors were encountered: