Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Diagram Drawing #1430

Merged
merged 52 commits into from Sep 14, 2012
Merged

Diagram Drawing #1430

merged 52 commits into from Sep 14, 2012

Conversation

scolobb
Copy link
Contributor

@scolobb scolobb commented Jul 18, 2012

Based on the diagram layouts produced by the code in #1429, the code introduced by this pull request allows producing Xy-pic presentations of diagrams.

This pull request should only be merged after #1429.

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: be3da02
branch hash: 1852340b38b3642982a924dfb27985cb4780c3b5

Interpreter 1: ✳️ All tests have passed.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYl-MgDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY2aEhDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYr9sgDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY3cghDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request fails (merged e298666a into be3da02).

@travisbot
Copy link

This pull request fails (merged 1852340b into be3da02).

@travisbot
Copy link

This pull request fails (merged b4cae522 into c84e5df).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: c84e5df
branch hash: b4cae522378147c968bc2ad36aa759ceedc220d7

Interpreter 1: 🔴 There were test failures.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYn-MgDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY7PIgDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY_8AhDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYxqkhDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request fails (merged 2b107948 into 82b045f).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: 82b045f
branch hash: 2b1079485370e536230cee3e79b99fe041b6a1c7

Interpreter 1: 🔴 There were test failures.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYt_8hDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYvaYiDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY7pYiDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY1Z4iDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request fails (merged 72a66e77 into 9ad73da).

@travisbot
Copy link

This pull request fails (merged 92da354f into 9ad73da).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: 5e2cf47
branch hash: 92da354fa02a5297960590fb0c32160e0fc4bbb9

Interpreter 1: ✳️ All tests have passed.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYyqYiDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY-JYiDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY8O8hDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYjo8iDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request fails (merged cc36cbbc into 3519951).

@travisbot
Copy link

This pull request passes (merged 1f9c8187 into 3519951).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: 3519951
branch hash: 1f9c81871caeb115eb4d1b6d5dd36ff89faa3474

Interpreter 1: 🔴 There were test failures.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY2fQiDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY8ewiDA

Interpreter 3: 🔴 There were test failures.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYh-UiDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYnoQjDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request passes (merged b79a4848 into 02daa7d).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@scolobb: Please fix the test failures.

Test command: setup.py test
master hash: 02daa7d
branch hash: b79a484817806a901ce74d5dc5719112457c92fd

Interpreter 1: 🔴 There were test failures.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYwdUiDA

Interpreter 2: 🔴 There were test failures.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYi-UiDA

Interpreter 3: ✳️ All tests have passed.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY3fQiDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY9OwiDA

Automatic review by SymPy Bot.

@travisbot
Copy link

This pull request passes (merged f0e1229b into 98cc80f).

@ness01
Copy link
Contributor

ness01 commented Aug 7, 2012

Can you rebase this onto master? It seems the commits from diagram-layout are still shown here...

@scolobb
Copy link
Contributor Author

scolobb commented Aug 7, 2012

