Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Al-Saffar committed Jun 24, 2024
1 parent 541a413 commit 42380a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion myresources/crocodile/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ def toml(obj: dict[Any, Any], path: PLike, encoding: str = 'utf-8'): return Path
@staticmethod
@save_decorator(".ini")
def ini(obj: dict[Any, Any], path: PLike, **kwargs: Any):
conf = install_n_import("configparser").ConfigParser()
# conf = install_n_import("configparser").ConfigParser()
import configparser
conf = configparser.ConfigParser()
conf.read_dict(obj)
with open(path, 'w', encoding="utf-8") as configfile: conf.write(configfile, **kwargs)
@staticmethod
Expand Down
10 changes: 6 additions & 4 deletions myresources/crocodile/deeplearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,10 @@ def compile(self, loss: Optional[Any] = None, optimizer: Optional[Any] = None, m
print(f"💥 Error while compiling the model.")
pass

def fit(self, viz: bool = True, weight_name: Optional[str] = None,
val_sample_weight: Optional['npt.NDArray[np.float64]'] = None, sample_weight: Optional['npt.NDArray[np.float64]'] = None,
def fit(self, viz: bool = True,
weight_name: Optional[str] = None,
val_sample_weight: Optional['npt.NDArray[np.float64]'] = None,
sample_weight: Optional['npt.NDArray[np.float64]'] = None,
verbose: Union[int, str] = "auto", callbacks: Optional[list[Any]] = None,
validation_freq: int = 1,
**kwargs: Any):
Expand All @@ -408,12 +410,12 @@ def fit(self, viz: bool = True, weight_name: Optional[str] = None,
train_weight_str = self.data.specs.get_split_names(names=[weight_name], which_split="train")[0]
sample_weight = self.data.split[train_weight_str]
else:
print(f"⚠️ sample_weight is passed directly to `fit` method, ignoring `weight_string` argument.")
print(f"⚠️ sample_weight is passed directly to `fit` method, ignoring `weight_name` argument.")
if val_sample_weight is None:
test_weight_str = self.data.specs.get_split_names(names=[weight_name], which_split="test")[0]
val_sample_weight = self.data.split[test_weight_str]
else:
print(f"⚠️ val_sample_weight is passed directly to `fit` method, ignoring `weight_string` argument.")
print(f"⚠️ val_sample_weight is passed directly to `fit` method, ignoring `weight_name` argument.")

x_test = x_test[0] if len(x_test) == 1 else x_test
y_test = y_test[0] if len(y_test) == 1 else y_test
Expand Down
6 changes: 3 additions & 3 deletions myresources/crocodile/file_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,11 @@ def yaml(path: PLike, r: bool = False) -> Any: # return could be list or dict e
_ = r
return mydict
@staticmethod
def ini(path: PLike):
def ini(path: PLike, encoding: Optional[str] = None):
if not Path(path).exists() or Path(path).is_dir(): raise FileNotFoundError(f"File not found: {path}")
import configparser
res = configparser.ConfigParser()
res.read(filenames=[str(path)])
res.read(filenames=[str(path)], encoding=encoding)
return res
@staticmethod
def toml(path: PLike): return install_n_import("tomli").loads(P(path).read_text())
Expand Down Expand Up @@ -466,7 +466,7 @@ def write_bytes(self, data: bytes, overwrite: bool = False) -> 'P':
if res == 0: raise RuntimeError(f"Could not save file on disk.")
return self
def touch(self, mode: int = 0o666, parents: bool = True, exist_ok: bool = True) -> 'P': # pylint: disable=W0237
if parents: self.parent.create(parents=parents)
if parents: self.parent.create(parents=parents)
super(P, self).touch(mode=mode, exist_ok=exist_ok)
return self
def symlink_from(self, src_folder: OPLike = None, src_file: OPLike = None, verbose: bool = False, overwrite: bool = False):
Expand Down

0 comments on commit 42380a1

Please sign in to comment.