math-spec-mapping 0.3.16__py3-none-any.whl → 0.3.17__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
1
  # from .documentation import write_top_level_json_description
2
2
  from .starter import remove_dummy_repo_components
3
- from .github import write_scaffold_to_github_issues
3
+ from .github import (
4
+ write_scaffold_to_github_issues,
5
+ find_open_issues,
6
+ create_priority_label_matrix,
7
+ create_milestone_label_matrix,
8
+ )
@@ -1,5 +1,8 @@
1
1
  import os
2
2
  import requests
3
+ from github import Github, Auth
4
+ import pandas as pd
5
+ from dotenv import load_dotenv
3
6
 
4
7
 
5
8
  def write_scaffold_to_github_issues(
@@ -32,3 +35,74 @@ def write_scaffold_to_github_issues(
32
35
  headers=headers,
33
36
  json={"title": issue_name, "body": checklist},
34
37
  )
38
+
39
+
40
+ def find_open_issues():
41
+ load_dotenv()
42
+ g = Github(auth=Auth.Token(os.getenv("GITHUB_TOKEN")))
43
+ repo = g.get_repo("BlockScience/MSML")
44
+ open_issues = repo.get_issues(state="open")
45
+ open_issues = list(open_issues)
46
+
47
+ df = pd.DataFrame(
48
+ [[x.title, x.labels, x.html_url, x.milestone] for x in open_issues],
49
+ columns=["Name", "Labels", "URL", "Milestone"],
50
+ )
51
+ df["Milestone"] = df["Milestone"].apply(lambda x: x.title if x else None)
52
+ df = df.join(
53
+ df["Labels"]
54
+ .apply(lambda x: {y.name: True for y in x})
55
+ .apply(pd.Series)
56
+ .fillna(False)
57
+ )
58
+
59
+ empty = df[df["Labels"].apply(lambda x: len(x)) == 0]
60
+ empty = empty[~empty["URL"].str.contains("MSML/pull")]
61
+ assert len(empty) == 0, "Some issues do not have labels"
62
+
63
+ return df, open_issues
64
+
65
+
66
+ def create_priority_label_matrix(df, exclude_milestones=None):
67
+ if exclude_milestones:
68
+ df = df[~df["Milestone"].isin(exclude_milestones)]
69
+ priority_labels = ["High Priority", "Medium Priority", "Low Priority"]
70
+ labels = list(df.columns[4:])
71
+ labels = sorted([x for x in labels if x not in priority_labels])
72
+
73
+ table = []
74
+ for label in labels:
75
+ row = []
76
+ for priority in priority_labels:
77
+ row.append(df[(df[priority]) & (df[label])])
78
+ table.append(row)
79
+ table = pd.DataFrame(table, index=labels, columns=priority_labels)
80
+ table = table.applymap(
81
+ lambda y: "\n".join(
82
+ y.apply(lambda x: "[{}]({})".format(x["Name"], x["URL"]), axis=1).values
83
+ )
84
+ )
85
+ return table
86
+
87
+
88
+ def create_milestone_label_matrix(df, exclude_milestones=None):
89
+ if exclude_milestones:
90
+ df = df[~df["Milestone"].isin(exclude_milestones)]
91
+ priority_labels = ["High Priority", "Medium Priority", "Low Priority"]
92
+ labels = list(df.columns[4:])
93
+ labels = sorted([x for x in labels if x not in priority_labels])
94
+ milestones = sorted(list(df[~pd.isnull(df["Milestone"])]["Milestone"].unique()))
95
+
96
+ table = []
97
+ for label in labels:
98
+ row = []
99
+ for milestone in milestones:
100
+ row.append(df[(df["Milestone"] == milestone) & (df[label])])
101
+ table.append(row)
102
+ table = pd.DataFrame(table, index=labels, columns=milestones)
103
+ table = table.applymap(
104
+ lambda y: "\n".join(
105
+ y.apply(lambda x: "[{}]({})".format(x["Name"], x["URL"]), axis=1).values
106
+ )
107
+ )
108
+ return table
@@ -788,6 +788,12 @@ def write_state_variables_markdown_reports(ms, path, state, add_metadata=True):
788
788
  out += variable.domain
789
789
  out += "\n\n"
790
790
 
791
+ out += "Updated By:\n"
792
+ for i, x in enumerate(sorted(variable.updated_by, key=lambda x: x.name)):
793
+ out += "{}. [[{}]]".format(i + 1, x.name)
794
+ out += "\n"
795
+ out += "\n"
796
+
791
797
  with open(
792
798
  "{}/State Variables/{}.md".format(
793
799
  path, "{}-{}".format(state.name, variable.name)
@@ -30,6 +30,12 @@ from .Reports import (
30
30
  write_parameter_table_markdown,
31
31
  )
32
32
  from .schema import schema
33
- from .Convenience import remove_dummy_repo_components, write_scaffold_to_github_issues
33
+ from .Convenience import (
34
+ remove_dummy_repo_components,
35
+ write_scaffold_to_github_issues,
36
+ find_open_issues,
37
+ create_priority_label_matrix,
38
+ create_milestone_label_matrix,
39
+ )
34
40
 
35
41
  # from .Convenience import write_top_level_json_description
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: math-spec-mapping
3
- Version: 0.3.16
3
+ Version: 0.3.17
4
4
  Summary: A library for easy mapping of mathematical specifications.
5
5
  Author-email: Sean McOwen <Sean@Block.Science>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -1,4 +1,4 @@
1
- math_spec_mapping/__init__.py,sha256=LvuIbfILQf3UGyHympLJyncfnnpZpEyvN5UDOpi8bWw,1140
1
+ math_spec_mapping/__init__.py,sha256=uuz8qXGzsumq0W4-iAIw2w-xxyI10PhbNlGGQ9MxR60,1244
2
2
  math_spec_mapping/schema.py,sha256=6mrRqzEnTTSXjb19xJ63MBp0KjKH0s7i6TfT4MkAY9k,233
3
3
  math_spec_mapping/schema.schema.json,sha256=hJP2TcV5WPFPmx4u_A5U1xtnpkE1LeYaTeYOXadTot0,30916
4
4
  math_spec_mapping/Classes/ActionTransmissionChannel.py,sha256=zWMo5QsgPh5WGIWXl-xOrZNMXYJXmK6Vejw1dQvi0og,246
@@ -17,9 +17,9 @@ math_spec_mapping/Classes/StateUpdateTransmissionChannel.py,sha256=3hBLvD1lE64Pk
17
17
  math_spec_mapping/Classes/StatefulMetric.py,sha256=plMFMAFEk1y2t4DR5lA2SRC9UrYArsx_W33l3mZSdgE,804
18
18
  math_spec_mapping/Classes/Type.py,sha256=2KFY8d3cv1PzJJ7SSMHJf1zcfQ3ZbqxotK2KgTaLZdM,289
19
19
  math_spec_mapping/Classes/__init__.py,sha256=0zxgOqns_9JybD74HKMVh6aw8ij8WVbfQ4Q_1uWzof0,761
20
- math_spec_mapping/Convenience/__init__.py,sha256=P8WgrbpJkH08GeyOdhF-ITfT4Yd4ny8QJEvZK0fSljc,164
20
+ math_spec_mapping/Convenience/__init__.py,sha256=BEZr1rXohKAknOa3wjNVx3EvSVxDcfftJsvtSw5mvmQ,264
21
21
  math_spec_mapping/Convenience/documentation.py,sha256=1ziWVJznbCUxeAAt03nAdEYtMlXNo5TeedHfgs0vSBU,1625
22
- math_spec_mapping/Convenience/github.py,sha256=mMOhIH3Nvh_91fNTOPjz1oQq1iDq2m5hNLMhtcrr5FU,1025
22
+ math_spec_mapping/Convenience/github.py,sha256=Wddr1FCxcIxaFeiKyvx3mvVDbzjcgTxs4rU8ulc4qXk,3539
23
23
  math_spec_mapping/Convenience/starter.py,sha256=9dBKU3EHscut2wA6Nx1XUmehrFIdr4dCjP9V1BbTF6s,12567
24
24
  math_spec_mapping/Load/__init__.py,sha256=_ga5nHi7U5rY5lCF36_XI9Qmybq4P8R4m5I5mmjLBk8,33
25
25
  math_spec_mapping/Load/action_transmission_channel.py,sha256=9Wer7g2s5SSOcUYuZ0PqSKUVVnW3EvGQJZNXJTwW__0,2561
@@ -45,7 +45,7 @@ math_spec_mapping/Reports/boundary_actions.py,sha256=45BPp4QjWdD-3E9ZWwqgj_nI2-Y
45
45
  math_spec_mapping/Reports/control_actions.py,sha256=NksekZKIPFSIkubttFstKFthc5AU9B9PWRLSl9j1wWs,1216
46
46
  math_spec_mapping/Reports/general.py,sha256=WOOn6Wlb8M4fsdN49FlKLwOka6vJPQ9aCUy88TL2ki0,1610
47
47
  math_spec_mapping/Reports/html.py,sha256=RpyQQON8pDnMmfcyxOsm8UAD5Ad8VKnnW-OyOarTmzA,9711
48
- math_spec_mapping/Reports/markdown.py,sha256=LCc9pbph0vcDvavCAWt1Z4uF2whnS8sVF87Aiyv4o_M,27592
48
+ math_spec_mapping/Reports/markdown.py,sha256=DG0DmzE6Pas5dLLjbSnGa0xmWSFz0IGLa0sT_1MgYvI,27804
49
49
  math_spec_mapping/Reports/mechanisms.py,sha256=d2Rxt3JBYvqAOAYUynl0buYVoXEHrO8EGq7GK6hK8NA,1322
50
50
  math_spec_mapping/Reports/node_map.py,sha256=FdSMDQG16NX6n9sZcH-T5xwsvgjrV9OqBHc9J_VlNK0,3129
51
51
  math_spec_mapping/Reports/parameters.py,sha256=-ucL71lolqU0xvV7yb0sXl4pFMRl5tXNWdoBfUjLOaQ,1944
@@ -54,8 +54,8 @@ math_spec_mapping/Reports/spaces.py,sha256=-76hR5wQBv4lsG000ypBJ-OprjsNjI-rNRMYd
54
54
  math_spec_mapping/Reports/state.py,sha256=QYeCvX5cHeZBrbvMeDsTqJcUDTuDFJSLvPbasjLspk8,3643
55
55
  math_spec_mapping/Reports/tables.py,sha256=O0CNuqh3LMECq5uLjBOoxMUk5hUvkUK660FNnwWUxDY,1505
56
56
  math_spec_mapping/Reports/wiring.py,sha256=u9SvKWy6T-WJUEgFI6-zgZanoOaTTs_2YwmEceDLsV8,1618
57
- math_spec_mapping-0.3.16.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
58
- math_spec_mapping-0.3.16.dist-info/METADATA,sha256=Bm-QWdPR6T4sJDJpc8omA2pKf8Zd_QdEOtwYSK9wHNc,6498
59
- math_spec_mapping-0.3.16.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
60
- math_spec_mapping-0.3.16.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
61
- math_spec_mapping-0.3.16.dist-info/RECORD,,
57
+ math_spec_mapping-0.3.17.dist-info/LICENSE,sha256=ObyEzSw8kgCaFbEfpu1zP4TrcAKLA0xhqHMZZfyh7N0,1069
58
+ math_spec_mapping-0.3.17.dist-info/METADATA,sha256=niURiLlRa8ejIvpDjiOcvg1jFeanlxz-76-Mb1joMsU,6498
59
+ math_spec_mapping-0.3.17.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
60
+ math_spec_mapping-0.3.17.dist-info/top_level.txt,sha256=AImhn9wgazkdV0a9vfiphtQR8uGe2nq-ZIOp-6yUk9o,18
61
+ math_spec_mapping-0.3.17.dist-info/RECORD,,