pypharm 1.3.1__tar.gz → 1.3.2__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypharm
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: Module for solving pharmacokinetic problems
5
5
  Home-page: https://github.com/Krash13/PyPharm
6
6
  Author: Krash13
@@ -323,7 +323,7 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
323
323
 
324
324
  need_v_release_optimization = False
325
325
  release_parameters_target = None
326
- release_parameters_target = None
326
+ accumulation_parameters_target = None
327
327
 
328
328
  class ReleaseRK45(RK45):
329
329
 
@@ -496,6 +496,15 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
496
496
  accumulation_type=self.accumulation_type,
497
497
  c0=c0
498
498
  )
499
+ self.last_result.model_realized = c0 - self.get_release_function()(self.last_result.t, c0)
500
+ if self.with_accumulate:
501
+ model_accumulation = self.get_accumulation_function()(self.last_result.t, c0)
502
+ if self.accumulation_type == 1:
503
+ self.last_result.model_realized = model_accumulation - self.get_release_function()(self.last_result.t, c0)
504
+ elif self.accumulation_type == 2:
505
+ accumulation_coeffs = model_accumulation / c0
506
+ self.last_result.model_realized= accumulation_coeffs * self.get_release_function()(self.last_result.t, c0)
507
+ self.last_result.model_realized = model_accumulation - self.last_result.model_realized
499
508
  return self.last_result
500
509
 
501
510
  def _target_function(self, x, max_step=0.01, metric='R2'):
@@ -523,29 +532,13 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
523
532
  if metric == 'R2':
524
533
  plus = 0
525
534
  if self.teoretic_realized is not None:
526
- model_realized = c0 - self.get_release_function()(self.teoretic_x, c0)
527
- if self.with_accumulate:
528
- model_accumulation = self.get_accumulation_function()(self.teoretic_x, c0)
529
- if self.accumulation_type == 1:
530
- model_realized = model_accumulation - self.get_release_function()(self.teoretic_x, c0)
531
- elif self.accumulation_type == 2:
532
- accumulation_coeffs = model_accumulation / c0
533
- model_realized = accumulation_coeffs * self.get_release_function()(self.teoretic_x, c0)
534
- model_realized = model_accumulation - model_realized
535
+ model_realized = self.last_result.model_realized
535
536
  plus = np.sum(((model_realized - self.teoretic_realized) ** 2) / ((self.teoretic_realized - self.teoretic_realized_avg) ** 2))
536
537
  return plus + np.sum(np.sum(self.w * ((target_results - self.teoretic_y) ** 2), axis=1) / np.sum((self.teoretic_avg - self.teoretic_y) ** 2, axis=1))
537
538
  elif metric == 'norm':
538
539
  plus = 0
539
540
  if self.teoretic_realized is not None:
540
- model_realized = c0 - self.get_release_function()(self.teoretic_x, c0)
541
- if self.with_accumulate:
542
- model_accumulation = self.get_accumulation_function()(self.teoretic_x, c0)
543
- if self.accumulation_type == 1:
544
- model_realized = model_accumulation - self.get_release_function()(self.teoretic_x, c0)
545
- elif self.accumulation_type == 2:
546
- accumulation_coeffs = model_accumulation / c0
547
- model_realized = accumulation_coeffs * self.get_release_function()(self.teoretic_x, c0)
548
- model_realized = model_accumulation - model_realized
541
+ model_realized = self.last_result.model_realized
549
542
  plus = np.linalg.norm(self.teoretic_realized - model_realized)
550
543
  return plus + np.linalg.norm(target_results - self.teoretic_y)
551
544
  else:
@@ -597,3 +590,17 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
597
590
  s += self.release_parameters_target_count + int(self.need_v_release_optimization)
598
591
  self.accumulation_parameters[self.accumulation_parameters_target] = x[s:s + self.accumulation_parameters_target_count]
599
592
  return x
593
+
594
+ def plot_model(self, compartment_numbers=None, compartment_names={},
595
+ left=None, right=None, y_lims={}, plot_accumulation=False, **kwargs):
596
+ super().plot_model(compartment_numbers, compartment_names, left, right, y_lims, **kwargs)
597
+ if plot_accumulation:
598
+ if hasattr(self, "teoretic_x") and hasattr(self, "teoretic_realized"):
599
+ plt.plot(self.teoretic_x, self.teoretic_realized, "*r")
600
+ plt.plot(self.last_result.t, self.last_result.model_realized)
601
+ plt.title(compartment_names.get('realized', 'realized'))
602
+ plt.xlim(left=left, right=right)
603
+ if y_lims.get('realized'):
604
+ plt.ylim(y_lims.get('realized'))
605
+ plt.grid()
606
+ plt.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pypharm
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: Module for solving pharmacokinetic problems
5
5
  Home-page: https://github.com/Krash13/PyPharm
6
6
  Author: Krash13
@@ -6,7 +6,7 @@ def readme():
6
6
 
7
7
  setup(
8
8
  name='pypharm',
9
- version='1.3.1',
9
+ version='1.3.2',
10
10
  author='Krash13',
11
11
  author_email='krasheninnikov.r.s@muctr.ru',
12
12
  description='Module for solving pharmacokinetic problems',
File without changes
File without changes
File without changes