-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MNT: Add Python 3.12 support #1057
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1057 +/- ##
==========================================
- Coverage 89.80% 89.80% -0.01%
==========================================
Files 63 63
Lines 7178 7177 -1
Branches 1374 1374
==========================================
- Hits 6446 6445 -1
Misses 532 532
Partials 200 200 ☔ View full report in Codecov by Sentry. |
searchpath = pkgr.resource_filename('bids', '/') | ||
template_file = 'modeling/report/report_template.jinja' | ||
loader = jinja2.PackageLoader('bids', 'modeling/report') | ||
template_file = 'report_template.jinja' | ||
else: | ||
searchpath, template_file = os.path.split(template_path) | ||
loader = jinja2.FileSystemLoader(os.path.dirname(template_path)) | ||
template_file = os.path.basename(template_path) | ||
|
||
env = jinja2.Environment( | ||
loader=jinja2.FileSystemLoader(searchpath=searchpath)) | ||
tpl = env.get_template(template_file) | ||
tpl = jinja2.Environment(loader=loader).get_template(template_file) | ||
|
||
model = snake_to_camel(report_dict['model']['name']) | ||
target_file = os.path.join( | ||
out_dir, f"{model}_report.html" | ||
) | ||
out_path = Path(out_dir) | ||
out_path.mkdir(parents=True, exist_ok=True) | ||
|
||
report_dict = deroot(report_dict, os.path.dirname(target_file)) | ||
report_dict = deroot(report_dict, str(out_path)) | ||
|
||
html = tpl.render(report_dict) | ||
Path(target_file).parent.mkdir(parents=True, exist_ok=True) | ||
Path(target_file).write_text(html) | ||
Path.write_text(out_path / f"{model}_report.html", html) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adelavega This was your bit, but the coverage report indicates that it's not tested. Could you verify that this still works as you intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, will do but it might take me a bit because i completely forgot the context.
as an aside, we certainly did not promote this feature nearly enough in the docs or otherwise... so maybe once this is tested we should add to the stats-model
website with a nice example. could also add some more model validation since this is what causes most users problems w/ stats-models/fitlins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: #918
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I manually ran the Jinja2 code, and what I changed it to above does load the template correctly. I'm going to go ahead and merge.
duration = math.ceil( # Round up to nearest second | ||
round(bin_sr * self.get_duration(), 3) # Cut off at millisecond precision | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python 3.11:
>>> sum([480.1] * 9)
4390.9
Python 3.12:
>>> sum([480.1] * 9)
4320.900000000001
It seems to me that we don't care about errors in the sub-millisecond range, so round to the nearest millisecond and then round up to the nearest second. Reduces the scope of potential bad rounding to N.4995
.
Builds on #1055, fixes one small bug and removes an import of the deprecated (and removed from default installations)
pkg_resources
.