markdown.obsidian.personal.notation.in_standard_information_note

For functions concerning notation notes as they are related to
from unittest import mock
import tempfile
import shutil
from fastcore.test import *
from trouver.helper.tests import _test_directory

Notations in a standard information note

Find notations introduced in note

By double asterisks **

WARNING: The use of double asterisks ** to signify definitions and notations is deprecated.

In the legacy method, string surrounded by double asterisks ** were recognized as marking notations


source

notat_str_from_doub_asts_in_std_info_note

 notat_str_from_doub_asts_in_std_info_note
                                            (info_note:trouver.markdown.ob
                                            sidian.vault.VaultNote)

*Return the LaTeX str’s with notations in a standard information note.

For this function, A LaTeX str is deemed to be a notation if it is surrounded by double asterisks ***

Type Details
info_note VaultNote
Returns list Each str is a LaTeX str, beginning and trailing dollar signs $ (single or double) included.

We can obtain the notation str in an information note:

vault = _test_directory() / 'test_vault_7'
# A note with just one notation:
vn = VaultNote(vault, name='galois_group')
sample_output_1 = notat_str_from_doub_asts_in_std_info_note(vn)
assert len(sample_output_1) == 1
assert sample_output_1[0].startswith('$')
assert sample_output_1[0].endswith('$')
assert not sample_output_1[0].startswith('$$')
assert not sample_output_1[0].endswith('$$')
print(sample_output_1)

# A note with a notation with double asterisks:
vn = VaultNote(vault, name='spectrum_of_a_ring')
sample_output_2 = notat_str_from_doub_asts_in_std_info_note(vn)
assert len(sample_output_2) == 2
assert sample_output_2[1].startswith('$$')
assert sample_output_2[1].endswith('$$')
print(sample_output_2)

# A note with no notations:
assert not notat_str_from_doub_asts_in_std_info_note(VaultNote(vault, name='no_notations_note_about_integral_domains'))
['$\\operatorname{Gal}(L/K)$']
['$\\operatorname{Spec} A$', '$$D(f) = \\{\\mathfrak{p} \\in \\operatorname{Spec} A: f \\not\\in \\mathfrak{p} \\}.$$']
# hide
# Test notation str with asterisks.
vault = _test_directory() / 'test_vault_7'
vn = VaultNote(vault, name='direct_and_inverse_images_of_sheaves')
sample_output = notat_str_from_doub_asts_in_std_info_note(vn)
# sample_output
assert len(sample_output) == 2

By HTML tags

Now, HTML tags are used to mark notations


source

notat_str_from_html_tags

 notat_str_from_html_tags
                           (info_note:trouver.markdown.obsidian.vault.Vaul
                           tNote)

*Return the LaTeX str’s with notations in a standard information note.

For this function, HTML tags with the notation attr are deemed to contain (newly introduced) notations. The notation attribute can have multiple strings separated by double semicolons ;; and not surrounded by dollar signs $.

The following are some examples of HTML tags with the format described above:

  1. \(H^i\)
  2. \(h^i := \dim_k H^i\)
  3. $\(IJ = \langle ab: a \in I, b \in J \rangle, \quad I+J = \{a+b: a \in I, b \in J \}\)

Raises - UserWarning - If an HTML tag with a notation attr does not surround a pure math mode string.*

Type Details
info_note VaultNote
Returns list Each str is a LaTeX str, the first of which is the text of and surrounded by the HTML tag and the second of which is a string (without surrounding dollar signs) specifying the actual notation introduced in the first text.
text = 'Let $K$ be a field. An <b definition="Abelian variety over a field">Abelian variety over $K$</b> is a variety that'
with mock.patch('__main__.VaultNote.text') as mock_vaultnote_text:
    mock_vaultnote_text.return_value = text
    listy = notat_str_from_html_tags(
        VaultNote('', ''))
    assert not listy
text = 'Given an ordering, we write <span notation="">$<$</span> for the less-than symbol'
with mock.patch('__main__.VaultNote.text') as mock_vaultnote_text:
    mock_vaultnote_text.return_value = text
    listy = notat_str_from_html_tags(
        VaultNote('', ''))
    test_eq(listy, [('$<$', '')])

