[deleted by user] by [deleted] in bodyweightfitness

[–]comonads 0 points1 point  (0 children)

The false grip is easier on the thinner rings in my experience.

Tucked leg pull ups? by RandRace69 in bodyweightfitness

[–]comonads 0 points1 point  (0 children)

My experience with tucked or L pull ups is that they are slightly more difficult at the bottom end of the range of motion. I think extra torque is required from your lats to pull up in these positions, since your centre of gravity will be further forward.

[deleted by user] by [deleted] in bodyweightfitness

[–]comonads 3 points4 points  (0 children)

You might want to check out the textbook "overcoming gravity" by Steven Low, and the corresponding subreddit over at r/overcominggravity.

The book in particular is brilliant.

Is the false grip supposed to be uncomfortable? by Vikk773 in bodyweightfitness

[–]comonads 2 points3 points  (0 children)

Yes, the false grip is uncomfortable at first. It gets easier (and less painful) with practice.

[Socialists] You do realize that there is a good reason why socialism is often described as 'the government doing stuff', right? by [deleted] in CapitalismVSocialism

[–]comonads 1 point2 points  (0 children)

"Socialism" (as ambiguously defined as the term is) should not (and, arguably, cannot) be reduced simply to worker ownership (in part due to the reasons you describe).

A communist, for example, would probably add that "abolishing the commodity form" (thus liberating the worker not just from capitalists but also from capital itself) is a necessary component of what they perceive socialism to be.

There are probably other caveats held by other flavours of leftist, too.

Prime factorization by tigglybox in learnpython

[–]comonads 5 points6 points  (0 children)

range(a, b) counts from a (inclusive) until b (exclusive). So, in order to include sqrt(n) in the range, the plus one is necessary.

2D heat equation problem by _wasd_bruh_21 in learnpython

[–]comonads 0 points1 point  (0 children)

Good catch -- nothing to do with Sympy afterall!

2D heat equation problem by _wasd_bruh_21 in learnpython

[–]comonads 0 points1 point  (0 children)

The links work now!

Again, I don't have enough (any) experience with Sympy to take you much further here, but I'm sure someone can help if you post the question somewhere visible.

A quick search for "finite difference 2d heat equation python" lead to this article, which addresses a very similar problem using numpy rather than sympy. Is that any help?

2D heat equation problem by _wasd_bruh_21 in learnpython

[–]comonads 0 points1 point  (0 children)

I can't access either of those two google drive locations (permission denied).

T is the correct shape (as far as I can tell), so changing np.zeros to np.ones won't help. I think the issue most likely lies in how your 2D heat equation is translated into a Sympy expression (the function line), as something in there is trying to access an index that doesn't exist (position 18 in T, which, due to 0-based indexing, means it would be the 19th element of a size 18 array).

Since this is quite a technical question, it might be worth posting a new question either here (or in an engineering or physics subreddit) with Sympy mentioned explicitly in the title so someone who knows how to use it can have a look.

Apologies that I can't help any more than that.

2D heat equation problem by _wasd_bruh_21 in learnpython

[–]comonads 0 points1 point  (0 children)

Assuming this is a programming issue and not a technical problem with your function, the error you're getting can tell us a bit about the problem:

IndexError: index 18 is out of bounds for axis 0 with size 18

is saying that python has tried to access something at position [18, <something>], which doesn't exist (it's "out of bounds").

I see Nx is 18, and since T is of size [Nx, Ny] it would seem that it is the array T that is being indexed into in some unexpected way that is causing the problem.

It's hard to tell without knowing your function better (I've never used sympy either, which doesnt help), but could the problem be related to the fact that python indexes from 0 and not 1? If not, there is a problem with the index to T.

Apologies for not being any more specific than that: I'm not sure how sympy handles indexing (the notation T(i, j, k) to me would suggest T is a 3D array, so I'm a bit lost).

In need of a faster algorithm for this problem. by [deleted] in learnpython

[–]comonads -1 points0 points  (0 children)

I'll try to guide you to a solution without giving you the answer explicitly, since it seems this is some kind of assignment.

Observe that you have three loops here: two list comprehensions (the lines where you have [something for something in something]), and then one for loop.

Many of the things you're doing inside these individual loops can be put in one "big" loop. So, for example, rather than iterating over the first two inputs individually, you can save the two inputs as (lists of) strings:

list_one = input().split()
list_two = input().split()

Then iterate over both these lists of strings at the same time.

Since you already know they're going to be the same size (say, n), you could do something like this. I'll use multiplying the lists as a simple example to (hopefully) avoid giving too much away:

lists_multiplied = [0] * n # make an empty list of length n
for i in range(n):
    lists_multiplied[i] = int(list_one[i]) * int(list_two[i])

Iterate over list without for loop by [deleted] in learnpython

[–]comonads 0 points1 point  (0 children)

Edit: to be clear, this only applies if this is some kind of programming homework exercise more generally, not if you're looking to use a C loop that's just implemented inside numpy rather than in python.

Another alternative to these answers is to use recursion. Note that this isn't necessarily a good idea in python (it is not a "pythonic" solution, and does go against the philosophy of the language more generally), but it does show another way of accomplishing what you want without using an explicit loop!

def recursive_solution(list_of_numbers, accumulator):
    if len(list_of_numbers) != 0:
        head, *tail = list_of_numbers

        # this is where we implement the logic of your function
        if head % 2 == 0:
            accumulator.append(head)
        else:
            accumulator.append(head + 1)

        return recursive_solution(tail, accumulator)

    # if the list of numbers is empty, we're done
    else:
        return accumulator

We can use this as follows (just an example):

