I am aware, that libraries exist for parsing python code, however, for the sake of learning how they parse errors, I'm creating a script that checks a file for only 6 Pep8 errors just for reference.
This is how my current 6 Pep8 functions look (they append an issue to the issues list, if issue wa...
You say that you "weren't sure of the best way". Were you able to produce a way? If so, what you do is go to codereview.stackexchange.com, read their policies, and see if they have suggestions to improve your working attempt. — Karl Knechtel19 secs ago
I am using a Deep Learning model I trained and want to improve its accuracy by implementing a rolling average prediction. I have already done it but want to improve it as I am making predictions on every 3 frames.
Input:
Each index represents a class and the respective prediction the model makes....
I have pre-defined code for the ants/bees dataset (2 labels) as follows:
%matplotlib inline
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
from torch.autograd import Variable
import numpy as np
import torchvision
from torchvision import dataset...
@Andreas This question would be off-topic on Code Review as it does not work as intended. In the future please link to the help center and use wording that shows the post may be off-topic when recommending Code Review. Take, "This may be on-topic on Code Review. Please check if it is on-topic and how to post a good question before posting there." — Peilonrayz58 secs ago
I've written a short script to print a number to a string. This actually was very difficult for me to do -- I'm not sure if this is actually a tricky task or just because I'm so new to asm I was having a hard time. Here it is:
SYS_EXIT = 60
SYS_WRITE = 1
SYS_STDOUT = 1
.section .rodata
num...
This is exercise 3.2.23. from the book Computer Science An Interdisciplinary Approach by Sedgewick & Wayne:
Write a recursive Turtle client that draws dragon fractal.
The following is the data-type implementation for Turtle graphics from the book which I beautified:
public class Turtle {
priv...
avoid this king of expressions. They do not have any practical use. Actually if I see something like this doing the code review - I ask to rewrite the whole thing. — P__J__46 secs ago
The following code asynchronously extract title from urls (saved in book-urls.txt).
from bs4 import BeautifulSoup
import grequests
links = list()
file1 = open("book-urls.txt", "r")
Lines = file1.readlines()
for line in Lines:
links.append(line)
file1.close()
reqs = (grequests.get(link) for...
Google Translate (if anyone happens to know a decent alternative that covers more languages than Deepl does, please tell) has this window notifying users of an upcoming change.
In Dutch, it says "Geplande wijzigingen in de geschiedenis", which basically translates to "Planned changes in/to history".
And I'm like "What?! They're going to time-travel?"
I am building a project and I have some parameters which I want to fix through all the modules of the project.
Below are the parameters -
# Deterministic Behaviour
seed = 1
os.environ['PYTHONHASHSEED'] = str(seed)
## Torch RNG
torch.manual_seed(seed)
torch.cuda.manual_seed(seed)
torch.cuda.manual...
@Peilonrayz My take is they are asking for a feature request and that means the code isn't written yet, what is clear is they are asking what a best practice.
@Mast @Peilonrayz Is there a way to create a module for import ala C or C++ and header files in python?
@Mast If I understand correctly they're asking for a file structure review. Like this. I don't think we have a "we don't review this language" close reason so, eh something will stick.
@Mast I think that'd be the cherry on top for this week. Worst case we can point to the meta I linked to and go through the help center. I'm sure we'd find a way to explain it.
@pacmaninbw You can import packages, modules and classes in Python. A module is just a Python file that is in your Python PATH or a package, you import it by importing it's name minus the .py. A package is a folder that contains modules and an __init__.py, the folder has to be in the Python PATH, you can import it by importing the folder's name. A class is just a class in a module, you can import it by importing the class' name. E.g. import package.module.class.
In the question the import_packages folder is a package and all the .py files are modules.
One of the projects that have been on my to-do list since years involves controlling a number of Inter-Integrated Circuit (\$I^2C\$) peripherals. Lately I've been turning everything into it's own library and I'm wondering if I'm doing it right.
While the libraries are usually called by a server-...
I've created a Life implementation in javascript with the goal to be as fast as possible, with the rendering I'm satisfied (see picture bellow), hovever the next state calculation is really slow and I'm out of ideas how to speed it up even more.
Current state of the implementation
Rendering
Scree...
@Mast My favourite is when you have two, or more, one off errors in the same function. I remember that happening to me fairly vividly, never again. I'd fly the SRP flag for that alone.
I have this program finding 2 numbers in the array (unsorted) so that its sum equal to the target sum. Here is my program:
vector<int> findNumbers(vector<int>& nums, int target)
{
vector<int> result;
for(int i = 0; i < nums.size() - 1; i++)
for(int j = i + 1; j < ...
@pacmaninbw Doesn't look like it, "if I remove it, it will cause error." But the last return is not removed. And how is it at all MRC? It's a fully functioning two sum function...
@Peilonrayz But in the last line, the return result doesn't seem to do anything,
The reason they can't remove it is in the declaration of the function, it must return a vector. Seeing the calling code might provide some idea how that can be rectified.
This code runs properly, tested on the various test cases. But is my approach, right?
#include<stdio.h>
#include<math.h>
int primefactors(int);
int main()
{
int num;
printf("Enter a no:-\n");
scanf("%d",&num);
printf("%d",primefactors(num));
return 0;
}
int primefactors(int n)...
I want to disable the dimming of the background when an alert dialog is shown.
An option would be to design my own type of dialog box, but I rather not
My code:
public void infoWindow() {
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("name");
alert.setMess...
@EOF Code Review isn't where to go to ask if your code is correct, it's where you go if you think/know it's correct and want open-ended constructive feedback on how to improve it. If this were posted on CR, it'd be downvoted and closed promptly. See CR on topic. — ggorlen1 min ago
@ggorlen I don't think the question is off-topic on Code Review, nor does it have any close votes there. As "To the best of [the OPs] knowledge, [...] the code work[s] as intended". Since they've tested it this is true. And it looks like they're looking for "correctness in unanticipated cases" or just a general review. — Peilonrayz45 secs ago
@WeatherVane Sorry, I don't understand the parallels you are drawing. I only see you saying it makes a good question for Code Review as we can expose this problem and help the OP write better code. — Peilonrayz36 secs ago
This sounds more on-topic on Code Review than here, but even there you'll have to include your code in the question not just a link to it. — Bergi58 secs ago
Welcome to Stack Overflow! Please note that there are many other Stack Exchange forums besides Stack Overflow. In this specific case, your question would be more suitable to the Code Review community in the following link: codereview.stackexchange.com — My Koryto27 secs ago
@Duga @pacmaninbw This may shed a little light on this comment. Additionally the first version had some problematic wording. In that it's common to misinterpret.