Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6609107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:40:50+00:00 2026-05-25T19:40:50+00:00

i’ve been reading on this site and can’t seem to find the specific answer

  • 0

i’ve been reading on this site and can’t seem to find the specific answer i want. i’ve tried reading david beasly’s slides on iteration and generators but still can’t quite get the answer i’m looking for though the question seems simple. i’m running a clock-based simulation (Brian for neural networking) and i have a generator that is manipulating the outputs and adding them to a running sum (in order for there to be n exponential decay for a simple low-pass filter). i then want to take the outputs of these generators, at each time-step and then use them in another function to update some of the state variables, it says that since the item is of the generator type i cannot do this. code and explanation of code is as follows:

import numpy
our_range=numpy.arange(0*ms,duration+defaultclock.dt,defaultclock.dt)
a=our_range   
c=defaultclock.t   #this is a clock that is part of the program i'm running, it updates every #timestep and runs through the range given above

def sum_tau(neuron):            #this gives a running sum which i want to access (the alphas can be ignored as they are problem specific)
    for c in a:            #had to express it like this (with c and a) or it wouldn't run
        if c ==0:
            x=0
        elif defaultclock.still_running()==False:
            return
        else:
            x = x*(1-alpha) + p(neuron)*alpha
            print x
            yield x


#p(neuron) just takes some of the neurons variables and gives a number

b=sum_tau(DN)     #this is just to specify the neuron we're working on, problem specific

@network_operation
def x():
    b.next()

the @network_operation means that every clock timestep the function below will be executed, therefore updating the sum to it’s required value.
Now what i want to do here is update a value that is used for the simulation (where d is the output to another generator, not shown, but very similar to b) by typing:

ron= (d/(1-b))

However, it says i cannot use a generator object in this way, i have used print statements to determine that that b (and d) give the outputs i want every timestep (when the simulation is run) but I cannot seem to take these outputs and do anything with them. (more specifically unsupported operand type ‘-‘ for int and generator. i tried converting it to a number with float() but obviously this doesn’t work for the same reason, i feel there must be a very simple solution to my problem but i can’t seem to find it.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:40:51+00:00Added an answer on May 25, 2026 at 7:40 pm

    “more specifically unsupported operand type ‘-‘ for int and generator” Take the hint.

    You can’t use a generator in a trivial formula. You have to “expand” it with a generator expression.

    ron= (d/(1-b))
    

    Has a generator b, right? b is not a “value”. It’s some kind of sequence of values.

    So, you have to apply each value in the sequence to your formula.

    ron = [ d/(1-x) for x in b ]
    

    will get each value of the sequence and compute a new value.

    (It’s not clear if this is actually useful, since the original ron= (d/(1-b)) when b is a collection of values doesn’t make much sense.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.