Notation notes listed in see also section


source

notation_notes_linked_in_see_also_section

 notation_notes_linked_in_see_also_section
                                            (info_note:trouver.markdown.ob
                                            sidian.vault.VaultNote,
                                            vault:os.PathLike,
                                            as_vault_notes:bool=True)

*Return a list of notation notes listed in the See Also section of the standard information note.

In the current implementation of this function, only “notation notes” that actually exist are included in the returned list.*

Type Default Details
info_note VaultNote
vault PathLike Path to the vault directory.
as_vault_notes bool True If True, returns each notation note as a VaultNote object. Otherwise, returns the name of each notation note. Defaults to True.
Returns Union Each entry corresponds to a notation note in the vault.

The notation_notes_linked_in_see_also_section method detects the Notation notes listed in bulleted links in the See Also section of a standard information note.

vault = _test_directory() / 'test_vault_7'
vn = VaultNote(vault, name='twist_of_a_graded_module')
sample_output = notation_notes_linked_in_see_also_section(vn, vault)
assert len(sample_output) == 1
assert isinstance(sample_output[0], VaultNote)
print(sample_output[0].name)
assert sample_output[0].exists()
foag_notation_M_n_bullet

Setting as_vault_notes=False returns the names of the notation notes.

vault = _test_directory() / 'test_vault_7'
vn = VaultNote(vault, name='twist_of_a_graded_module')
sample_output = notation_notes_linked_in_see_also_section(vn, vault, as_vault_notes=False)
assert len(sample_output) == 1
assert isinstance(sample_output[0], str)
print(sample_output[0])
foag_notation_M_n_bullet

If a “notation note” does not exist, then it is not included in the returned list.

Note that notation_notes_linked_in_see_also_section uses bulleted_links_of_type_in_section, which is turn uses note_is_of_type to get a list of linked notes of the type NOTATION_NOTE of the PersonalNoteTypeEnum class. In turn, a note file must exist for the note to be considered of any particular type under the current implementation of note_is_of_type.

vault = _test_directory() / 'test_vault_7'
vn = VaultNote(vault, name='note_with_links_to_non_existent_notation_notes')
sample_output = notation_notes_linked_in_see_also_section(vn, vault, as_vault_notes=True)
test_eq(sample_output, [])
sample_output = notation_notes_linked_in_see_also_section(vn, vault, as_vault_notes=False)
test_eq(sample_output, [])

Find all notation notes in a vault subdirectory


source

notations_and_main_notes

 notations_and_main_notes (vault:os.PathLike,
                           subdirectory:Optional[os.PathLike]=None, note:O
                           ptional[trouver.markdown.obsidian.vault.VaultNo
                           te]=None)

*Return a dict with all of notation notes in a specified subdirectory of a vault and the names of the main notes of these notation notes.

Returns - dict

Raises

  • ValueError
    • If subdirectory and note are both None.*
