hossam 0.3.5__py3-none-any.whl → 0.3.12__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.
hossam/__init__.py CHANGED
@@ -1,78 +1,85 @@
1
1
  from .data_loader import load_data, load_info
2
+ from .hs_stats import oneway_anova
2
3
  from matplotlib import pyplot as plt
3
4
  from matplotlib import font_manager as fm
4
5
  from importlib.resources import files, as_file
5
- import os
6
+ from importlib.metadata import version
7
+ from types import SimpleNamespace
6
8
  import warnings
7
9
 
8
- __version__ = '0.3.0'
9
- __all__ = ['load_data', 'load_info']
10
+ try:
11
+ __version__ = version("hossam")
12
+ except Exception:
13
+ __version__ = "develop"
10
14
 
11
- my_dpi = 200 # 이미지 선명도(100~300)
15
+
16
+ hs_fig = SimpleNamespace(
17
+ dpi=200,
18
+ width=600,
19
+ height=320,
20
+ font_size=6,
21
+ font_weight="light",
22
+ frame_width=0.4,
23
+ line_width=1,
24
+ grid_alpha=0.3,
25
+ grid_width=0.4,
26
+ fill_alpha=0.3
27
+ )
28
+
29
+ __all__ = ["load_data", "load_info", "hs_classroom", "hs_gis", "hs_plot", "hs_prep", "hs_stats", "hs_timeserise", "hs_util", "hs_fig"]
12
30
 
13
31
 
14
32
  def _init_korean_font():
15
- """패키지에 포함된 한글 폰트를 자동 등록하고 기본 폰트로 설정합니다.
33
+ """
34
+ 패키지에 포함된 한글 폰트를 기본 폰트로 설정합니다.
35
+ """
36
+ font_file = "NotoSansKR-Regular.ttf"
37
+ try:
38
+ # 패키지 리소스에서 폰트 파일 경로 확보
39
+ with as_file(files("hossam") / font_file) as font_path:
40
+ fm.fontManager.addfont(str(font_path))
41
+ fprop = fm.FontProperties(fname=str(font_path))
42
+ fname = fprop.get_name()
16
43
 
17
- - 패키지 내부의 NotoSansKR-Regular.ttf를 우선적으로 사용합니다.
18
- - 폰트 파일을 찾지 못하면 말굽고딕 등 시스템 폰트로 폴백합니다.
19
- """
20
- # 환경 변수 제어
21
- env_disable = os.environ.get('HOSSAM_FONT_DISABLE', '').lower() in {'1', 'true', 'yes'}
22
- env_family = os.environ.get('HOSSAM_FONT_FAMILY')
23
- env_size = os.environ.get('HOSSAM_FONT_SIZE')
24
- env_path = os.environ.get('HOSSAM_FONT_PATH')
44
+ plt.rcParams.update({
45
+ "font.family": fname,
46
+ "font.size": hs_fig.font_size,
47
+ "font.weight": hs_fig.font_weight,
48
+ "axes.unicode_minus": False,
49
+ "text.antialiased": True,
50
+ "lines.antialiased": True,
51
+ "patch.antialiased": True,
52
+ "figure.dpi": hs_fig.dpi,
53
+ "savefig.dpi": hs_fig.dpi * 2,
54
+ "text.hinting": "auto",
55
+ "text.hinting_factor": 8,
56
+ "pdf.fonttype": 42,
57
+ "ps.fonttype": 42,
58
+ })
59
+ print(
60
+ "\n✅ 시각화를 위한 한글 글꼴(NotoSansKR-Regular)이 자동 적용되었습니다."
61
+ )
62
+ return
63
+ except Exception as e:
64
+ warnings.warn(f"\n한글 폰트 초기화: 패키지 폰트 사용 실패 ({e}).")
25
65
 
26
- if env_disable:
27
- return
28
66
 
29
- # 우선순위 1: 사용자 지정 폰트 경로
30
- if env_path:
31
- try:
32
- fm.fontManager.addfont(env_path)
33
- fprop = fm.FontProperties(fname=env_path)
34
- fname = fprop.get_name()
35
- plt.rcParams['font.family'] = env_family or fname
36
- plt.rcParams['font.size'] = int(env_size) if env_size else 6
37
- plt.rcParams['axes.unicode_minus'] = False
38
- return
39
- except Exception as e:
40
- warnings.warn(f"환경 변수 경로 폰트 사용 실패 ({e}). 패키지/시스템 폰트로 폴백합니다.")
67
+ def _init():
41
68
 
