Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70008

Re: Plotting the integer-and-fraction remainder of a function value modulo 360

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'python,': 0.02; 'operator': 0.03; 'defines': 0.09; 'modulo': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'type,': 0.09; 'python': 0.11; 'behave': 0.16; 'finney': 0.16; 'i.e.,': 0.16; 'integers,': 0.16; 'operator.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'remainder': 0.16; 'say)': 0.16; 'do,': 0.16; 'discussion': 0.18; 'variable': 0.18; '>>>': 0.22; '(in': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'fraction': 0.24; 'integer': 0.24; '(for': 0.26; 'supported': 0.26; 'defined': 0.27; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; 'apparently': 0.31; 'behaving': 0.31; 'kim': 0.31; 'mod': 0.31; 'shoot': 0.31; 'symbolic': 0.31; 'wright': 0.31; 'writes:': 0.31; 'class': 0.32; 'probably': 0.32; 'sense': 0.34; 'skip:d 20': 0.34; 'subject:the': 0.34; "can't": 0.35; 'beyond': 0.35; 'case,': 0.35; 'but': 0.35; 'requirements': 0.37; 'two': 0.37; 'represent': 0.38; 'ben': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'anything': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'how': 0.40; '8bit%:29': 0.60; 'expression': 0.60; 'numbers': 0.61; 'range': 0.61; 'simply': 0.61; "you're": 0.61; 'more': 0.64; 'taking': 0.65; 'between': 0.67; 'evaluate': 0.72; '360': 0.84; 'degrees,': 0.84; 'longitude': 0.84; 'received:125': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Ben Finney <ben+python@benfinney.id.au>
Subject Re: Plotting the integer-and-fraction remainder of a function value modulo 360
Date Thu, 10 Apr 2014 14:54:26 +1000
References <1397104347.74031.YahooMailNeo@web161504.mail.bf1.yahoo.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host jigong.madmonks.org
X-Public-Key-ID 0xBD41714B
X-Public-Key-Fingerprint 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B
X-Public-Key-URL http://www.benfinney.id.au/contact/bfinney-gpg.asc
X-Post-From Ben Finney <bignose+hates-spam@benfinney.id.au>
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)
Cancel-Lock sha1:EOKwyMlClulXy3+4xD1LKbQWHDk=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9112.1397105687.18130.python-list@python.org> (permalink)
Lines 64
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1397105687 news.xs4all.nl 2905 [2001:888:2000:d::a6]:36137
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70008

Show key headers only | View raw


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)
> function expression mod 360?

In Python, you simply use the modulo (‘%’) operator::

    >>> 45.0 % 360
    45.0
    >>> 700.0 % 360
    340.0
    >>> 

> That is, I have a function 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 beyond “they will behave the way the Longitude class
defines them”.

> which is defined in terms of the variable t.

I don't understand what it means for a longitude value to be “defined in
terms of the variable t”.

Can you say more about how these 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-AND-fraction remainder
> after dividing Longitude by 360.

What does it mean to “plot the integer-AND-fraction remainder”? It
sounds like you want to plot two numbers separately, the integer and the
fraction remainder. But that doesn't make much sense to me.

Do you mean simply that you want to plot numbers like ‘3.7’, ‘270.0’,
and ‘48.75’? In which case, this is supported by the native ‘float’
type, and (for better accuracy) by the ‘decimal.Decimal’ type from the
standard library::

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

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

It sounds like this Sage is not behaving as the standard Python types
do, with regard to the modulo ‘%’ operator.

For help with Sage (I don'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 TypeError.

-- 
 \      “If you were going to shoot a mime, would you use a silencer?” |
  `\                                                    —Steven Wright |
_o__)                                                                  |
Ben Finney

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Plotting the integer-and-fraction remainder of a function value modulo 360 Ben Finney <ben+python@benfinney.id.au> - 2014-04-10 14:54 +1000

csiph-web