I am trying to create a PSO algorithm template for my project. I've decide to make the Swarm as separate type and PSO class that computes the algorithm. For this program, the intention is to minimize the sphere function, as the result is expected to be close to 0. I am seeking advice in how shoul...
Here is a project that I worked on for a few days in June 2020. Since the algorithm is extremely slow, I looked into methods in order to parallelize operations but did not obtain any satisfactory answers.
https://github.com/aaronjohnsabu1999/tk2NN
Please suggest anything ranging from how to make ...
In the following code, I use the Page_Suspended-handler to perform a database insertion when the application is suspended. Unfortunately, in my real application and not this simple MWE, I have some code like this, but in some very rare cases the insertion did not work.
Since the bug is not reprod...
I need to re-implement three features of C++ OpenVDB library in Go language:
Mesh to volume
template <typename GridType, typename MeshDataAdapter>
inline typename GridType::Ptr
meshToVolume(
const MeshDataAdapter& mesh,
const math::Transform& transform,
float exteriorBandWidth = 3.0f,
f...
Developed epub-reader component and it is working as it should work, but there are cases with some epub files, where first page of book is always aligned on left side, when normally is on center. Those alignments are setup on popup window where you can choose "spread to one page" OR "spread to tw...
I am trying to implement a Reinforcement Learning algorithm called DDPG in TensorFlow 2.x on a custom gym environment. I am new to TF. So, I started with the DDPG TF 1.x implementation from pemami4911. My TF 2.x implementation can be found in a google-colab document.
For some reason, the agent wo...
I've started bash scripting recently and currently I'm working on a program that simplifies backuping using rsync . I'd appreciate any feedback on what I've done wrong / what can be improved.
#!/bin/bash
# Copyright (C) 2020 ##########, e-mail: ##################
# saver comes with NO WARRANTY....
(1) I read your entire post. Did you read my link? (2) To say "I have a solution but I am not sure if it right." doesn't make my comment wrong and also doesn't matter for Stack Overflow. Your question ends with "Do you know any other solution? or tools?" (3) For bad code and best-practice question see codereview.stackexchange.com and be nice to the people there. — Niklas E.52 secs ago
I'm writing a few python scripts to get started. There is sometimes the assumption that most functions should return a value, but some cases are confusing to me.
The next function use *args, an equivalent to the rest operator in javascript, to put all the arguments (any number) into an array name...
I'm trying to get a method to return the closest value to 0.5, and used std::lower_bound. Why does this return the incorrect value, and a value that isn't even in the array?
#include <iostream>
#include <algorithm>
#include <vector>
int test() {
float array[] = {0.730453, 0.69921...
How can I improve the readability of the below function using a list comprehension?
Also, is there a way to improve items() performance?
pricing = {'prices': [{'product_id': 1, 'price': 599, 'vat_band': 'standard'},
{'product_id': 2, 'price': 250, 'vat_band': 'zero'},
...
The code below runs perfectly fine as I want it to. I'd like to create more subclasses to get a better overview over the whole code. Can I place the setter and getter as well as the methods into the extended classes? I'd like to create subclasses as in single room, double room etc. extends room. ...
try stackexchange for codereview. SO is for nonfuncitonal code. judging working code without seeing the code is futile (and offtopic here). — Patrick Artnerjust now
@PatrickArtner This question would be off-topic on Code Review as it is asking us to implement code and does not have the code in the question. In the future please link to the help center 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." — Peilonrayz53 secs ago
@Peilonraz The question would be ontopic in Codereview if the code was posted and asked for a review? — Patrick Artner20 secs ago
@Duga @Mast @SᴀᴍOnᴇᴌᴀ I've decided to write my own version of auto comments. It converts short hand to useful comments, for example that was generated with @[ Patrick Artner], SO[R[CNI, I], W[L]]. I want a review for the output of the comments, how do you think I should do that? I can probably post it on CR but I really don't care for the petty responses I'll get about the Python code, and I don't really want to sink tons more hours into it to safeguard against them.
@Peilonrayz CR Meta would probably be a good spot for that, if you're only concerned about the language. We have a comment templates / canned comments meta.
@DerKommissar I've covered most of the comments on the FPC Meta. But much of the wording there doesn't fit the 'modular' style of my thing. I'll wait to see if anyone has any disagreement with posting on Meta, before posting there :)
I have below code which works fine as its written in bash, i am just posting it here to see if this can be better optimised as per the BASH way. I am have an intermediate understanding in bash so, looking for any expert advise.
Thanks for the reveiw and comments in advanced 🙏 .
BASH CODE:
#!/bin...
@CaptainObvious This question is labeled as belongs on another site, I don't think so, but it is missing context. Before I VTC I'd like others to tell me if I'm correct since python is not my top language.
If you want a review of the used language instead of the code, you can't put it on the main site. Meta could work, but we can just shoot at it in chat as well.
This might be more suitable on codereview.stackexchange.com if you elaborate a bit on what you want to improve. But you should probably fix a few obvious issues first: 1. indentation 2. English variable names. Other than that, you should start by trying to identify parts of your code that could be extracted to functions — Hulk59 secs ago
This question is better suited to codereview.stackexchange.com. It sounds like you're looking for best practices, and guidance on approach. This forum is not appropriate for that type of question. — idream1nC0de11 secs ago
@VisheshMangla Next time, make sure there are no mistakes like that so the answer can focus on the real things. But if the spelling and the basic stuff ain't good, that has to be fixed first.
@VisheshMangla Run black on your code, then run a couple of linters on your code and fix all the output. Then double check you've fixed all of Reinderien's remarks and then post a new question.
ok I ll do so, but it you read the chat for the first `question''s answer i.e., the prior of this I still haven't found out a way to fix that creation of temporary file
I'd recommend running; black, flake8, prospector, pydocstyle, mypy (with the --strict flag) and the likelihood of getting the answer you want should increase.
I need to check if the key of a key/value pair exists in the excel to json data I am reading. I will be reading multiple file and there is not an ability to have the data columns all renamed to match a specific value.
I can get the array object element value using Object.keys(this.jsonData[0]).i...
The objetive is to get a lista of number and then switch the last person surname with the first person surname, when I type '$' it do the changes and finish the program! (POINTERS and DYNAMIC ALLOCATION) -I have to use pointers and dynamic allocation, my code is nice, but I know that it can be be...
I have created a small selenium script that checks for available times to write a test for a drivers license. The program runs every minute and takes approx 50 seconds to run. I have noticed that it's quite unstable, and do not preform optimally because the web-page loads elements dynamically. Ev...
I am trying to implement the LRU Cache but getting error at this case. I am following the pseudocode but looks like I am stuck at
class Node:
def __init__(self, key, val):
self.key = key
self.val = val
self.next = None
self.prev = None
class DoubleLink...
There's an edit war going on in Smart Tic Tac Toe, a reinforcement learning approach . Every edit by one high-rep user is being reverted by the OP with no explanation, and he (sigh) offers this:
keep editing my post and I'll keep rolling it back and let's see who gives up first. You do not own t...
I have modified a recursive function designed to print all the integer partitions of a positive integer. I would like
def partition(number, interesting): # returns all the partitions of number that are included in the interesting list
answer = set()
if number in interesting:
answe...
My point was that if the code works but you want to improve it, it can often go on Code Review; Stack Overflow usually helps people with code that doesn't work. — msanford23 secs ago
I have a range of two columns that I want to search for a "key" and then find the corresponding value in the directly adjacent column. The key is stored in a dictionary that I populated earlier in the program. I then store the value with its corresponding key in the dictionary to display later.
I...
If this is code you've written, and you want a review of all of the code, this question may be better served by checking if it is on topic on Code Review. — Heretic Monkey12 secs ago
@Mast Right. That said, I've voted that the OP undelete that post. I think it was entirely on-topic; my comment on it is simply that any answer would need to be in English.
I am communicating with a machine that sends/received structured binary data to my netcore service. The machine supplier's new library uses Memory in their library's API.
I have written the following code for Ser/Des which works, but seems verbose. I know I can wrap some of this in methods/helper...
I was trying to write a small application with modern practices for CMake and C++ which will talk with JIRA rest api and took some info from it for forming a report about person's activities.
Kindly asking for code review since we are going to use it as a kind of reference example in a company, s...
I'm pretty new to php coding, but i know wordpress for a long time. Also experimenting with bootstrap. I created a new Page Template and modified it a bit. What I'm looking for is to optimize this php code:
<div class="row">
<div class="col kb_landing_left">
<?php
global $post;
...
@ankii IIRC, they don't show up in the list, unless they were a) already shown on the page and b) you've used the "load new questions" (or similar banner) that shows up after some time.
They will then show up with a red background:
(That's taken from my bookmark page for demonstration purposes. The real list looks a little bit different, for obvious reasons ;))
@CaptainObvious Got really excited when I saw the title of this question, but there is only 4 lines of code in the question. Definitely missing context.
I wrote a javascript app with allows the user to add events and get countdown for every event. Also the events and there dates are stored in localStorage.
I want a general review and I think that every second the browser makes a lot of operations like here:
let interval = setInterval(() => {
...
I’m voting to close this question because this belongs on Code Review, another site in the Stack Exchange network. — AndrewL6429 secs ago
@AndrewL64 - Code review is for improving working code. This doesn't work - it runs out of memory because it's the wrong code for a problem like this. — jfriend0051 secs ago
Since your code works and you just want ideas on how to make it more readable, I suggest you post on Code Review Stack Exchange instead. I think your question may be off topic here. — John Wu25 secs ago
I have been working on some code that produces a live graphic of a graph and blocks moving. It works in theory but does not look like how I want. The animation runs very slow when showing both the graph and the blocks together (a code that has each alone works much better). How can I get them to ...
I'm posting my code for a LeetCode problem copied here. If you would like to review, please do so. Thank you for your time!
Problem
Given an Iterator class interface with methods: next() and
hasNext(), design and implement a PeekingIterator that support the
peek() operation -- it essentially pee...