Skip to content

Conversation

@mzecc
Copy link
Collaborator

@mzecc mzecc commented Sep 24, 2025

Description

Added ResultInt and first attempt to bubble-up errors

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

Comment on lines 71 to 72
function build(self, data_v_in, error_v_in) result(res)
!! Build instance
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function build(self, data_v_in, error_v_in) result(res)
!! Build instance
subroutine build(self, data_v_in, error_v_in, res)
!! Build instance

I'm not sure what I like more. I don't love the pattern of using a function with effectively multiple return values. Now that I've seen it, using a subroutine seems to be a better option. What do you think?

@define
class ResultInt:
"""
Result type that can hold double precision real values
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Result type that can hold double precision real values
Result type that can hold (8 bit) integer values

Comment on lines 37 to 38
call get_available_instance_index(res_available_instance_index)
! MZ check for errors ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep we want to switch this to returniing ResultInt

res_build = instance_array(instance_index) % build(data_v_in=data_v_in, error_v_in=error_v_in)
call get_available_instance_index(res_available_instance_index)
! MZ check for errors ?
! MZ function with side effect: good idea??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ye I don't like it either, see my comments on the function

call get_available_instance_index(res_available_instance_index)
! MZ check for errors ?
! MZ function with side effect: good idea??
! MZ why res_build is ResultNone??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're calling a method on the object we already have so I was following the python convention of returning none which means the result has to be ResultNone. Is there another option?

! print *, "Index ", instance_index, " has not been claimed"
! error stop 1
! MZ Weird thing allocatable message
msg = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this line?

error stop 1
! print *, "Index ", instance_index, " has not been claimed"
! error stop 1
! MZ Weird thing allocatable message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep lots of mucking around. We may end up writing something like this https://gitlab.com/magicc/fgen/-/blob/switch-to-uv/packages/fgen-core/src/char_conversions.f90?ref_type=heads

or using someone else's equivalent if we can find a nice one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok the pros are here: https://github.com/fortran-lang/stdlib

we would either use their functions or could also just look at them and write our own versions because a) stdlib is MIT licensed so it's fine and b) we don't introduce the entire stdlib as a dependency that way

@mzecc mzecc requested a review from znicholls October 13, 2025 10:16
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 90.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.59%. Comparing base (ca2a5f5) to head (c42bb2d).

Files with missing lines Patch % Lines
src/example_fgen_basic/result/result_int.py 82.14% 3 Missing and 2 partials ⚠️
src/example_fgen_basic/get_square_root.py 88.88% 1 Missing and 1 partial ⚠️
src/example_fgen_basic/result/result_dp.py 96.77% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main      #36      +/-   ##
===========================================
- Coverage   100.00%   94.59%   -5.41%     
===========================================
  Files            7       11       +4     
  Lines           68      148      +80     
  Branches         0        6       +6     
===========================================
+ Hits            68      140      +72     
- Misses           0        5       +5     
- Partials         0        3       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants