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

Fixed the doc sets/recursively_enumerated_set.py #37331

Merged
merged 11 commits into from
Mar 25, 2024

Conversation

janmenjayap
Copy link
Contributor

@janmenjayap janmenjayap commented Feb 14, 2024

Modified the doc in sets/recursively_enumerated_set.py (in the section Example: Forest structure) to display the HTML nicely; also corrected some typos.

Sphinx .. MATH:: directive is unable to render the picture environment in LaTeX, as a result of which the image is not begin displayed nicely in sets/recursively_enumerated_set. I generated the pdf and png of the required image by compiling the LaTeX code and attached the image. The inspiration is from Figure: The five complete binary trees with four leaves in combinat/tutorial.

Fixes #37084.

The link of the original documentation -- sets/recursively_enumerated_set.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes. (Not required it seems.)
  • I have updated the documentation accordingly.

⌛ Dependencies

None.

@grhkm21
Copy link
Contributor

grhkm21 commented Feb 14, 2024

I'm not sure creating a new media is a good idea, since it's hard to change. Instead, try following how combinat/bijectionist does it. You can see the result here

@janmenjayap
Copy link
Contributor Author

Hi,
I tried recreating the same stuff using arrays in a local latex environment as follows and it worked.

% LaTeX
\begin{equation*}
\begin{array}{rcl}
    % Root and Legend
    & \text{``\ "} \\
    \text{2) A function of an element enumerating}\quad \quad& \scalebox{1.5}{$\bullet$} & \scalebox{2}{$\leftarrow$}\quad\text{1) An initial element} \\
    \text{its children (if any) \hspace{3.75cm}} & & \\

    % Arrows
    \scalebox{2}{$\searrow$}\hspace{2cm} \scalebox{2}{$\swarrow$}  & \scalebox{2}{$\downarrow$} & \scalebox{2}{$\searrow$} \\[5pt]

    % First Children
    \text{``a"} \hspace{4.5em}& \text{``b"} & \hspace{4.5em}\text{``c"} \\
    \scalebox{1.5}{$\bullet$}\hspace{5em} & \scalebox{1.5}{$\bullet$} & \hspace{5em}\scalebox{1.5}{$\bullet$}\\

    % Second Children
    \begin{array}{rcl}
        \scalebox{2}{$\swarrow$}  & \scalebox{2}{$\downarrow$} & \scalebox{2}{$\searrow$} \\[5pt]
        \text{``aa"} \quad& \text{``ab"} & \quad\text{``ac"} \\
        \scalebox{1.5}{$\bullet$}\hspace{1.65em} & \scalebox{1.5}{$\bullet$} & \hspace{1.65em}\scalebox{1.5}{$\bullet$}\\
    \end{array} & 
    \begin{array}{rcl}
        \scalebox{2}{$\swarrow$}  & \scalebox{2}{$\downarrow$} & \scalebox{2}{$\searrow$} \\[5pt]
        \text{``ba"} \quad& \text{``bb"} & \quad\text{``bc"} \\
        \scalebox{1.5}{$\bullet$}\hspace{1.65em} & \scalebox{1.5}{$\bullet$} & \hspace{1.65em}\scalebox{1.5}{$\bullet$}\\
    \end{array} & 
    \begin{array}{rcl}
        \scalebox{2}{$\swarrow$}  & \scalebox{2}{$\downarrow$} & \scalebox{2}{$\searrow$} \\[5pt]
        \text{``ca"} \quad& \text{``cb"} & \quad\text{``cc"} \\
        \scalebox{1.5}{$\bullet$}\hspace{1.65em} & \scalebox{1.5}{$\bullet$} & \hspace{1.65em}\scalebox{1.5}{$\bullet$}\\
    \end{array} \\
\end{array}
\end{equation*}

Here's the preview for that:
image-array

But, it was kind of difficult to manage the alignments, font size, inverted commas etc in the pyx file itself. I will try to implement it and commit. Thank you.

@mantepse
Copy link
Collaborator

Cool! Could you try to remove the bullet points alltogether?

Also, the arrow labelled 2) must point to an arrow, not to a vertex of the tree.

In fact, either the two arrows labelled 1) and 2) (which "explain" the diagram) should look very different from the other arrows, or should be removed entirely (together with the text "an initial element" and "a function ...").

I would actually vote for removing them: the concept is not all that difficult to understand to warrant such a complicated figure.

@mantepse
Copy link
Collaborator

Great job! Thank you for looking so carefully through the whole text!

Did you use a tool or did you do it by hand?

@janmenjayap
Copy link
Contributor Author

Thank you for your comments :-)

The initial part was done by me; later I used Grammarly to cross-check things. It suggested some modifications like replacing 'depth first search' with 'depth-first search', 'non negative' with 'non-negative' and so on, which I did not appreciate by going through some other documentation of Sage.

Also, I wanted to say that maybe some Sphinx directive like .. raw:: latex (which may at least allow to directly integrate TikZ codes in .pyx/ .py files), .. raw:: html and so, should be enabled in Sage, which may reduce the use of media and allow more flexibility :-)

@mantepse
Copy link
Collaborator

It would be cool if you could finish this, so it makes it into the upcoming release!

@janmenjayap
Copy link
Contributor Author

Hello,
Apologies for the delay and thank you for your patience.

I have made a new commit with the changes suggested. Just a few observations:

  • The final image generated looks as follows:
    recursively_enumerated_set
  • Apparently, \text{``a''} does not act as expected and generates the quotes as follows:
    a
  • Also, the orientation and length of \swarrow and \searrow in the first set of arrows do not seem quite correct; however, \rotatebox[]()() does not work here as it does in the usual LaTeX math environment.

@mantepse
Copy link
Collaborator

Thank you!

One question: it might be even better to simplify to single quotes, as one might be used to from working with sage. I.e.,

''
'a'
'ab'

(and without the \hspace)

What do you think?

@janmenjayap
Copy link
Contributor Author

janmenjayap commented Feb 16, 2024