42
- font_file = 'NotoSansKR-Regular.ttf'
43
- try:
44
- # 패키지 리소스에서 폰트 파일 경로 확보
45
- with as_file(files('hossam') / font_file) as font_path:
46
- fm.fontManager.addfont(str(font_path))
47
- fprop = fm.FontProperties(fname=str(font_path))
48
- fname = fprop.get_name()
49
- plt.rcParams['font.family'] = fname
50
- plt.rcParams['font.size'] = int(env_size) if env_size else 6
51
- plt.rcParams['axes.unicode_minus'] = False
52
- return
53
- except Exception as e:
54
- warnings.warn(f"한글 폰트 초기화: 패키지 폰트 사용 실패 ({e}). 시스템 폰트로 폴백합니다.")
69
+ # 안내 메시지 (블릿 리스트)
70
+ messages = [
71
+ "📦 아이티윌 이광호 강사가 제작한 라이브러리를 사용중입니다.",
72
+ "📚 자세한 사용 방법은 https://py.hossam.kr 을 참고하세요.",
73
+ "📧 Email: leekh4232@gmail.com",
74
+ "🎬 Youtube: https://www.youtube.com/@hossam-codingclub",
75
+ "📝 Blog: https://blog.hossam.kr/",
76
+ f"🔖 Version: {__version__}",
77
+ ]
55
78
 
56
- # 시스템 폰트 폴백 (Windows 우선: Malgun Gothic, 그 외 대안)
57
- fallback_fonts = [
58
- 'Malgun Gothic',
59
- 'NanumGothic',
60
- 'AppleGothic',
61
- 'Noto Sans CJK KR',
62
- 'Noto Sans KR',
63
- 'DejaVu Sans'
64
- ]
65
- for ff in ([env_family] if env_family else []) + fallback_fonts:
66
- try:
67
- plt.rcParams['font.family'] = ff
68
- plt.rcParams['font.size'] = int(env_size) if env_size else 6
69
- plt.rcParams['axes.unicode_minus'] = False
70
- return
71
- except Exception:
72
- continue
79
+ for msg in messages:
80
+ print(f"{msg}")
73
81
 
74
- warnings.warn('한글 폰트 초기화 실패: 적절한 폰트를 찾지 못했습니다.')
82
+ _init_korean_font()
75
83
 
76
84
 
77
- # 모듈 임포트 시점에 폰트 초기화 수행
78
- _init_korean_font()
85
+ _init()
hossam/data_loader.py CHANGED
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ # -------------------------------------------------------------
3
+
1
4
  import requests
2
5
  import json
3
6
  from os.path import join, exists
@@ -8,7 +11,7 @@ from typing import Optional
8
11
 
9
12
  BASE_URL = "https://data.hossam.kr"
10
13
 
11
-
14
+ # -------------------------------------------------------------
12
15
  def __get_df(path: str, index_col=None) -> DataFrame:
13
16
  p = path.rfind(".")
14
17
  exec = path[p+1:].lower()
@@ -54,6 +57,7 @@ def __get_df(path: str, index_col=None) -> DataFrame:
54
57
 
55
58
  return df
56
59
 
60
+ # -------------------------------------------------------------
57
61
  def __get_data_url(key: str, local: str = None) -> str:
58
62
  global BASE_URL
59
63
 
@@ -89,7 +93,7 @@ def __get_data_url(key: str, local: str = None) -> str:
89
93
 
90
94
  return path, info.get('desc'), info.get('index')
91
95
 
92
-
96
+ # -------------------------------------------------------------
93
97
  def load_info(search: str = None, local: str = None) -> DataFrame:
94
98
  """메타데이터에서 사용 가능한 데이터셋 정보를 로드한다.
95
99
 
@@ -152,7 +156,7 @@ def load_info(search: str = None, local: str = None) -> DataFrame:
152
156
 
153
157
  return my_df2
154
158
 
155
-
159
+ # -------------------------------------------------------------
156
160
  def load_data(key: str, local: str = None) -> Optional[DataFrame]:
157
161
  """키로 지정된 데이터셋을 로드한다.
158
162