Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'defines': 0.09; 'modulo': 0.09; 'operand': 0.09; 'type,': 0.09; 'python': 0.11; 'behave': 0.16; 'email addr:yahoo.com>': 0.16; 'expression,': 0.16; 'finney': 0.16; 'i.e.,': 0.16; 'integers,': 0.16; 'operator.': 0.16; 'remainder': 0.16; 'say)': 0.16; 'typeerror:': 0.16; 'thursday,': 0.16; 'do,': 0.16; 'thanks,': 0.17; 'discussion': 0.18; 'variable': 0.18; "skip:' 30": 0.19; 'help.': 0.21; 'seems': 0.21; '>>>': 0.22; 'example': 0.22; '(in': 0.22; 'python?': 0.22; 'saying': 0.22; 'to:name:python-list@python.org': 0.22; 'error': 0.23; '>>>': 0.24; 'fraction': 0.24; 'integer': 0.24; 'why.': 0.24; '>': 0.26; '(for': 0.26; 'supported': 0.26; 'defined': 0.27; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'function': 0.29; "doesn't": 0.30; 'url:mailman': 0.30; 'apparently': 0.31; 'behaving': 0.31; 'kim': 0.31; 'mod': 0.31; 'operators': 0.31; 'produces': 0.31; 'shoot': 0.31; 'symbolic': 0.31; 'wright': 0.31; 'writes:': 0.31; 'class': 0.32; 'probably': 0.32; 'url:python': 0.33; 'sense': 0.34; 'skip:d 20': 0.34; 'subject:the': 0.34; 'could': 0.34; 'problem': 0.35; "can't": 0.35; 'something': 0.35; 'beyond': 0.35; 'case,': 0.35; 'but': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'error.': 0.37; 'requirements': 0.37; 'two': 0.37; 'email addr:python.org': 0.37; 'represent': 0.38; 'ben': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'rather': 0.38; 'anything': 0.39; 'skip:_ 30': 0.39; 'does': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'url:mail': 0.40; 'how': 0.40; '8bit%:29': 0.60; 'expression': 0.60; 'received:bf1.yahoo.com': 0.60; 'received:mail.bf1.yahoo.com': 0.60; 'numbers': 0.61; 'range': 0.61; 'simply': 0.61; "you're": 0.61; 're:': 0.63; 'such': 0.63; 'more': 0.64; 'taking': 0.65; 'email name:python-list': 0.65; 'skip:\xe2 10': 0.65; 'between': 0.67; 'header:Reply-To:1': 0.67; 'received:98.139.212': 0.68; 'evaluate': 0.72; 'received:bullet.mail.bf1.yahoo.com': 0.74; '8bit%:46': 0.78; '360': 0.84; 'alone.': 0.84; 'degrees,': 0.84; 'longitude': 0.84; 'received:98.139.212.151': 0.84; 'type(s)': 0.84 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 445662.45699.bm@omp1018.mail.bf1.yahoo.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1397106229; bh=EemI6nTeQ1c3hxTGxg5oPyEiqyJ8IdDaLi5MCkSpujA=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type; b=AWijGe9NgiY+W1l7Dgusl0A8TB/3LfkIbtTo3QO2ELP/MVqmrKjD8pgpZPQ+m71mRfeds0eZA6BZptfNRrJDXCj6GgMJhMr5Yre18mHG18aayvURonxc5nzH71mXz1daIyZxsnDIJOtjBirioCPNKDR7CnES9aXJVII2uhXPiHE= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject: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IHdyb25nOgoKdCA9IHZhcigndCcpCgpMKHQpID0gdCo3MjUuNSUzNjAuMAoKClRoaXMgcHJvZHVjZXMgdGhlIGZvbGxvd2luZyBlcnJvciBtZXNzYWdlOgoKLi4BMAEBAQE- X-Mailer: YahooMailWebService/0.8.182.648 References: <1397104347.74031.YahooMailNeo@web161504.mail.bf1.yahoo.com> <85eh15zsvx.fsf@benfinney.id.au> Date: Wed, 9 Apr 2014 22:03:49 -0700 (PDT) From: Kim Plofker Subject: Re: Plotting the integer-and-fraction remainder of a function value modulo 360 To: Ben Finney , "python-list@python.org" In-Reply-To: <85eh15zsvx.fsf@benfinney.id.au> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="2164780-1011759679-1397106229=:8794" X-Mailman-Approved-At: Thu, 10 Apr 2014 08:47:40 +0200 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Kim Plofker List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 175 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1397112461 news.xs4all.nl 2974 [2001:888:2000:d::a6]:35600 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:70018 --2164780-1011759679-1397106229=:8794 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks, the % operator is indeed what I want, but I want to use it with a f= unction expression rather than with numbers alone. =C2=A0And that seems to = create a type error.=0A=0AHere's an example of what goes wrong:=0A=0At =3D = var('t')=0A=0AL(t) =3D t*725.5%360.0=0A=0A=0AThis produces the following er= ror message:=0A=0A...=0ATypeError: unsupported operand type(s) for %:=0A'sa= ge.symbolic.expression.Expression' and=0A'sage.symbolic.expression.Expressi= on'=0A=0AI can use other arithmetic operators such as + and / in this funct= ion expression, but not %, and I don't understand why. =C2=A0Is it indeed a= Sage-specific problem rather than something I could work around in Python?= =0A=0AMany thanks again for any help.=0A=0AKim=0A=0A=0A____________________= ____________=0A From: Ben Finney =0ATo: python-= list@python.org =0ASent: Thursday, April 10, 2014 12:54 AM=0ASubject: Re: P= lotting the integer-and-fraction remainder of a function value modulo 360= =0A =0A=0AKim Plofker writes:=0A=0A> How can I get = Python to represent a value of a function in degrees,=0A> i.e., with values= between 0 and 360, by taking the (non-integer)=0A> function expression mod= 360?=0A=0AIn Python, you simply use the modulo (=E2=80=98%=E2=80=99) opera= tor::=0A=0A=C2=A0 =C2=A0 >>> 45.0 % 360=0A=C2=A0 =C2=A0 45.0=0A=C2=A0 =C2= =A0 >>> 700.0 % 360=0A=C2=A0 =C2=A0 340.0=0A=C2=A0 =C2=A0 >>> =0A=0A> That = is, I have a function with non-integer values, called Longitude=0A=0AIf the= y're not integers, and you're not saying what they *are*, then I=0Acan't kn= ow anything beyond =E2=80=9Cthey will behave the way the Longitude class=0A= defines them=E2=80=9D.=0A=0A> which is defined in terms of the variable t.= =0A=0AI don't understand what it means for a longitude value to be =E2=80= =9Cdefined in=0Aterms of the variable t=E2=80=9D.=0A=0ACan you say more abo= ut how these values are defined? Since (as you say)=0Athey're not integers,= what *are* they?=0A=0A> I just want to plot Longitude modulo 360 for a ran= ge of values of t:=0A> that is, for every value of t, plot the integer-AND-= fraction remainder=0A> after dividing Longitude by 360.=0A=0AWhat does it m= ean to =E2=80=9Cplot the integer-AND-fraction remainder=E2=80=9D? It=0Asoun= ds like you want to plot two numbers separately, the integer and the=0Afrac= tion remainder. But that doesn't make much sense to me.=0A=0ADo you mean si= mply that you want to plot numbers like =E2=80=983.7=E2=80=99, =E2=80=98270= .0=E2=80=99,=0Aand =E2=80=9848.75=E2=80=99? In which case, this is supporte= d by the native =E2=80=98float=E2=80=99=0Atype, and (for better accuracy) b= y the =E2=80=98decimal.Decimal=E2=80=99 type from the=0Astandard library::= =0A=0A=C2=A0 =C2=A0 >>> lon =3D decimal.Decimal("758.45")=0A=C2=A0 =C2=A0 >= >> lon % 360=0A=C2=A0 =C2=A0 Decimal('38.45')=0A=0A> But Python (in Sage) a= pparently won't let me use the int function or=0A> the // operator on funct= ions defined in terms of a variable: I get a=0A> "cannot evaluate symbolic = expression numerically" TypeError.=0A=0AIt sounds like this Sage is not beh= aving as the standard Python types=0Ado, with regard to the modulo =E2=80= =98%=E2=80=99 operator.=0A=0AFor help with Sage (I don't know what that is)= , you probably will get=0Abetter answers on a Sage-specific discussion foru= m.=0A=0AFrom the perspective of Python, the standard types handle the=0Areq= uirements you describe without any TypeError.=0A=0A-- =0A\=C2=A0 =C2=A0 =C2= =A0 =E2=80=9CIf you were going to shoot a mime, would you use a silencer?= =E2=80=9D |=0A=C2=A0 `\=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =E2=80=94Steven Wri= ght |=0A_o__)=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 |=0ABen Finney=0A=0A-- =0Ahttps://mail.python.org/mail= man/listinfo/python-list --2164780-1011759679-1397106229=:8794 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Thanks, the % operator is indeed what I want, but = I want to use it with a function expression rather than with numbers alone.=  And that seems to create a type error.

Here's an example of what goes wrong:=

t =3D var('t')
L(t) =3D t*7= 25.5%360.0

This produces the following error message:

...=0ATypeError: unsupported operand type(s) for %:=0A'sage.symbolic.ex=
pression.Expression' and=0A'sage.symbolic.expression.Expression'

I can use other arithmetic op=
erators such as + and / in this function expression, but not %, and I don't=
 understand why.  Is it indeed a Sage-specific problem rather than som=
ething I could work around in Python?

Many thanks = again for any help.

Kim


From: Ben Finney <ben+python@ben= finney.id.au>
To: p= ython-list@python.org
Sent: Thursday, April 10, 2014 12:54 AM
Subject: Re: Plotting the integer-and-fraction remainder= of a function value modulo 360

Kim Plofker <kim_plofker@yahoo.com> writes:
=
> How can I get Python to represent a value of a function in degrees= ,
> i.e., with values between 0 and 360, by taking the (non-integer)<= br>> function expression mod 360?

In Python, you simply use the m= odulo (=E2=80=98%=E2=80=99) operator::

    >>> 45= .0 % 360
    45.0
    >>> 700.0 % 360    340.0
    >>>

> That is, I have a functio= n with non-integer values, called Longitude

If they're not integers,= and you're not saying what they *are*, then I
can't know anything beyon= d =E2=80=9Cthey will behave the way the Longitude class
defines them=E2= =80=9D.

> which is defined in terms of the variable t.

I d= on't understand what it means for a longitude value to be =E2=80=9Cdefined = in
terms of the variable t=E2=80=9D.

Can you say more about how t= hese values are defined? Since (as you say)
they're not integers, what *= are* they?

> I just want to plot Longitude modulo 360 for a range= of values of t:
> that is, for every value of t, plot the integer-AN= D-fraction remainder
> after dividing Longitude by 360.

What d= oes it mean to =E2=80=9Cplot the integer-AND-fraction remainder=E2=80=9D? I= t
sounds like you want to plot two numbers separately, the integer and t= he
fraction remainder. But that doesn't make much sense to me.

Do you mean simply that you wan= t to plot numbers like =E2=80=983.7=E2=80=99, =E2=80=98270.0=E2=80=99,
a= nd =E2=80=9848.75=E2=80=99? In which case, this is supported by the native = =E2=80=98float=E2=80=99
type, and (for better accuracy) by the =E2=80=98= decimal.Decimal=E2=80=99 type from the
standard library::

  =   >>> lon =3D decimal.Decimal("758.45")
    >= >> lon % 360
    Decimal('38.45')

> But Python= (in Sage) apparently won't let me use the int function or
> the // o= perator on functions defined in terms of a variable: I get a
> "canno= t evaluate symbolic expression numerically" TypeError.

It sounds lik= e this Sage is not behaving as the standard Python types
do, with regard= to the modulo =E2=80=98%=E2=80=99 operator.

For help with Sage (I d= on't know what that is), you probably will get
better answers on a Sage-= specific discussion forum.

From the perspective of Python, the standard types handle the
requirements you describe without any Typ= eError.

--
\      =E2=80=9CIf you were going to = shoot a mime, would you use a silencer?=E2=80=9D |
  `\   = ;                     &nb= sp;                     &= nbsp;     =E2=80=94Steven Wright |
_o__)      &= nbsp;                    =                     &nbs= p;                 |
Ben Finney<= br>
--
https://mail.python.org/mailman/listinfo/python-list<= /a>


--2164780-1011759679-1397106229=:8794--