Consider the following:

  \begin{array}{rcl}
      & {^{`}} {^{'}} \\
      \swarrow & \downarrow & \searrow \\[5pt]
      \text{'a'} & \text{`b'} & \text{``c''} \\
      \begin{array}{rcl}
          \swarrow & \downarrow & \searrow \\[5pt]
          ^{``}aa^{"} & ^{`}ab^{'} & `ac' \\
      \end{array} & 
      \begin{array}{rcl}
          \swarrow & \downarrow & \searrow \\[5pt]
          {\scriptstyle `}ba' & ^{\scriptstyle `}bb^{'} & ^{`}bc^{'} \\
      \end{array} & 
      \begin{array}{rcl}
          \swarrow & \downarrow & \searrow \\[5pt]
          ^{`}ca^{'} & ^{`}cb^{'} & ^{`}cc^{'} \\
      \end{array}
  \end{array}

The output is as follows:
modification

Some observations:

  • Without \hspace it is kind of difficult to customize spacing. I need to check with the different possibilities with \quad, \:, \; and \,.
  • For single quotes with `', the left one tends to get a bit larger than the right one (see ^{`}ab^{'}) and for backtick, it is required to use ^{`} instead of ` (see `ac' ). Also the use of \scriptstyle does not work in ^{`} (see ^{\scriptstyle `}bb^{'}).
  • With double quotes {^{``}} {^{"}}, the sizes of the left and right quotes seem similar (see ^{``}aa^{"}), but the same does not seem true for single quotes (see ^{`}ab^{'}).
  • Use of \text generates desirable results neither for single quotes nor for double quotes (see \text{'a'}, \text{`b'} and \text{``c''} ).
  • Also, I suppose single quotes are generally used for single characters and double quotes for strings (at least in most of the programming languages, but I might be biased 😅).

@mantepse
Copy link
Collaborator

I'd go with

\begin{array}{ccc}
      & ``\," \\
      \hfil\swarrow & \downarrow & \searrow\hfil\\
      ``a" & ``b" & ``c" \\
      \begin{array}{ccc}
          \swarrow & \downarrow & \searrow \\
          ``aa" & ``ab" & ``ac" \\
      \end{array} & 
      \begin{array}{ccc}
          \swarrow & \downarrow & \searrow \\
          ``ba" & ``bb" & ``bc" \\
      \end{array} & 
      \begin{array}{ccc}
          \swarrow & \downarrow & \searrow \\
          ``ca" & ``cb" & ``cc" \\
      \end{array}
  \end{array}

It is not all that nice, but it's readable and very simple.

@janmenjayap
Copy link
Contributor Author

Cool.
I have modified accordingly.

Copy link
Collaborator

@mantepse mantepse left a comment

Choose a reason for hiding this comment

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

looks great! I would like to wait for the linter, to make sure that there is no trailing whitespace. Unfortunately, I do not have the rights to approve the workflow, it seems!

vbraun pushed a commit to vbraun/sage that referenced this pull request Feb 18, 2024
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
Modified the doc in `sets/recursively_enumerated_set.py ` (in the
section `Example: Forest structure`) to display the HTML nicely; also
corrected some typos.
<!-- Describe your changes here in detail -->

<!-- Why is this change required? What problem does it solve? -->
Sphinx `.. MATH::` directive is unable to render the `picture`
environment in LaTeX, as a result of which the image is not begin
displayed nicely in [sets/recursively_enumerated_set](https://doc.sagema
th.org/html/en/reference/sets/sage/sets/recursively_enumerated_set.html)
. I generated the pdf and png of the required image by compiling the
LaTeX code and attached the image. The inspiration is from `Figure: The
five complete binary trees with four leaves` in [combinat/tutorial](http
s://doc.sagemath.org/html/en/reference/combinat/sage/combinat/tutorial.h
tml).

<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
This PR resolves an open issue, that is -- sagemath#37084.
<!-- If your change requires a documentation PR, please link it
appropriately. -->
The link of the original documentation -- [sets/recursively_enumerated_s
et](https://doc.sagemath.org/html/en/reference/sets/sage/sets/recursivel
y_enumerated_set.html).

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x]  The title is concise, informative, and self-explanatory.
- [x]  The description explains in detail what this PR is about.
- [x]  I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes. (Not required it
seems.)
- [x]  I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
None.

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#37331
Reported by: Janmenjaya Panda
Reviewer(s): Martin Rubey
@janmenjayap
Copy link
Contributor Author

It seems that there have been too many commits.
Shall I squash them to a single commit (just for cleanup)?

@mantepse
Copy link
Collaborator

mantepse commented Mar 1, 2024

No, I don't think so.

Copy link
Collaborator

@tscrim tscrim left a comment

Choose a reason for hiding this comment

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

No, I don't think so either. It has useful information of things that have been tried.

@mantepse
Copy link
Collaborator

mantepse commented Mar 1, 2024

@tscrim, did you look at the generated html? I think it looks terrible :-(

I am unhappy about the EXAMPLES: being followed by a heading, and I am unhappy about the example LaTeX - for some reason, the LaTeX - html converter completely messes up the quotes. Maybe we should simply remove them, and use \emptyset for the empty word? (I must say, the example is not all that brilliant, but never mind.)

@janmenjayap
Copy link
Contributor Author

janmenjayap commented Mar 2, 2024

Hello,

I want to make two points.

  1. Regarding the examples, as far as the initial section is concerned, the current doc looks like:
Recursively enumerated set

## Definitions and properties of RES

AUTHORS:

Sébastien Labbé, April 2014, at Sage Days 57, Cernay-la-ville

EXAMPLES:
No hypothesis on the structure

## Definition of No hypothesis on the structure
## Examples of No hypothesis on the structure

Symmetric structure

## Examples of Symmetric structure

Graded structure
## Examples of Graded structure

Forest structure
Forest structure [Ex 1]
## Example 1 of Forest structure
Forest structure [Ex 2]
## Example 2 of Forest structure

This is a temporary solution. I believe we should include the definitions of Symmetric structure, Graded structure and Forest structure and finally it may look like the following:

Recursively enumerated set

## Definitions and properties of RES

AUTHORS:

Sébastien Labbé, April 2014, at Sage Days 57, Cernay-la-ville

No hypothesis on the structure

## Definition of No hypothesis on the structure
EXAMPLES:
## Examples of No hypothesis on the structure

Symmetric structure

## Definition of Symmetric structure
EXAMPLES:
## Examples of Symmetric structure

Graded structure

## Definition of Graded structure
EXAMPLES:
## Examples of Graded structure

Forest structure

## Definition of Forest structure
EXAMPLES:
Forest structure [Ex 1]
## Example 1 of Forest structure
Forest structure [Ex 2]
## Example 2 of Forest structure

This seems like a more robust and better solution concerning the examples than the existing one. This will address both the issues raised by @mantepse and @tscrim and give a better overview of the doc.

  1. Regarding the LaTeX, actually that quotation thing I observed earlier while I generated HTML in my local system and I suggested ^{`}ca^{'} instead of ``ca'' (please take a look at the earlier discussion/ comments on this PR). Yep, either we can try out with the former one (aka ^{`}ca^{'} ) or we may remove the quotations. But, I think the first one is better, as it represents the string structure.

Please consider putting needs work tag as of now :-)
Thank you for this active discussion.

@janmenjayap
Copy link
Contributor Author

Also, the Lint test is failing. I suppose, once again there is some trailing whitespace.
Will fix it (if any).

@tscrim
Copy link
Collaborator

tscrim commented Mar 2, 2024

@mantepse I don’t think it looks that bad, but okay. Let me again suggest keeping how the original version was but changing all of the headings to be .. RUBRIC::. Looking a little more carefully, I don’t think it makes much sense to subhead the examples for the forest structure. Just start and label them one-by-one as .. RUBRIC:: Forest Structure (Example 1) as they are examples.

I don’t think it is useful to duplicate documentation with the (precise) definitions. They are examples. If someone wants the definitions, they can look later in the doc.

I agree with @mantepse that the quotes in the latex looks pretty bad in the html. I would remove them all and replace the empty with $\emptyset$ (\emptyset).

The lint test is very reliable. If it is failing, then it needs to be fixed.

@tscrim
Copy link
Collaborator

tscrim commented Mar 4, 2024

@mantepse What do you think about the doc now?

@mantepse
Copy link
Collaborator

mantepse commented Mar 4, 2024

Looks OK! Possibly the module heading should be Recursively Enumerated Sets, to make it more similar to the rest? (https://deploy-preview-37331--sagemath.netlify.app/html/en/reference/sets/)

@janmenjayap
Copy link
Contributor Author

Is it required to change the file name from recursively_enumerated_set.pyx to recursively_enumerated_sets.pyx and any other such changes that are analogous and possible, concerning recursively enumerated sets?

@mantepse
Copy link
Collaborator

mantepse commented Mar 4, 2024

Is it required to change the file name from recursively_enumerated_set.pyx to recursively_enumerated_sets.pyx and any other such changes that are analogous and possible, concerning recursively enumerated sets?

NO!

Copy link

github-actions bot commented Mar 4, 2024

Documentation preview for this PR (built with commit 162c152; changes) is ready! 🎉

@tscrim
Copy link
Collaborator

tscrim commented Mar 5, 2024

@mantepse Any additional comments? I am ready to set this to a positive review.

@mantepse
Copy link
Collaborator

mantepse commented Mar 5, 2024

Perfect!

@vbraun vbraun merged commit 217a019 into sagemath:develop Mar 25, 2024
15 checks passed
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix documentation of sets/recursively_enumerated_set.py
6 participants