Re: [Tutor] How to correct decimal addition.

2014-01-26 Thread spir

On 01/26/2014 04:22 AM, Keith Winston wrote:

On Sat, Jan 25, 2014 at 5:09 PM, Oscar Benjamin
 wrote:

Perhaps it would be better though to point at this:

round(D('0.123456'), 3)

Decimal('0.123')


I think you are right. I didn't even think of round(). I think we have
confounded two issues in this thread, the internal
representation/accuracy, and the final presentation. They aren't
really the same thing, unless we force them to be (i.e. using ints).


Yes. Side-note below.

In programming, there is a general confusion between ideas, such as -1.23> and their representations, like "-1.23" "minus one dot twenty three", 
"moins un virgule vingt-trois", "-1,23", or varipus possible strings of bits. 
There are outer written or spoken representations (numerals, for numbers) and 
internal representations in memory, which we could call "raw data". Raw data are 
meaningless (and type-less). Obviously, many truely believe there are data with 
meaning or type, that is ideas, *in* a machine; especially many speak and 
obviously think as if there were _numbers_ in a computer; as if a machine had a 
mind and thought... Numbers and other ideas are only in "heads" of psychical 
(mental) living things, as far as we know. there are no numbers, colors, texts, 
characters, weapons... in a machine ;-)


The internal representation is no less a representation and a pure convention. 3 
can be written

vv^^
(with, say, bits 'on' and 'off')
it is a pure conventional representation (albeit simple & logical), and works 
because routines supposed to operate on numbers take this conventional 
representation for granted, both for operations and for input/output conversions 
to/from outer written representations.


In both internal and external representations there may be issues related to the 
base (eg in python we can also write hex or bin numbers). And a major issue, 
that will last as long as CPU's don't process decimal fractionals natively 
(so-to-say), is the clash between our expectations related to outer decimals and 
the inner processing in binary representation.


d
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Multi Layered Graphs

2014-01-26 Thread Ankit Arora
I'm working on a project which involves network graphs. Is there a library
that can help me do this:

I want to create multi-layered graphs i.e. graphs which contain a set
number of vertices but multiple 'layers' of edges i.e. same set of vertices
representing two or more properties in the same data structure.

One rather hacky solution can be to form a complete graph in igraph and
deal with the layers as if they were igraph edge attributes, though when
dealing with tens of thousands of vertices on a complete graph it will be
inefficient.

Any clue if something proper exists? If not, any more intelligent solutions
using existing libraries such as igraph/networkx?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Multi Layered Graphs

2014-01-26 Thread Steven D'Aprano
On Mon, Jan 27, 2014 at 03:53:38AM +0530, Ankit Arora wrote:
> I'm working on a project which involves network graphs. Is there a library
> that can help me do this:
> 
> I want to create multi-layered graphs i.e. graphs which contain a set
> number of vertices but multiple 'layers' of edges i.e. same set of vertices
> representing two or more properties in the same data structure.

This may be a bit advanced for the "tutor" list, which is more aimed at 
learning the syntax and standard library. If nobody responds with an 
answer here, you might like to try asking on comp.lang.python, also 
available by email python-l...@python.org.

-- 
Steven

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor