running into a large bottleneck in my program that takes hours to perform.
I have a Dataframe that is very large. I need to take the columns of the Dataframe and create new columns within same Dataframe. the new columns need to grouped by a specific date once grouped they are ranked . after...
I got this program that I am working on and in it, I got a section that has a try statement and two error except statements.
try:
...
if ...: raise SyntaxError
except SyntaxError:
...
except ValueError:
...
The thing is that the SyntaxErrors are technically ValueErrors, but th...
Okay, this will most likely be the last post I make for Singe Linked List unless significant revision is needed. This post following from here.
Shout out to @hoffmale for showing me the ways of the force.
Here is the header file:
#ifndef SINGLELINKEDLIST_h
#define SINGLELINKEDLIST_h
template
Hello Stackexchangers,
I started to learn c# and while i was writing the same code 100 times in a row, i was wondering if my design is not optimal or i am writing sloppy code.
private void initialiseerVariabelen()
{
int minimum = 0, maximum = 100;
trackBar1.Minimum =...
I'm going to screw around with visualizing Recamán's Sequence, but want to have a good sequence generator to generate the sequence before I start. I want to use a lazy generator for my actual application, but decided to make a strict version first since it will likely be simpler.
This is what I ...
The following C# code is written to fetch the Categories data from SQL Server Database using Asynchronous Task for HttpGet. The Dapper library is used as ORM.
I need help to identify whether the Async Task implementation is correct or any better way to implement?
CategoriesController.cs
public...
Where I stand on Lisp
So, Lisp. It's been on my radar for years and I'm finally getting around to learning it. The syntax is foreign but I find I'm having the most difficulty in the areas of semantics and the standard library. The symbol semantics are giving me tremendous trouble for sure, mainl...
thanks for the code review. I can see definitely yours is working. I output my base64 from a console.log so maybe it went bad in some way. Thanks again. — macm11 secs ago
As an exercise in multithreaded programming, I am trying to implement a basic FIFO task queue. For this, I also implement simplified version of my lock_guard, from STL. Here is the code:
#include <mutex>
#include <iostream>
#include <thread>
#include <chrono>
#include <optional>
namespace cho {...
I'm voting to close this question as off-topic because this question belongs on another site in the Stack Exchange network: Code Review. — vishes_shell22 secs ago
@Duga Oddly enough I'd consider that a valid close reason. Of-course, it doesn't need anything specific since 'Too broad' works just as well, but hey...
The catchment area is having a bad association with the hungry man. The popular things which are common for the involvment of the understanding of the statement is the perusal of the images and though avoiding the sensor . Please understand and will you ?
Please write a javascript code to zoom an image from a already existing image.I am very confused and I am working here as a fellow. Please help me to write this code and I will be expressing my gratitude forever
Im trying to match the pixel spacing between two folders, here matches has 994 keys and it shows that i may take more than a day to compute this. Is there any way i can speed up this operation.
the load series function looks like this
import SimpleITK as sitk
def load_series(path):
reader ...
I have a simple event that the cleint sends to the server, the server can then respond saying if it was successful, or if it failed for some reason.
The client has to send a auth code, which is inside their config class. Below I attempt to throttle it, allowing 2 attempts, then reloading the co...
Aram, please don't promote a product or service here. Also, please remember that your question is about how many fields in a class, not about code review tools. Lastly, please answer my questions, specifically why 15 fields. Why not 14, 16 or 17? — LBear50 secs ago
Aram, please don't promote a product or service here. Also, please remember that your question is about how many fields in a class, not about code review tools. Lastly, please answer my questions, specifically why 15 fields. Why not 14, 16 or 17? Personally, I like prime numbers, so 17 is my choice. That last part is an opinion, by the way. — LBear28 secs ago
I have Activity1, where I display Room database entries in form of LiveData in a RecyclerView, and Activity2, where I have the necessary fields to add and update new entries.
I wonder what is the proper architecture to build this kind of situation, where Activity2 has 2 roles (create and update)...
Read How to Ask, help center and perhaps try this on Code Review - but not with a screenshot of your code, and not with this literal description. Voice your actual concerns, and not "fix anything in this code you find wrong with it please". — CodeCaster50 secs ago
I'm voting to close this question as off-topic because it's a code review. — CodeCaster44 secs ago
@CodeCaster Don't you care redirecting crap like this to Code Review. A question of this quality should be fixed before redirection pops up in anyone's train of thought. — Mast39 secs ago
Imo, It's not a code review. The question for now need big edit. "how can i improve" is not enought context. — xdtTransform43 secs ago
I have a neural network for linear regression:
class Neural(object):
def __init__(self,x,y,hiddensize1,output_size,cost=None,alpha=0.01,reg_coef=0.1):
std=0.1
self.x=x
self.y=y
self.hiddensize1=hiddensize1
self.output_size=output_size
self.cos...
What would be the best way to replace in a long text (about a page) up to 10 variables.
I feel, that there would be something more elegant than this:
string s;
s = string.Format("Lorem ipsum dolor sit amet, consetetur {0} sadipscing elitr, " + Environment.NewLine +
...
So the assignment is:
Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text file. For example, a text file may look like this:
The ADJECTIVE panda walked to the NOUN and then VERB. A nearby ...
I have two tables in my database, which contains a big list of organisations. They are called orgs_main and orgs_sub. This is the structure:
orgs_main:
id | code | name | address |
----------------------------
orgs_sub:
id | code | name | address | merged |
---------------------------------...
Hi, @tushar. The code in the question is incomplete. We only review real, working code. Ideally it must compile without changes. I've checked your GitHub repo and suggest you to post all relevant code here in the question body so it can be reviewed. — sineemore14 hours ago
Did you notice the age of the question?
Why do you think it's incomplete?
The repo is there for context, the code in the question can be reviewed.
If your code is working correctly and you are asking for possible improvements then codereview.stackexchange.com is a better place to ask. Make sure to read their FAQ first, and choose an appropriate title. — Martin R47 secs ago
@Mast (A bit exaggerated) It's like getting a review request for void my_vector::push_back(const T& val) { return emplace_back(val); } The important parts are missing, even though the code might be totally correct
@Mast I see several issues: types WorkerInfo, DoJobArgs, MapReduce, DoJobReply, Map, Reduce are missing. Same stands for their mehods and fields (both exporteed and unexported) that where used in provided snippet. Function `call` is missing.
@hoffmale That's the argument we use against code and challenge descriptions behind a link, since code becomes unreviewable if the link breaks (there no longer is any code). If the problem statement is already in the question, it's a bit of a grey area I guess.
The biggest single problem I have with the code is that it relies on some non-obvious signaling mechanism (who writes to those channels?) - and without that context, one simply cannot see whether that function is working correctly
@Mast I really don't see a meaningful way to review the provided snippet. If we strip all unknown types and functions it becomes a bunch of `go` statements and channel operations. Not that much to review.
@Vogel612 Mostly true literals and unknown variable worker. Also not that much.
No. We require the code to be contained within the question, for the following reasons:
To avoid dependency on third-party hosting services. These links tend to go away after a while.
To prevent review requests of huge projects.
To make it easier to see the code and so it can interest more revi...
In my first CR question, I was looking for feedback about my implementation of a graph data structure and an algorithm for depth first traversal, as I am studying these at the moment.
Although I appreciate many of the reviewers' comments, there seemed to be a focus on code that I deliberately pu...
> If your code is too long (doesn't fit within the 65 000 character limit for posts on Code Review), please select only the portions of the code where you are especially interested in getting reviewed. In such a case, you may add a link to a site where more of your code can be seen, but don't expect anyone here to review it.
@Mast: Going only from the code as posted, submitJob cannot possibly work as intented, unless some very relevant context is missing. it first tries to read from the channel (?) mr.registerChannel and only afterwards (and with a condition) writes to it. If mr.registerChannel isn't primed / written to somewhere else submitJob cannot work. What should I assume for a review?
My verdict currently is that the question as-is cannot be reviewed meaningfully without going through a lot of the code on github, because the snippet itself is either missing crucial context or not working as intended.
@MathiasEttinger (and others that know dataclasses) Do you know if there's a simple way to convert from a dictionary to a dataclass? I know dataclass -> dict is asdict.
You don't use typing properly. Parametrizing generic types should be done using brackets notation (aka __getitem__) not parenthesis (aka instantiation).
You also don't use any feature of dataclasses in your defined classes, so you might as well drop that dependency. Or you could use it properly ...
My code excellent working, but he very slow.
What does my code do:
Step 1. Connecting to 30 DB (consistently)
Step 2. Copying DB file to temp.dat
Step 3. Reading temp.dat
Step 4. Writing read data to file.
So 30 times with different databases.
This take 6-7 second (on powerful notebook), but...
I am sub-classing an object in python and I need to overload a bunch of the methods with very similar logic, essentially a call to super() and then some additional operations. I want to avoid explicitly writing out each of those overloaded methods in that way, so I implemented a decorator.
Is th...
This question got sparked by a recent discussion in the 2nd Monitor about this question: Golang Map-Reduce Master - Channels.
The problem is: How much context is needed to actually review the code in the question? How much should the reviewer assume about functions/types/object states which are ...
This question got sparked by a recent discussion in the 2nd Monitor about this question: Golang Map-Reduce Master - Channels.
The problem is: How much context is needed to actually review the code in the question? How much should the reviewer assume about functions/types/object states which are ...
No I am just lazy and don't have time to finish it.
Personally, I think that question is fine. Sure, there's setup required, but there's no "Your code must be copy-pasteable from the question to an IDE/Compiler/Interpreter/Whatever to be run" rule.
The rules are that you must provide sufficient context to understand the purpose, you must own it, etc.
No rule about "it must be able to be run directly", which I think is the issue here.
@202_accepted This was my fault at stating this as requirement in the comment under the question. Yep, no such rule. My point was - it makes things easier.
@hoffmale No, but your idea is that "there is more setup required to run the code than should be acceptable", which is on the same foundation.
The basic "gist" is that the code doesn't have enough "context", but it does. The OP talks about the purpose, the why, the how, etc. The OP just doesn't talk about "prerequisites."
I mean, if "too much setup" is now a valid reason to ditch a question, there are quite a few that should be gotten rid of.
I've had to Frankenstein a lot of questions to test them, but, unfortunately, that's life.
@sineemore Sure, it makes things easier. So do test-cases. Which should we require?
The question Does this method guarantee that cells in a CSV will be correctly partitioned? is a duplicate of this one (10k+ and mods only) which asks whether a singular function properly 'escapes' bits of text from a CSV when handed to the function.
My personal opinion is that it does not meet t...
@sineemore Should we require test-cases? Because that's the same type-of-idea here.
The idea is that we "need to be able to verify the code works", but that's not always the case. If the OP makes the affirmation that "the code works to the best of their knowledge", then that's good enough for me. If we find a bug, so be it.
Basically: I think the question is perfectly valid, and there is no "hard minimum" on the amount of context required.
I think that an excerpt from my answer to Thomas Ward's meta question provides a good starting point for nailing down the whole "context" thing.
This is how I feel about context personally.
This may or may not be how Code Review feels as a community
The Last Piece of the puzzle
Conte...
@202_accepted you may be interested in my answer, I think that it is short, sweet and to the point, almost exactly what you are saying
@Mast how so? I figured this might turn into a lengthy conversation.
if you know the code base and the library, and still can't figure out what they are doing it should be closed, right?
we are only talking about context, not about whether there is enough code to be run.
@Malachi Absolutely, but where do you draw the line from that to "this is perfectly reviewable"? There's a grey area in between how clear it is what the code is supposed to do.
someone with enough knowledge about the languages involved would not need more context
I could go to a lot of questions and not know what is going on, I would need more context.
yes there is grey area. if you think it is in the grey area, leave it alone and let someone else handle it that has more knowledge about the language and libraries being used
Newbie Alert!
I have been playing around in hacker rank with Python these days, and now pulling my hair out on this question to solve the Euler's problem in the least time required.
Without that in mind, I initially wrote the below code:
t = int(input())
for a in range(t):
n = int(input())...
Reason
I decided to write a new language, partially for the challange and for the following reasons:
I wanted to implement the pipe operator: |>, the lambda operator: '::' and the hash operator: '#'.
Javascript comments were rather jagged, so I replaced /* with @@@
Accessing prototypes was a p...
@Klaus: I'd rather delete this low-quality question, which doesn't even have a Minimal, Complete, and Verifiable example as actually required. Perhaps it could be moved to codereview.stackexchange.com though, but here, it is misplaced. That said, yes, your suggestions are all valuable! — Ulrich Eckhardt58 secs ago
@202_accepted I don't actually care whether I have to do anything to get the code to run. What I do care about are major dependencies on which we as reviewers get no information at all.
It's hard if not impossible to verify whether some code does what it is intended to do if major parts of the required logic reside in other components.
The OP stated that the code only fails some of the test cases due to a time-out, I think this question is on-topic (since we have the tag time-limit-exceeded specifically for this)
@CaptainObvious Since there are no experts on the language available except possibly the OP, who's going to determine whether enough context has been provided?
Good Day,
Attached is some code I have written for my application. It is an OWIN based web server which connects an Alexa Custom Skill, my security camera feed, and Microsoft Azure Face Api.
The number one thing to remember when creating an Alexa custom skill is that the bot times-out after abo...
"But it points to a 'squashed' commit, a long list of commit message headers, without detail. Not really helpful." The person who squashed the original commits should generally ensure that the commit message for the new commit is helpful. This may involve editing the old commit messages, replacing them, or adding some kind of summary. The best practice is likely context-dependent. Unhelpful commit messages from squashing can be caught in code review, just like regular commit messages and code changes. — Chris16 secs ago
So if, in a code review, we find the commit message is in fact unhelpful, is it possible to unsquash it and do it again? If not, then that adds more weight to my feeling that squashing is too dangerous a practice to allow. And yes, it would be by policy—whether squashing becomes part of our policy is something I've been considering carefully, and I'm afraid the 'but reflogs!' counterargument has collapsed now, in my view. — Michael Scheperjust now
I have been playing around in hacker rank with Python these days, and now pulling my hair out on this question to solve the Euler's problem in the least time required.
Without that in mind, I initially wrote the below code:
t = int(input())
for a in range(t):
n = int(input())
temp=0
...
What I Found
I stumbled upon this python method:
def getMaxFailures(nodeCount: int) -> int:
r"""
The maximum number of Byzantine failures permissible by the RBFT system.
Calculated as :math:`f = (N-1)/3`
:param nodeCount: number of nodes in the system
:return: maximum permi...
I am trying to learn OOP by refactoring my existing code (functions only). This example works but I am not sure whether it is pythonic and good practice.
I have a shared library which consist of several file with functions:
color_spaces.py
import cv2
def rgb_to_hsv(image):
print ('hsv')
...
Because they contain implicit assumptions which aren't communicated to the reviewer, and without those it might be impossible to deduce the actual logic
Simplest example: If I know a called function will never return null, I don't need to check for that. If that isn't clear to the reviewer, then he can either assume it's working as intended (never returns null) or that it's a bug (missing null check).
Or say you see a call to a function reportError: Does it throw an exception, or just log the error message somewhere?
First example: you should still handle the null, even if it "can't" return one. You should always make it explicit, or leave a comment why it was excluded.
Write a function sumprimes(l) that takes as input a list of integers l and retuns the sum of all the prime numbers in l in python.
Here are some examples to show how your function should work.
>>> sumprimes([3,3,1,13])
19
>>> sumprimes([2,4,6,9,11])
13
>>> sumprimes([-3,1,6])
0
I have a user interface that I designed for a simple code demo the layout is presented like I want it to be, but barely holding up (malaligned components and half-baked animations) I want it revamped and styled properly. I am still getting my feet wet with CSS but would like this to be done p...
Mad Libs program that reads in text files and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text file.
#!/usr/bin/env python3
# madlib.pyw - Mad Libs program that reads in text files
# and lets the user add their own t...
public void addBird(String art, String location){
boolean found = false;
for (int i = 0; i <birdlList.size(); i++){
if(birdList.contains(art))
found = true;
break;
}
if (!found) {
System.out.println("The bird is...
I need a method which fetches all of the text from a URL (generally a sitemap URL), and returns an IEnumerable of all valid URLs contained in the text returned from the initial address. What I have so far is:
public IEnumerable<Uri> GetSitemapUrls(Uri sitemapUrl)
{
var sitemapText = GetSitem...
@sineemore I have sese.evbpc.com that shows some of this stuff, but it's broke at the moment and I need to fix it. (Meant to do it this weekend, going to do it tonight because I forgot.)
I need to simply count lines of Scala code in project, which includes some package(i.e. directory) hierarchy
import java.io.File
import scala.io.Source
object CountLoc {
def main(args: Array[String]): Unit = {
val parentDir: File = new File(System.getProperty("user.dir"))
def travers...
Is the following code a proper solution to my problem? I have a feeling it can be simplified quite a bit.
function checkboxCount() {
var form = document.forms["calculator"];
var bar5 = form.elements["bar5"];
var foo = document.querySelectorAll("input[name=foo]");
count = 0;
for (var i...