Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [generator]

A generator is a generalisation of a subroutine, primarily used to simplify the writing of iterators. The yield statement in a generator does not specify a coroutine to jump to, but rather passes a value back to a parent routine.

0 votes
1 answer
6 views

what is the purpose of this tag <meta name="GENERATOR" content=""/> and how to get this

I am creating my html website. and i need to add this tag. can we add this tag in my html website. can we add this tag in my html website? If yes then what is the complete tag we can add. i made my ...
Umair Ahsan's user avatar
0 votes
2 answers
52 views

Inconsistency of character indexes while trying to parse multiple JSON in a file

I am using the following code to parse JSON multiline objects separated by comma from a webscraped string stored in a .json file: import json def stream_read_json(fn): start_pos = 0 with open(...
Martin Horst's user avatar
0 votes
0 answers
6 views

Taking account of generator ramp constraints in pypsa optimisation

I would like to know how Pypsa handles the ramp constraints (on load, at start-up and at shutdown) of generators. Is it sufficient to fill in these attributes only or does it require additional codes? ...
Amar Becegade's user avatar
2 votes
1 answer
33 views

How to save generator object to png, jpg or other image files

I'm using timeseries-generator from GitHub to get synthetic line graphs. That works good. But now I want to save the plots into a file as sepparate png-images. This is my code so far: i=range(0,4) #...
aibe0815's user avatar
4 votes
2 answers
87 views

Reverse work out the mean using random number seed

In R language version 4.4.1 (the version should not matter, just for the sake of discussion), we write the code : set.seed(1234) x <- 5 y <- rnorm(1, mean = x, sd = 0.1) We will be able to ...
温泽海's user avatar
  • 344
3 votes
1 answer
54 views

Unexpected generator behaviour when not assigned to a variable

Could someone explain the difference between these two executions? Here is my generator function: def g(n): try: yield n print("first") except BaseException as e: ...
Joan Ràfols's user avatar
5 votes
5 answers
551 views

Efficient solution for the same-fringe problem for binary trees

The fringe of a binary tree is the sequence composed by its leaves, from left to right. The same-fringe problem [Hewitt & Patterson, 1970] consists of determining whether two binary trees have the ...
slago's user avatar
  • 5,445
1 vote
4 answers
95 views

Unexpected result from zipping two generators. How does zip work?

I have two generators, one which depends on the output of the other. def do_work(n): for i in range(n): yield i def more_work(x): for i in x: yield i * 2 def main(): x = ...
monopoly's user avatar
  • 544
0 votes
1 answer
32 views

How do I automate dbset operations in my application?

I have a project with a large number of entities and a project that can expand further in the future. At this point, I want to automate my dbset operations. In this case, what kind of generator should ...
JacksonT's user avatar
1 vote
2 answers
115 views

How do I check for a value efficiently in a list of dictionaries in Python?

Say I have a list of dictionaries: universe_creatures = [ {'type': 'dragon', 'weight': 1400}, {'type': 'kraken', 'weight': 6000}, {'type': 'elf', 'weight': 75} ] How can I search if there'...
UpTheIrons's user avatar
0 votes
0 answers
18 views

How to update weights of a generator

I would like to update the weights of a stylegan generator. I have the weights delta. Is this the correct approach: def add_weights_delta(generator, weights_delta): with torch.no_grad(): ...
user23365379's user avatar
0 votes
1 answer
58 views

Python, Tkinter: Apply delay to function inside generator

I am making an application in python tkinter to visualize algorithms. I want to apply a delay (window.after()) to the function partition() called inside quick_sort. The window.after() seems to only ...
Harbourheading's user avatar
0 votes
0 answers
22 views

Error in Graph Convolution Layer using StellarGraph GCN

I am trying to train a StellarGraph GCN Model and i get a dimension error on when fitting. Below is my code. graph = StellarDiGraph(nodes=domains, edges=edges) generator = FullBatchNodeGenerator(graph,...
Panagiotis Sakkis's user avatar
0 votes
1 answer
44 views

Why does comprehension only work with tuples when unpacking in Python?

I tried to use list comprehension on a tuple and it worked fine when unpacking, but not when assigning to a single variable. If I run the following code var1, var2, var3 = (i for i in range(3)) var1 =...
Jme's user avatar
  • 3
-3 votes
1 answer
73 views

Why the result is the same even if the variable isnt static?

char next_char(void){ char letter='a'; while(letter!='z'){ letter=letter+1; char next_char(void); } printf("%c",letter); } When the variable letter is ...
JOHN BOURAS's user avatar

15 30 50 per page
1
2 3 4 5
433