Skip to content

Commit

Permalink
sort contributors chronologically on team page
Browse files Browse the repository at this point in the history
  • Loading branch information
phfaist committed Sep 30, 2022
1 parent bd634ee commit 1680606
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 12 deletions.
50 changes: 47 additions & 3 deletions generate_ecc_zoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import logging

import dateutil.parser

sys.path.insert(0, '.')
import ecczoogen
ecczoogen.setup_logging(level=logging.INFO)
Expand Down Expand Up @@ -581,16 +583,58 @@ def _llm_as_text(s):
with open(contributors_yml_fname, encoding='utf-8') as f:
loaded_zoo_contributors_info = yaml.safe_load(f)
for user in loaded_zoo_contributors_info:
zooteam = user.get('zooteam', 'code_contributors')
zooteam = user.get('zooteam', None) #'code_contributors')
# make sure user_id is unique
user_id = user['user_id']
if user_id in zoo_users_db:
logger.error(f"User ID {user_id} was assigned twice!\n%r\n%r",
zoo_users_db[user_id], user)
raise ValueError(f"User ID {user_id} was assigned twice!")

# will store the user's contributions in this array
user['_code_contributions'] = []

zoo_users_db[user_id] = user
# sort into the correct team
zoo_contributors_info[zooteam].append(user)

if zooteam is not None:
# sort into the correct team (code contributors will automatically
# be added later)
zoo_contributors_info[zooteam].append(user)


# collect contributions for each user
for code_id, code in zoo.all_codes().items():
if '_meta' in code.source_info:
if 'changelog' in code.source_info['_meta']:
for chg in code.source_info['_meta']['changelog']:
user = zoo_users_db[chg['user_id']]
user['_code_contributions'].append({
'changelog_item': chg,
'code': code,
})
if 'zooteam' not in user:
user['zooteam'] = 'code_contributors'
zoo_contributors_info['code_contributors'].append(user)

#
# Now, sort the code contributors by chronological order of contributions
#
def get_user_earliest_contribution_dt(user):
earliest_dt = None
earliest_contrib = None
for contrib in user['_code_contributions']:
chgdt = dateutil.parser.parse(contrib['changelog_item']['date'])
if earliest_dt is None or chgdt < earliest_dt:
earliest_dt = chgdt
earliest_contrib = contrib
if earliest_contrib is None:
raise RuntimeError(f"?? user {user!r} has no contributions despite being "
f"in the code_contributors team")
return earliest_dt

zoo_contributors_info['code_contributors'].sort(
key=get_user_earliest_contribution_dt
)


#
Expand Down
14 changes: 13 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ backoff = "^1.11.1"
citeproc-py = {'git' = "https://github.com/phfaist/citeproc-py.git"}
Pillow = "^9.0.1"
"ruamel.yaml" = "^0.17.21"
python-dateutil = "^2.8.2"

[tool.poetry.dev-dependencies]

Expand Down
7 changes: 7 additions & 0 deletions schemas/ecc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ _zoo_relations:
#relation_primary_key_field: 'code_id'
#relation_object_field: 'code'

- object_field: '_meta.changelog'
to_object_type: 'user'
relation_primary_key_field: 'user_id'
relation_add_object_field: 'user'
backreference:
field: 'zoo_contributions.code'


properties:

Expand Down
20 changes: 19 additions & 1 deletion test/test_code_yml_features/codes/CSS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ description: |
\end{align}
The above condition guarantees that the \(X\)-stabilizer generators, defined in the symplectic representation as rows of \(H_X\), commute with the \(Z\)-stabilizer generators associated with \(H_Z\).
\begin{table}
\begin{cells}
\celldata<rH>{One\\ Two\\ Three}
\celldata[1-;2]{1\\ 2\\ 3}
\end{cells}
\end{table}
Encoding is based on two related \hyperref[code:binary_linear]{binary linear codes}, an \([n,k_X,d^\prime_X]\) code \(C_X\) and \([n,k_Z,d^\prime_Z]\) code \(C_Z\), satisfying \(C_X^\perp \subseteq C_Z\). The resulting CSS code has \(k=k_X+k_Z-n\) logical qubits and distance \(d\geq\min\{d^\prime_X,d^\prime_Z\}\). The \(H_X\) (\(H_Z\)) block of \(H\) \eqref{eq:parity} is the parity-check matrix of the code \(C_X\) (\(C_Z\)). The requirement \(C_X^\perp \subseteq C_Z\) guarantees \eqref{eq:comm}.
Basis states for the code are, for \(\gamma \in C_X\),
\begin{align}
Expand Down Expand Up @@ -96,4 +103,15 @@ relations:


_meta:
contributors: []
changelog:
- user_id: PhF
date: '2022-03-05'
notes: 'These logs are completely fictitious!'
- user_id: PhF
date: '2021-01-01'






9 changes: 6 additions & 3 deletions test/test_code_yml_features/codes/binary_linear.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ notes:

# Begin Entry Meta Information
_meta:
contributors:
- name: 'Victor V. Albert'
githubusername: valbert4
changelog:
- user_id: VVA
date: '2022-03-05'
notes: 'These logs are completely fictitious'
- user_id: VVA
date: '2021-01-01'
7 changes: 6 additions & 1 deletion test/test_code_yml_features/codes/qubits_into_qubits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,9 @@ description: 'Encodes \(K\)-dimensional Hilbert space into a \(2^n\)-dimensional
# detail: 'code_id4 are other codes of similar encoding but with different physical space structures (classical or quantum)'

_meta:
contributors: []
changelog:
- user_id: PhF
date: '2022-03-05'
notes: 'These logs are completely fictitious'
- user_id: VVA
date: '2021-01-01'
7 changes: 6 additions & 1 deletion test/test_code_yml_features/codes/stabilizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ relations:


_meta:
contributors: []
changelog:
- user_id: PhF
date: '2022-03-05'
notes: 'These logs are completely fictitious'
- user_id: VVA
date: '2021-01-01'
8 changes: 7 additions & 1 deletion test/test_code_yml_features/codes/surface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,10 @@ relations:


_meta:
contributors: []
changelog:
- user_id: VVA
date: '2022-03-05'
notes: 'These logs are completely fictitious'
- user_id: VVA
date: '2021-01-01'

7 changes: 6 additions & 1 deletion test/test_code_yml_features/codes/testcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,9 @@ relations:
detail: 'Description of how this code relates to stabilizer codes.\cite{arXiv:1111.0011}'

_meta:
contributors: []
changelog:
- user_id: PhF
date: '2022-03-05'
notes: 'These logs are completely fictitious'
- user_id: VVA
date: '2021-01-01'

0 comments on commit 1680606

Please sign in to comment.