prefab 1.1.5__py3-none-any.whl → 1.1.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
prefab/__init__.py CHANGED
@@ -5,7 +5,7 @@ Usage:
5
5
  import prefab as pf
6
6
  """
7
7
 
8
- __version__ = "1.1.5"
8
+ __version__ = "1.1.6"
9
9
 
10
10
  from . import compare, geometry, predict, read, shapes
11
11
  from .device import BufferSpec, Device
prefab/__main__.py CHANGED
@@ -1,4 +1,4 @@
1
- """Provides the main entry point for the Prefab CLI."""
1
+ """Provides the main entry point for the Prefab authentication CLI."""
2
2
 
3
3
  import argparse
4
4
  import os
@@ -10,13 +10,17 @@ from http.server import BaseHTTPRequestHandler, HTTPServer
10
10
  import toml
11
11
 
12
12
 
13
- def store_jwt_securely(jwt, refresh_token):
14
- """Store the JWT and refresh token securely in a TOML file."""
15
-
13
+ def store_jwt(jwt, refresh_token):
14
+ """Store the JWT and refresh token in a TOML file."""
16
15
  prefab_file_path = os.path.expanduser("~/.prefab.toml")
17
16
  with open(prefab_file_path, "w", encoding="utf-8") as toml_file:
18
17
  toml.dump({"access_token": jwt, "refresh_token": refresh_token}, toml_file)
19
- print(f"Token successfully stored in {prefab_file_path}")
18
+ print(
19
+ f"Token successfully stored in {prefab_file_path}.\n\n"
20
+ "🎉 Welcome to PreFab!.\n"
21
+ "See our examples at https://docs.prefabphotonics.com/examples to start.\n"
22
+ "Reach out to us at hi@prefabphotonics.com if you have any questions."
23
+ )
20
24
 
21
25
 
22
26
  class GracefulHTTPServer(HTTPServer):
@@ -29,7 +33,7 @@ class GracefulHTTPServer(HTTPServer):
29
33
 
30
34
 
31
35
  class CallbackHandler(BaseHTTPRequestHandler):
32
- """A request handler for the HTTP server that handles the OAuth callback."""
36
+ """A request handler for the HTTP server that handles the JWT-auth callback."""
33
37
 
34
38
  def do_GET(self):
35
39
  if self.path.startswith("/callback"):
@@ -41,8 +45,8 @@ class CallbackHandler(BaseHTTPRequestHandler):
41
45
  jwt_token = params.get("token")
42
46
  refresh_token = params.get("refresh_token")
43
47
  if jwt_token and refresh_token:
44
- print("Token verified!")
45
- store_jwt_securely(jwt_token, refresh_token)
48
+ print("Token verified.")
49
+ store_jwt(jwt_token, refresh_token)
46
50
  self.send_response_only(200, "OK")
47
51
  self.send_header("Content-type", "text/html")
48
52
  self.end_headers()
@@ -55,13 +59,12 @@ class CallbackHandler(BaseHTTPRequestHandler):
55
59
 
56
60
 
57
61
  def main():
58
- """Main function for the Prefab CLI."""
59
- parser = argparse.ArgumentParser(description="Prefab CLI")
62
+ """Main function for the Prefab authentication CLI."""
63
+ parser = argparse.ArgumentParser(description="PreFab Auth CLI")
60
64
  parser.add_argument("command", help="The command to run", choices=["setup"])
61
65
  parser.add_argument(
62
66
  "--port", help="Port number for the HTTP server", type=int, default=8000
63
67
  )
64
-
65
68
  args = parser.parse_args()
66
69
 
67
70
  if args.command == "setup":
prefab/compare.py CHANGED
@@ -1,4 +1,4 @@
1
- """Provides functions to measure the similarity between devices."""
1
+ """Functions to measure the structural similarity between devices."""
2
2
 
3
3
  import warnings
4
4
 
@@ -43,6 +43,11 @@ def intersection_over_union(device_a: Device, device_b: Device) -> float:
43
43
  -------
44
44
  float
45
45
  The Intersection over Union between two devices.
46
+
47
+ Warnings
48
+ --------
49
+ UserWarning
50
+ If one or both devices are not binarized.
46
51
  """
47
52
  if not device_a.is_binary or not device_b.is_binary:
48
53
  warnings.warn(
@@ -71,6 +76,11 @@ def hamming_distance(device_a: Device, device_b: Device) -> int:
71
76
  -------
72
77
  int
73
78
  The Hamming distance between two devices.
79
+
80
+ Warnings
81
+ --------
82
+ UserWarning
83
+ If one or both devices are not binarized.
74
84
  """
75
85
  if not device_a.is_binary or not device_b.is_binary:
76
86
  warnings.warn(
@@ -97,6 +107,11 @@ def dice_coefficient(device_a: Device, device_b: Device) -> float:
97
107
  -------
98
108
  float
99
109
  The Dice coefficient between two devices.
110
+
111
+ Warnings
112
+ --------
113
+ UserWarning
114
+ If one or both devices are not binarized.
100
115
  """
101
116
  if not device_a.is_binary or not device_b.is_binary:
102
117
  warnings.warn(