@ness01 , done; sorry, I totally forgot to rebase this branch :-(

@ness01
Copy link
Contributor

ness01 commented Aug 7, 2012

On 07.08.2012 19:32, Sergiu Ivanov wrote:

@ness01 https://github.com/ness01 , done; sorry, I totally forgot to
rebase this branch :-(

No problem. I'll start the reviewing tomorrow.

@scolobb
Copy link
Contributor Author

scolobb commented Aug 7, 2012

No problem. I'll start the reviewing tomorrow.

Cool!

@travisbot
Copy link

This pull request passes (merged d4bdaa5 into 3c2c3c7).

@certik
Copy link
Member

certik commented Aug 7, 2012

@ness01, thanks!

@Krastanov
Copy link
Member

SymPy Bot Summary: ✳️ All tests have passed.

Test command: setup.py test
master hash: 3c2c3c7
branch hash: d4bdaa5

Interpreter 1: ✳️ All tests have passed.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY9ZsjDA

Interpreter 2: ✳️ All tests have passed.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY-_QiDA

Interpreter 3: ✳️ All tests have passed.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYlvAhDA

Build HTML Docs: ✳️ All tests have passed.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY4dUiDA

Automatic review by SymPy Bot.

@ness01
Copy link
Contributor

ness01 commented Aug 8, 2012

I'm going through all commits, and after that will comment on the general structure. Once this is in (hopefully very soon) I will try the code out thoroughly and compile a report on how the diagram drawing is going. We can convert it into some bug reports (maybe) and a wiki page. Just to let you know what is coming ^^.

@ness01
Copy link
Contributor

ness01 commented Aug 8, 2012

Very good work! I have gone through all commits and have very few comments.

"""
Given the required information, produces the string
representation of ``morphism``.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is HUGE. Do you see any way to split it up further?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, splitting it up was pretty easy. I have moved out the three branches of the huge if-statement into separate functions. The resulting functions are still relatively long: 1.5--2 screenful of text, but I believe that does not critically affect readability because of numerous chunks of repetitive code.

@ness01
Copy link
Contributor

ness01 commented Aug 8, 2012

Yay. I'm through.

Previously, some dictionaries were not written according to PEP8
whitespace requirements.
This commit fixes and expands some of the inline comments which are not
very clear.
This commit fixes a couple misformulations and typos in the docstrings
pertaining to diagram drawing.
This commit substitutes some straight for-loops with more expressive
list comprehensions.
This commit improves the docstring of this function by explaining what
it actually does instead of trying describe the code in words.  Further,
this commit cleans up the code by removing nested if statements and
dubious conditional branches.
This method used to be very large due to the amount of heuristics it
incorporated.  This commit essentially factors out the three branches of
the central if-statement of ``_process_morphism`` into three separate
functions.  The four functions resulted after this split up are all less
than two screenful of text, which is easier to both read and maintain.
Similarly to the previous commit, this one splits up the longish
method ``_push_labels_out`` into several methods to treat the
horizontal, vertical, and diagonal cases separately and to then combine
the result.
This commit is another one in the series of commits which split up
longish methods in XypicDiagramDrawer by factoring out independent
functionality in separate methods.  This commit is particularly
concerned with the method ``draw``, which now looks much tidier.
… method.

This commit adds an overview comment to the beginning of ``draw`` which
offers an overall perspective on the steps through which this methods
passes to produce the final result.
This commit splits the testing function into four functions according to
the kinds of diagrams tested.
This commit fixes the layout of section titles throughout the whole
``diagram_drawing.py`` file.
@scolobb
Copy link
Contributor Author

scolobb commented Sep 11, 2012

I have complied with the first round of comments, rebased the branch, and pushed the new version. Test coverage is 97%; I'll fix that soon. I don't know how to test a preview-like function (preview_diagram in my code) though; I haven't seen preview tested in SymPy at all. @ness01 , @asmeurer , is it OK to leave preview_diagram untested?

A couple weeks ago I've found some diagrams which were typeset rather uglily; I'll look into that after cranking up the test coverage. That shouldn't be considered as a stopper for merging this pull-request though; I guess it would be detrimental to keep it open for a longer time.

@asmeurer
Copy link
Member

If you can figure out how to test it, go for it. Otherwise, don't worry about it.

@scolobb
Copy link
Contributor Author

scolobb commented Sep 11, 2012

OK, thank you.

@ness01
Copy link
Contributor

ness01 commented Sep 12, 2012

Finally, if one does typeset a diagram for an article and would like to
omit certain morphism names, it is possible to do so via the arrow
formatter mechanism, either by dropping the names of morphisms which
have a certain property, or by filtering them by name. There is
currently no one-line way to achieve this, but it is trivial to
implement and I could sketch something like that in less than an hour.

That sounds useful. Let's keep it in mind for later.

@ness01
Copy link
Contributor

ness01 commented Sep 12, 2012

On 11.09.2012 13:33, Sergiu Ivanov wrote:

I have complied with the first round of comments, rebased the branch,
and pushed the new version. Test coverage is 97%; I'll fix that soon. I
don't know how to test a |preview|-like function (|preview_diagram| in
my code) though; I haven't seen |preview| tested in SymPy at all.
@ness01 https://github.com/ness01 , @asmeurer
https://github.com/asmeurer , is it OK to leave |preview_diagram|
untested?

A couple weeks ago I've found some diagrams which were typeset rather
uglily; I'll look into that after cranking up the test coverage. That
shouldn't be considered as a stopper for merging this pull-request
though; I guess it would be detrimental to keep it open for a longer time.

Yes. I intend to run the drawer against many examples once it is in and
file bugs. But as you said, it seems bad to keep it open longer than
necessary.

@ness01
Copy link
Contributor

ness01 commented Sep 12, 2012

On 11.09.2012 13:33, Sergiu Ivanov wrote:

I have complied with the first round of comments, rebased the branch,
and pushed the new version. Test coverage is 97%; I'll fix that soon. I
don't know how to test a |preview|-like function (|preview_diagram| in
my code) though; I haven't seen |preview| tested in SymPy at all.
@ness01 https://github.com/ness01 , @asmeurer
https://github.com/asmeurer , is it OK to leave |preview_diagram|
untested?

I think that's fine. I'll look through the branch again as soon as I can
(today or tomorrow).

@scolobb
Copy link
Contributor Author

scolobb commented Sep 12, 2012

Yes. I intend to run the drawer against many examples once it is in and file bugs. But as you said, it seems bad to keep it open longer than necessary.

Cool :-) Looking forward to your bug reports.

I'll look through the branch again as soon as I can (today or tomorrow).

Very good! Thank you!

@ness01
Copy link
Contributor

ness01 commented Sep 12, 2012

I think this looks good! @asmeurer, could you run the bot again?

@asmeurer
Copy link
Member

SymPy Bot Summary: 🔴 Failed after merging scolobb/ct2-diagram-drawing (2ecadb7) into master (cf6bb17).
@scolobb: Please fix the test failures.
✳️ Python 2.5.0-final-0: pass
✳️ Python 2.6.6-final-0: pass
✳️ Python 2.7.2-final-0: pass
✳️ Python 2.6.8-final-0: pass
✳️ Python 2.7.3-final-0: pass
🔴 PyPy 1.9.0-final-0; 2.7.2-final-42: fail
✳️ Python 3.2.2-final-0: pass
✳️ Python 3.3.0-beta-2: pass
✳️ Python 3.2.3-final-0: pass
✳️ Python 3.3.0-beta-2: pass
🔴Sphinx 1.1.3: fail

@ness01
Copy link
Contributor

ness01 commented Sep 13, 2012

Well that's great, isn't it? I'll push tomorrow evening if there are no complaints.

@asmeurer
Copy link
Member

Yes it is. Good work here and this summer.

By the way, I found out I will be taking a category theory course next semester. So I hope that this module will be useful to me then (and also if you start seeing a bunch of bug reports on it next year, that's why). Maybe I'll even try typesetting my homework in LaTeX just so I can use the diagram drawing.

@scolobb
Copy link
Contributor Author

scolobb commented Sep 13, 2012

Well that's great, isn't it? I'll push tomorrow evening if there are no complaints.

Great! Thank you! When you have merged it, I will submit the pull request with the improved Diagram.

Yes it is. Good work here and this summer.

Thank you!

By the way, I found out I will be taking a category theory course next semester. So I hope that this module will be useful to me then (and also if you start seeing a bunch of bug reports on it next year, that's why). Maybe I'll even try typesetting my homework in LaTeX just so I can use the diagram drawing.

Oh, sounds cool :-) By "next semester" do you refer to the semester which starts in January? I do hope that by that time I will have fixed many of the issues with ugly typesetting. I also hope I will have some commutativity proving in place, but it's hard to promise.

@asmeurer
Copy link
Member

Yes, the semester starting in January.

@jrioux
Copy link
Member

jrioux commented Sep 13, 2012

SymPy Bot Summary: ✳️ Passed after merging scolobb/ct2-diagram-drawing (2ecadb7) into master (c49dca1).
✳️ Python 2.7.2-final-0: pass
✳️ Python 3.2.1-final-0: pass
✳️Sphinx 1.1.3: pass
Docs build command: make clean && make html-errors && make clean && make latex && cd _build/latex && xelatex -interaction=nonstopmode sympy-*.tex

ness01 added a commit that referenced this pull request Sep 14, 2012
@ness01 ness01 merged commit 3c884dc into sympy:master Sep 14, 2012
@ness01
Copy link
Contributor

ness01 commented Sep 14, 2012

Well then, here we go! @scolobb, what's next?

@scolobb
Copy link
Contributor Author

scolobb commented Sep 14, 2012

@ness01 , thank you! :-)

My plans for the nearest future are as follows:

  1. Write the GSoC report (it's kind of overdue, sorry :-( )
  2. See if I can raise the test coverage in test_drawing.py to 100% and submit the corresponding pull request (should be trivial)
  3. React to the comments on Correct and improve the sympy.categories.Diagram class. #1531, which introduces the improvements to the Diagram which I have told you about some time ago. I don't insist on an immediate review though, so take your time and only look at that code when you definitely have the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants