Opened 6 years ago
Closed 6 years ago
#17574 closed defect (fixed)
Empty hypergraph and __str__ function
Reported by: | ncohen | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | sage-6.5 |
Component: | combinatorial designs | Keywords: | |
Cc: | vdelecroix | Merged in: | |
Authors: | Nathann Cohen | Reviewers: | Dima Pasechnik |
Report Upstream: | N/A | Work issues: | |
Branch: | 514dd64 (Commits) | Commit: | 514dd6484b29cb40474f09408301b968678cc9d2 |
Dependencies: | Stopgaps: |
Description
Right now an exception is raised when building the empty hypergraph. This branch fixes it:
sage: sage: IncidenceStructure([]) Incidence structure with 0 points and 0 blocks
Also, right now the class has both a __repr__
and a __str__
function, which means that typing H
in a console does not produce the same output as typing print H
in a script. The two functions are made equal: I work often with this class and pretty often the result of print H
takes a whole screen, as it displays *all blocks*.
Nathann
Change History (9)
comment:1 Changed 6 years ago by
- Branch set to u/ncohen/17574
- Status changed from new to needs_review
comment:2 Changed 6 years ago by
- Commit set to 871738feb57aaa75d015c2fb3af8900a57d50270
comment:3 follow-up: ↓ 4 Changed 6 years ago by
Hey,
It can be useful to keep a function printing all blocks as it is the case with matrices right now with the method .str()
:
sage: m = random_matrix(ZZ,100) sage: m 100 x 100 dense matrix over Integer Ring (use the '.str()' method to see the entries) sage: print m 100 x 100 dense matrix over Integer Ring sage: m.str() ... # crazy string
And it is true that __repr__
and __str__
coincide.
sage: m.__repr__() '100 x 100 dense matrix over Integer Ring' sage: m.__str__() '100 x 100 dense matrix over Integer Ring'
To get a hint when only m
is typed, you need to hack repl/display/fancy_repr.py
.
Vincent
comment:4 in reply to: ↑ 3 Changed 6 years ago by
Yo !
It can be useful to keep a function printing all blocks as it is the case with matrices right now with the method
.str()
:
But we have H.blocks()
, don't we ? Why would we need something else ?
On the other hand, I often need to control variables, to make sure that the input is a PairwiseBalancedDesign
and not just an incidence structure, and all that I could do so far was print H.__repr__()
.
Nathann
comment:5 Changed 6 years ago by
Beep ?...
comment:6 Changed 6 years ago by
- Commit changed from 871738feb57aaa75d015c2fb3af8900a57d50270 to 514dd6484b29cb40474f09408301b968678cc9d2
comment:7 Changed 6 years ago by
- Reviewers set to Dima Pasechnik
- Status changed from needs_review to positive_review
LGTM
comment:8 Changed 6 years ago by
Thaaaaaaaaaaaaaaaaaaaanks!!!
Nathann
comment:9 Changed 6 years ago by
- Branch changed from u/ncohen/17574 to 514dd6484b29cb40474f09408301b968678cc9d2
- Resolution set to fixed
- Status changed from positive_review to closed
Branch pushed to git repo; I updated commit sha1. New commits:
trac #17574: Empty hypergraph and __str__ function