Which concepts known from Python programming are useful in understanding Julia and which are not?

Thank you… :slightly_smiling_face:

Or

max(size(A)...) 

I think, btw, you should tone down the talk about “insanity”. You are basically implying that almost everyone here is insane. I, too, have left my senses according to your posts. It’s a bit much.

6 Likes

Wish I could downvote a comment :laughing:
I took a peek at your profile and writings on “oOo” and I think you’re right, maybe I am insane!
I’m sorry you don’t like the current scheme though, but oh well :man_shrugging:

3 Likes

The original code was correct, actually. @oOosys misled you there :sweat_smile:
See below where it works for both narrow and wide matrices:

julia> collect_diagonals_orig(A) = [diag(A, i) for i in -(size(A, 1)-1):size(A, 2)-1];

julia> let A = collect(LinearIndices((3, 2)))
           display(A)
           collect_diagonals_orig(A)
       end
3×2 Matrix{Int64}:
 1  4
 2  5
 3  6
4-element Vector{Vector{Int64}}:
 [3]
 [2, 6]
 [1, 5]
 [4]

julia> let A = collect(LinearIndices((2, 3)))
           display(A)
           collect_diagonals_orig(A)
       end
2×3 Matrix{Int64}:
 1  3  5
 2  4  6
4-element Vector{Vector{Int64}}:
 [2]
 [1, 4]
 [3, 6]
 [5]
2 Likes

have checked it out … you are right … somehow I haven’t questioned my point of view … I have spent several days on getting code about diagonals right and arrived at code which needed handling of the cases to make the code work properly assuming it must be that way.

Running this simple code example I was first not believing my eyes … it worked correctly and I needed to revise what I have been considering to be true (using Python) without checking it after so much effort put into the wrong conclusion in first place,

Thank you much for the clarification … and excuse me for the trouble caused out of the confusion I was trapped myself for a week or two busy with approaching indexing of 2D-arrays using the “diagonal coordinate system”.

It’s much easier when you have the right mental model, isn’t it :wink:
I guess centering on the main diagonal leads to a more harmonious view of the solar system after all!

1 Like

Yes, it is … it was a terrible confusion at the beginning … and asking questions on stackoverflow has shown to me that the respondents are all also highly confused. The OOP way of programming made people no more able to grasp most basic things … so I had to answer my questions all myself … animating on that way others to follow my path of thought … which resulted in code 1000 times faster than the first proposed in the initial answer. The patterns of Python programming ingrained by decades of “experience” are showing a quite devastating effect on my ability of deep understanding … taking days and weeks in order to arrive at at least a bit clearer mind allowing then to see how confused the minds of others are …

I have a general issue with NEGATIVITY … and negative numbers are NEGATIV … focusing on what is missing, pointing out how much less there is of something which is nothing … it’s craziness at a highest level possible … established by mathematicians and other smart people … having many negative thoughts … leading to negative numbers. Maybe renaming them to “the other side of N” or similar would help to avoid the negativity spreading this way, on evil purpose or not - hard to see it clearly. The language words decide about your awareness and your focus ,… decide about your personality … So True and False … or True and NOT True … are just things that CAN be avoided … but no language in the world seems to have only the YES in the vocabulary … without the negativity of NO …

If you are not aware how much the vocabulary you use decide about who you are and how you filter what is, you will have hard time to understand how it comes that the convenience of zero and negative numbers is something preventing spreading of happiness around the world ,…

This is why I am not giving-in … even if it seems to be more convenient from some point of view … I would be probably more happy with the main diagonal being the number ONE and then others 1,2,3 above or below instead of +2 and (minus) -2 (a NEGATIVE number).

So do I. But I’ll double down on it, hoping that it will turn into something positive again.

I do appreciate the irony hidden in your posts though: Pointing out how you prefer a language/world without negativity, yet insulting others who reply to you with (presumably) good intentions by calling them “confused” and their ideas “craziness” – even after someone already kindly pointed out to you that this is rude.

Just use unsigned integers … and let me spread happiness by defining some Bools. I might even subtract them if I feel frisky today.

PS: My post clearly doesn’t relate to the original question, sorry for that. My impression was that this ship has long sailed.

4 Likes
1 Like

Some useful concepts from Python. Version 3.7 (2018) onwards: @dataclass creates a class for holding data only, without bundling user-defined methods. It creates default constructor and printing methods for you. This is a nice break from heavy OOP and is similar to structs in Julia. Dataclass documentation encourages the use of type hints, and this becomes essential for Julia where concrete types in struct fields are important for performance.

Python 3.4 (2014) introduces abstract base classes, which have similarities with abstract types in Julia.

2 Likes

Sometimes being rude is the only way to “wake others up” … you know: “the road to hell is paved with good intentions …”

No, rudeness is neither required nor accepted here. This forum is built on mutual respect, and we expect everyone here to be respectful and welcoming to all.

18 Likes

OK … got the message. Will try as good as possible to me to stick to this rule, or … if not possible or making sense … just to keep what would need to be said to myself :slight_smile: .

1 Like

Thank you! And thanks to everyone who participated here for the interesting discussion.

Let’s bring this particular topic to a close. As always, any specific points of particular interest can be continued in new — more focused — topics.

4 Likes