Skip to content

Commit

Permalink
no print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jul 25, 2021
1 parent bc2c24a commit c1b7094
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ repos:
- id: pylint
args: [--rcfile=.pylintrc]
files: ^pymc3/
- repo: https://github.com/MarcoGorelli/madforhooks
rev: 0.2.0
hooks:
- id: no-print-statements
files: ^pymc3/
- repo: local
hooks:
- id: check-no-tests-are-ignored
Expand Down
2 changes: 1 addition & 1 deletion pymc3/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ def perform(self, node, inputs, outputs, params=None):
log_det = np.sum(np.log(np.abs(s)))
z[0] = np.asarray(log_det, dtype=x.dtype)
except Exception:
print(f"Failed to compute logdet of {x}.")
sys.stdout.write(f"Failed to compute logdet of {x}.\n")
raise

def grad(self, inputs, g_outputs):
Expand Down
8 changes: 4 additions & 4 deletions pymc3/sampling_jax.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def sample_numpyro_nuts(
rv_samples.name = rv.name
sample_outputs.append(rv_samples)

print("Compiling...")
sys.stdout.write("Compiling...\n")

tic1 = pd.Timestamp.now()
_sample = compile_rv_inplace(
Expand All @@ -219,14 +219,14 @@ def sample_numpyro_nuts(
)
tic2 = pd.Timestamp.now()

print("Compilation time = ", tic2 - tic1)
sys.stdout.write(f"Compilation time = {tic2-tic1}")

print("Sampling...")
sys.stdout.write("Sampling...\n")

*mcmc_samples, leapfrogs_taken = _sample()
tic3 = pd.Timestamp.now()

print("Sampling time = ", tic3 - tic2)
sys.stdout.write(f"Sampling time = {tic3-tic2}")

posterior = {k.name: v for k, v in zip(sample_outputs, mcmc_samples)}

Expand Down
2 changes: 1 addition & 1 deletion pymc3/tuning/starting.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def dlogp_func(x):
assert isinstance(cost_func.progress, ProgressBar)
cost_func.progress.total = last_v
cost_func.progress.update(last_v)
print()
sys.stdout.write("\n")

mx0 = RaveledVars(mx0, x0.point_map_info)

Expand Down

0 comments on commit c1b7094

Please sign in to comment.