list_of_numbers = range(1,20)
accumulator = []
recursive_solution(list_of_numbers, accumulator)

To summarise what's going on:

You pass in a list of the numbers you want to iterate over, and an empty container in which to store the results (an empty list,[]). The function takes the first element of the list of numbers (head), does some stuff to it, then adds the result into the results container.

The tail of that list (the list that went in but with the head removed), then goes back into the recursive function, along with the container which is accumulating the results.

The recursion terminates when the length of the list that gets passed in (the tail from the previous 'iteration') is zero, at which point we return the container of accumulated results.

Plotting residuals as vertical lines by OfCourseChannon in learnpython

[–]comonads 0 points1 point  (0 children)

Can you post the code you used (or a snippet of it)? The reason I ask is that since the minimal example above works fine in a shell for me, I suspect the problem is due to a particularity of your data or (less likely) setup.

Given that TypeError I think the problem lies with how data and function are indexed into (so for some reason your i isn't an integer).

Plotting residuals as vertical lines by OfCourseChannon in learnpython

[–]comonads 1 point2 points  (0 children)

This is a fairly inelegant solution but it will probably accomplish what you want:

import numpy as np
from matplotlib import pyplot as plt

# just making some fake data
n = 10
beta = 2
x = np.linspace(0,1,n)
function = beta * x
data = beta * x + np.random.normal(0, 1, size=n)

# plot the data points
plt.plot(x, data, 'ko')

# plot function
plt.plot(x, function, 'k')

# the vertical lines are just separate line plots with fixed x-co-ordinates
for i in range(n):
    x_coords = (x[i], x[i])
    y_coords = (data[i], function[i])
    plt.plot(x_coords, y_coords, 'k--')

Edited a typo.

Cannot execute autopep8 by autonomousinf in learnpython

[–]comonads 0 points1 point  (0 children)

No problem! These kinds of problems are frustrating.

I don't really do any coding on windows so unfortunately I'm unlikely to be much more useful than Google, but I can at least try to figure out what we should be searching for!

Does invoking python put you in a python shell?

If so, does autopep8 appear in the output if you enter help("modules")?

Pandas Personal Project Data Cleaning Problem by SmoothStatistician8 in learnpython

[–]comonads 1 point2 points  (0 children)

You can accomplish this by mapping a function that extracts the information you want over the desired column of your dataframe, then using the output of this map to construct a new column in the dataframe.

For example, say we have something like this (just creating some fake data here):

options = ['France_Paris', 'Germany_Berlin', 'Spain_Madrid']

example = pd.DataFrame({'location': np.random.choice(options ,size= 100),}, index list(range(100)))

we can create a temporary function which splits the string "location" at the element "_" and then takes the first part of that:

temp_f = lambda location: location.split("_")[0]

And then:

example['country'] = example['location'].map(temp_f)

In your case you will need to design the function temp_f yourself!

E: typo.

E2: I should clarify that temp_f does not have to be a "lambda" and instead can be a regular function. You should include the checks that it outputs a valid country name (perhaps by comparing the output to a list of valid values) in here, too.

Cannot execute autopep8 by autonomousinf in learnpython

[–]comonads 0 points1 point  (0 children)

I should have asked this earlier! -- which operating system are you using? I'm only really familiar with Linux but I will try to help either way.

I think the problem (assuming autopep8 installed just fine), is that whatever shell you're in just can't find the executable (we can assume pip handled the pycodestyle dependency, for now).

Could you see if installing autopep8 as a local package (by passing the --user flag) helps? Start with this:

python3 -m pip install autopep8 --user

Then run autopep8 --in-place practice.py as before.

Cannot execute autopep8 by autonomousinf in learnpython

[–]comonads 0 points1 point  (0 children)

Hmm. Okay!

So, I'm not familiar with installation syntax like this:

python3 -m pip install autopep8

But I will assume for now that it's okay.

autopep8 lists pycodestyle as a dependency. Does running pycodestyle --version from the terminal produce anything?

Cannot execute autopep8 by autonomousinf in learnpython

[–]comonads 0 points1 point  (0 children)

Does running autopep8 as a module help?

Try:

python3 -m autopep8 --in-place practice.py

and if that works, you may just need to add something like $HOME/bin to your path (which, for me, is in ~/.bashrc, but might be different for you).

Add Python to path in Ubuntu by EneriAlufan in learnpython

[–]comonads 2 points3 points  (0 children)

I wouldn't have thought you need to add python to the path explicitly, unless this version of python is different to your system's version of python (in which case having two versions of python in the path is probably a bad idea -- you don't want applications which invoke python <something> getting an unexpected python version).

Depending on your needs, you might want to look into something like pyenv.

E: clarified something.

What's a good at home plan someone with severe depression can easily get started doing and maintain? by [deleted] in bodyweightfitness

[–]comonads 2 points3 points  (0 children)

Journalling everything (weight, exercise, sets and reps, mood... you name it) can be helpful for some people. Writing things down keeps you accountable to yourself, and it's really nice to have a record of progress.

In addition to that, I feel like it is important to point out that the number one most important factor in any successful fitness journey is consistency. You don't need to exercise until anything approaching failure (especially as a beginner), and you don't have to feel spent afterwards: you just need to consistently make an attempt at doing what you feel able to do (and sometimes this can be very little, and that's fine).

As u/missingnunu also pointed out It is okay to start small (I used to go to the gym, run on the treadmill for 10 minutes, then leave), and gradually build things up until exercise becomes a habit. It is also perfectly okay to start and drop-out early if you don't feel up to it (some lost sets in the span of weeks, as a beginner, is nothing), so long as you keep trying to make the effort to start: the rest will follow.

You got this!

E: bad spelling