Type Default Details
vault PathLike Path to the vault directory.
subdirectory Optional None Path to the subdirectory, relative to vault, to find the notation notes. Searches for all notation notes here and in subdirectories of this subdirectory. If None, then the note parameter is used to determined the subdirectory. Ifsubdirectoryis the empty str, then all notation notes in the vault are searched. Defaults toNone. | | note | Optional | None | A note in the vault. The directory that this note is in determines thesubdirectoryparameter if the argument passed tosubdirectoryis the blank str. This note can usually be an index note, e.g.’_index_silverman’. Defaults toNone, in which casesubdirectorymust be specified. | | **Returns** | **dict** | | **A key is the unique name of a notation note in the vault and its corresponding value is the name of the main note of the notation note. Each main note may not actually exist, but each notation note definitely exists. If the notation note has no main note (i.e. has no links to other notes), then the value isNone`.**

The notations_and_main_notes function returns all the notation notes in a subdirectory of a vault

vault = _test_directory() / 'test_vault_7'
sample_output = notations_and_main_notes(vault, subdirectory='')
print(sample_output)
assert 'foag_notation_M_n_bullet' in sample_output
assert 'some_reference_name_notation_O_X_this_file_has_no_links' in sample_output
assert sample_output['some_reference_name_notation_O_X_this_file_has_no_links'] is None
assert 'poonen_curves_notation_Z_X_T' in sample_output
{'foag_notation_M_n_bullet': 'twist_of_a_graded_module', 'notation_note_with_main_note_link_but_main_note_does_not_exist': 'nonexistent_note', 'some_reference_name_notation_k_t_formal_power_series_ring': 'some_note', 'some_reference_name_notation_O_X_this_file_has_no_links': None, 'some_reference_name_notation_Pic_C': 'divisor_class_group_of_a_curve', 'some_reference_name_notation_Spec_A': 'spectrum_of_a_ring', 'foag_notation_O_n': 'foag_15.2.1', 'foag_notation_O_text_Proj__S__n': 'foag_15.2.1', 'poonen_curves_notation_zeta_X_s_zeta_function_of_variety': 'poonen_curves_3.4.1 DEFINITION', 'poonen_curves_notation_Z_X_T': 'poonen_curves_3.4.1 DEFINITION', 'some_reference_name_notation_B_R': 'note_with_some_excessive_notation_notes', 'some_reference_name_notation_B_R_1': 'note_with_some_excessive_notation_notes', 'some_reference_name_notation_Jac_C': 'note_with_some_excessive_notation_notes', 'test_notation_note_for_latex_in_original_metadata_1': 'test_note_for_latex_in_original_metadata', 'test_notation_note_for_latex_in_original_metadata_2': 'test_note_for_latex_in_original_metadata', 'foag_notation__otimes_A_quad_obj_Mod_A_times_obj_Mod_A_longarrow_obj_Mod_A_': 'foag_1.3.5', 'notation_note_with_auto_notation_summary_tag': 'main_note_of_notation_note_with_auto_notation_summary_tag'}

Here is an example with a subdirectory specified:

vault = _test_directory() / 'test_vault_7'
sample_output = notations_and_main_notes(vault, subdirectory='some_other_folder')
print(sample_output)
assert 'foag_notation_M_n_bullet' not in sample_output
assert 'some_reference_name_notation_O_X_this_file_has_no_links' not in sample_output
assert 'poonen_curves_notation_Z_X_T' in sample_output
{'foag_notation_O_n': 'foag_15.2.1', 'foag_notation_O_text_Proj__S__n': 'foag_15.2.1', 'poonen_curves_notation_zeta_X_s_zeta_function_of_variety': 'poonen_curves_3.4.1 DEFINITION', 'poonen_curves_notation_Z_X_T': 'poonen_curves_3.4.1 DEFINITION', 'some_reference_name_notation_B_R': 'note_with_some_excessive_notation_notes', 'some_reference_name_notation_B_R_1': 'note_with_some_excessive_notation_notes', 'some_reference_name_notation_Jac_C': 'note_with_some_excessive_notation_notes'}

Alternatively, we can specify a subdirectory by a VaultNote object; the directory that the VaultNote object is the subdirectory:

vault = _test_directory() / 'test_vault_7'
vn = VaultNote(vault, name='galois_group')
sample_output = notations_and_main_notes(vault, subdirectory=None, note=vn)
print(sample_output)
assert 'foag_notation_M_n_bullet' in sample_output
assert 'some_reference_name_notation_O_X_this_file_has_no_links' in sample_output
assert sample_output['some_reference_name_notation_O_X_this_file_has_no_links'] is None
assert 'poonen_curves_notation_Z_X_T' not in sample_output
{'foag_notation_M_n_bullet': 'twist_of_a_graded_module', 'notation_note_with_main_note_link_but_main_note_does_not_exist': 'nonexistent_note', 'some_reference_name_notation_k_t_formal_power_series_ring': 'some_note', 'some_reference_name_notation_O_X_this_file_has_no_links': None, 'some_reference_name_notation_Pic_C': 'divisor_class_group_of_a_curve', 'some_reference_name_notation_Spec_A': 'spectrum_of_a_ring'}